Merge pull request #8149 from Mailaender/fetch-geoip-db
Automatized GeoIP database download
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user