mirror of
https://github.com/netchx/netch.git
synced 2026-04-01 19:15:09 +08:00
catch Geo error
This commit is contained in:
@@ -156,25 +156,32 @@ namespace Netch.Models
|
||||
|
||||
if (Country == null)
|
||||
{
|
||||
var databaseReader = new DatabaseReader("bin\\GeoLite2-Country.mmdb");
|
||||
|
||||
if (IPAddress.TryParse(Hostname, out _) == true)
|
||||
try
|
||||
{
|
||||
Country = databaseReader.Country(Hostname).Country.IsoCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
var DnsResult = DNS.Lookup(Hostname);
|
||||
var databaseReader = new DatabaseReader("bin\\GeoLite2-Country.mmdb");
|
||||
|
||||
if (DnsResult != null)
|
||||
if (IPAddress.TryParse(Hostname, out _) == true)
|
||||
{
|
||||
Country = databaseReader.Country(DnsResult).Country.IsoCode;
|
||||
Country = databaseReader.Country(Hostname).Country.IsoCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
Country = "UN";
|
||||
var DnsResult = DNS.Lookup(Hostname);
|
||||
|
||||
if (DnsResult != null)
|
||||
{
|
||||
Country = databaseReader.Country(DnsResult).Country.IsoCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
Country = "UN";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Country = "UN";
|
||||
}
|
||||
}
|
||||
|
||||
Group = Group.Equals("None") ? Group.ToUpper() : Group;
|
||||
|
||||
Reference in New Issue
Block a user