diff --git a/AUTHORS b/AUTHORS index 26dd59cf05..44c75afe26 100644 --- a/AUTHORS +++ b/AUTHORS @@ -163,9 +163,6 @@ Using OpenAL Soft distributed under the GNU LGPL. Using MaxMind GeoIP2 .NET API distributed under the Apache 2.0 license. -Using GeoLite2 data created by MaxMind and -distributed under the CC BY-SA 3.0 license. - Using SDL2-CS and OpenAL-CS created by Ethan Lee and released under the zlib license. diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 847b16d521..352cfa5999 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -338,8 +338,6 @@ namespace OpenRA } } - GeoIP.Initialize(); - if (Settings.Server.DiscoverNatDevices) discoverNat = UPnP.DiscoverNatDevices(Settings.Server.NatDiscoveryTimeout); diff --git a/OpenRA.Game/Network/Session.cs b/OpenRA.Game/Network/Session.cs index c21c9bbac7..51e34e2b16 100644 --- a/OpenRA.Game/Network/Session.cs +++ b/OpenRA.Game/Network/Session.cs @@ -116,6 +116,7 @@ namespace OpenRA.Network public int SpawnPoint; public string Name; public string IpAddress; + public string Location; public ClientState State = ClientState.Invalid; public int Team; public string Slot; // Slot ID, or null for observer diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index 5fd4c8bd0a..8c94753262 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -149,6 +149,8 @@ namespace OpenRA.Server randomSeed = (int)DateTime.Now.ToBinary(); + GeoIP.Initialize(); + if (UPnP.Status == UPnPStatus.Enabled) UPnP.ForwardPort(Settings.ListenPort, Settings.ListenPort).Wait(); @@ -341,10 +343,12 @@ namespace OpenRA.Server return; } + var ipAddress = ((IPEndPoint)newConn.Socket.RemoteEndPoint).Address; var client = new Session.Client { Name = OpenRA.Settings.SanitizedPlayerName(handshake.Client.Name), - IpAddress = ((IPEndPoint)newConn.Socket.RemoteEndPoint).Address.ToString(), + IpAddress = ipAddress.ToString(), + Location = GeoIP.LookupCountry(ipAddress.ToString()), Index = newConn.PlayerIndex, PreferredColor = handshake.Client.PreferredColor, Color = handshake.Client.Color, diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs index caee016a4b..d25d11ce19 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs @@ -593,20 +593,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic HideChildWidget(parent, "STATUS_IMAGE"); } - public static string GetExternalIP(Session.Client client, OrderManager orderManager) - { - var address = client != null ? client.IpAddress : ""; - var lc = orderManager.LocalClient; - if (lc != null && lc.Index == client.Index && address == IPAddress.Loopback.ToString()) - { - var externalIP = UPnP.ExternalIP; - if (externalIP != null) - address = externalIP.ToString(); - } - - return address; - } - public static void SetupChatLine(ContainerWidget template, DateTime time, string name, Color nameColor, string text, Color textColor) { var nameLabel = template.Get("NAME"); diff --git a/OpenRA.Mods.Common/Widgets/Logic/PlayerProfileLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/PlayerProfileLogic.cs index 736a3f756b..70aeaaafbc 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/PlayerProfileLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/PlayerProfileLogic.cs @@ -312,19 +312,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic [ObjectCreator.UseCtor] public AnonymousProfileTooltipLogic(Widget widget, OrderManager orderManager, Session.Client client) { - var address = LobbyUtils.GetExternalIP(client, orderManager); - var cachedDescriptiveIP = address ?? "Unknown IP"; - var nameLabel = widget.Get("NAME"); var nameFont = Game.Renderer.Fonts[nameLabel.Font]; widget.Bounds.Width = nameFont.Measure(nameLabel.Text).X + 2 * nameLabel.Bounds.Left; var ipLabel = widget.Get("IP"); - ipLabel.GetText = () => cachedDescriptiveIP; + ipLabel.GetText = () => client.IpAddress; var locationLabel = widget.Get("LOCATION"); - var cachedCountryLookup = GeoIP.LookupCountry(address); - locationLabel.GetText = () => cachedCountryLookup; + locationLabel.GetText = () => client.Location; if (client.IsAdmin) {