public IActionResult ValidateInput() { var ipaddr = new IPaddr(); ipaddr.def = "def"; ViewBag.def = Request.Host.Value; ipaddr._IPaddrInput = Request.Host.Host; //var i = View(new IPaddr()); return(View(ipaddr)); }
public IActionResult ValidateInput(IPaddr ipaddr) { if (!ModelState.IsValid) { return(View(ipaddr)); } //string test = inputString; //IPaddr IPaddrInput = new IPaddr(); //IPaddrInput.IPaddrInput = inputString; //System.Diagnostics.Debug.WriteLine("kaczucha_ipaddr" + ipaddr.IPaddrInput); return(RedirectToAction("Execute", "TheLast", new { inputString = ipaddr.IPaddrInput })); }
public IActionResult ValidateInput(string inputString) { IPaddr IPaddrInput = new IPaddr(); IPaddrInput.IPaddrInput = inputString; //if (ModelState.IsValid) //{ List <string> IPpartsList = GetIpaddressToList(IPaddrInput.IPaddrInput); double translatedIPaddress = TranslateIPaddress(IPpartsList); string ipToCheck = translatedIPaddress.ToString(); //Connnection NpgsqlConnection connection = new NpgsqlConnection("Server=127.0.0.1;UserId=postgres;Password=postgres;Database=ip2location"); //connection.Open(); String query = "select * from ip2location_db11 where '" + ipToCheck + "' between ip_from and ip_to"; NpgsqlCommand cmd = new NpgsqlCommand(query, connection); IPinfo3 IPdata = new IPinfo3(); //var model = new IPinfo(); using (connection) { connection.Open(); NpgsqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { IPdata.countryName = (String)rdr["country_name"]; IPdata.countryCode = (String)rdr["country_code"]; IPdata.regionName = (String)rdr["region_name"]; IPdata.cityName = (String)rdr["city_name"]; IPdata.zipCode = (String)rdr["zip_code"]; IPdata.longitude = (float)rdr["longitude"]; IPdata.latitude = (float)rdr["latitude"]; IPdata.timeZone = (String)rdr["time_zone"]; } connection.Close(); //} return(View(IPdata)); } //return View(IPaddrInput); }
public void Registrer(string ip, FileSettingElement settings) { if (settings.RangeCheck) { string ipr = IP.Masked(ip, settings.MaskSize); if (ips.ContainsKey(ipr)) { ips[ipr].Registrer(ip); } else { IP _ip = new IPrange(ip, settings.MaskSize, settings.Count, settings.UniqeIps) { ruleName = settings.RuleName, sourceFile = settings.SourceFile }; ips.Add(ipr, _ip); } } else { if (ips.ContainsKey(ip)) { ips[ip].Registrer(ip); } else { IP _ip = new IPaddr(ip, settings.Count) { ruleName = settings.RuleName, sourceFile = settings.SourceFile }; ips.Add(ip, _ip); } } }