try to grab the external IP of localhost from the NAT router

This commit is contained in:
Matthias Mailänder
2013-08-07 19:07:23 +02:00
parent feb7f80a39
commit 9d40b430dc
3 changed files with 7 additions and 1 deletions

View File

@@ -16,7 +16,7 @@ using Mono.Nat.Upnp;
namespace OpenRA.Network
{
class UPnP
public class UPnP
{
public static INatDevice NatDevice;

View File

@@ -75,6 +75,10 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\thirdparty\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference>
<Reference Include="Mono.Nat">
<HintPath>..\thirdparty\Mono.Nat.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Activities\LegacyCaptureActor.cs" />

View File

@@ -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);
}