Evaluate player location on the server.

This commit is contained in:
Paul Chote
2020-01-11 12:14:10 +00:00
committed by abcdefg30
parent c430884c8b
commit 6b2c019caa
6 changed files with 8 additions and 26 deletions

View File

@@ -338,8 +338,6 @@ namespace OpenRA
}
}
GeoIP.Initialize();
if (Settings.Server.DiscoverNatDevices)
discoverNat = UPnP.DiscoverNatDevices(Settings.Server.NatDiscoveryTimeout);

View File

@@ -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

View File

@@ -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,