Merge pull request #9215 from LipkeGu/upnp_externalip_fix

Move NAT Logic from ClientTooltipLogic into its own Function at LobbyUtils.
This commit is contained in:
abcdefg30
2015-09-19 17:22:02 +02:00
2 changed files with 15 additions and 4 deletions

View File

@@ -79,10 +79,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var ping = orderManager.LobbyInfo.PingFromClient(client);
latency.GetText = () => LobbyUtils.LatencyDescription(ping);
latency.GetColor = () => LobbyUtils.LatencyColor(ping);
var address = orderManager.LobbyInfo.ClientWithIndex(clientIndex).IpAddress;
if (clientIndex == orderManager.LocalClient.Index && UPnP.NatDevice != null
&& address == IPAddress.Loopback.ToString())
address = UPnP.NatDevice.GetExternalIP().ToString();
var address = LobbyUtils.GetExternalIP(clientIndex, orderManager);
var cachedDescriptiveIP = LobbyUtils.DescriptiveIpAddress(address);
ip.GetText = () => cachedDescriptiveIP;
var cachedCountryLookup = GeoIP.LookupCountry(address);

View File

@@ -482,5 +482,18 @@ namespace OpenRA.Mods.Common.Widgets.Logic
};
playerName.GetColor = () => player.Color.RGB;
}
public static string GetExternalIP(int clientIndex, OrderManager orderManager)
{
var address = orderManager.LobbyInfo.ClientWithIndex(clientIndex).IpAddress;
if (clientIndex == orderManager.LocalClient.Index && address == IPAddress.Loopback.ToString() && UPnP.NatDevice != null)
{
var externalIP = UPnP.NatDevice.GetExternalIP();
if (externalIP != null)
address = externalIP.ToString();
}
return address;
}
}
}