Merge pull request #8149 from Mailaender/fetch-geoip-db

Automatized GeoIP database download
This commit is contained in:
Pavel Penev
2015-05-24 16:43:22 +03:00
13 changed files with 89 additions and 32 deletions

View File

@@ -85,7 +85,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
address = UPnP.NatDevice.GetExternalIP().ToString();
var cachedDescriptiveIP = LobbyUtils.DescriptiveIpAddress(address);
ip.GetText = () => cachedDescriptiveIP;
var cachedCountryLookup = LobbyUtils.LookupCountry(address);
var cachedCountryLookup = GeoIP.LookupCountry(address);
location.GetText = () => cachedCountryLookup;
}
}

View File

@@ -235,21 +235,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
return ip;
}
public static string LookupCountry(string ip)
{
const string Unknown = "Unknown Location";
try
{
return Game.GeoIpDatabase.Country(ip).Country.Name ?? Unknown;
}
catch (Exception e)
{
Log.Write("geoip", "LookupCountry failed: {0}", e);
return Unknown;
}
}
public static void SetupClientWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager, bool visible)
{
parent.Get("ADMIN_INDICATOR").IsVisible = () => c.IsAdmin;