From 9d40b430dc8b2ee50203ad0e602737144e68ff36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Wed, 7 Aug 2013 19:07:23 +0200 Subject: [PATCH] try to grab the external IP of localhost from the NAT router --- OpenRA.Game/Network/UPnP.cs | 2 +- OpenRA.Mods.RA/OpenRA.Mods.RA.csproj | 4 ++++ OpenRA.Mods.RA/Widgets/Logic/ClientTooltipLogic.cs | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/OpenRA.Game/Network/UPnP.cs b/OpenRA.Game/Network/UPnP.cs index 4252a86af3..7676566e31 100644 --- a/OpenRA.Game/Network/UPnP.cs +++ b/OpenRA.Game/Network/UPnP.cs @@ -16,7 +16,7 @@ using Mono.Nat.Upnp; namespace OpenRA.Network { - class UPnP + public class UPnP { public static INatDevice NatDevice; diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 75191b6a01..f8a6799fe9 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -75,6 +75,10 @@ False ..\thirdparty\ICSharpCode.SharpZipLib.dll + + ..\thirdparty\Mono.Nat.dll + False + diff --git a/OpenRA.Mods.RA/Widgets/Logic/ClientTooltipLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/ClientTooltipLogic.cs index 07d911c033..8aee073cc5 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/ClientTooltipLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/ClientTooltipLogic.cs @@ -68,6 +68,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic admin.IsVisible = () => orderManager.LobbyInfo.ClientWithIndex(clientIndex).IsAdmin; latency.GetText = () => "Latency: {0}".F(LobbyUtils.LatencyDescription(orderManager.LobbyInfo.ClientWithIndex(clientIndex).Latency)); var ipAddress = orderManager.LobbyInfo.ClientWithIndex(clientIndex).IpAddress; + if ((ipAddress == null || ipAddress == "127.0.0.1") && UPnP.NatDevice != null) + ipAddress = UPnP.NatDevice.GetExternalIP().ToString(); ip.GetText = () => LobbyUtils.DescriptiveIpAddress(ipAddress); location.GetText = () => LobbyUtils.LookupCountry(ipAddress); }