Evaluate player location on the server.
This commit is contained in:
3
AUTHORS
3
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.
|
||||
|
||||
|
||||
@@ -338,8 +338,6 @@ namespace OpenRA
|
||||
}
|
||||
}
|
||||
|
||||
GeoIP.Initialize();
|
||||
|
||||
if (Settings.Server.DiscoverNatDevices)
|
||||
discoverNat = UPnP.DiscoverNatDevices(Settings.Server.NatDiscoveryTimeout);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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<LabelWidget>("NAME");
|
||||
|
||||
@@ -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<LabelWidget>("NAME");
|
||||
var nameFont = Game.Renderer.Fonts[nameLabel.Font];
|
||||
widget.Bounds.Width = nameFont.Measure(nameLabel.Text).X + 2 * nameLabel.Bounds.Left;
|
||||
|
||||
var ipLabel = widget.Get<LabelWidget>("IP");
|
||||
ipLabel.GetText = () => cachedDescriptiveIP;
|
||||
ipLabel.GetText = () => client.IpAddress;
|
||||
|
||||
var locationLabel = widget.Get<LabelWidget>("LOCATION");
|
||||
var cachedCountryLookup = GeoIP.LookupCountry(address);
|
||||
locationLabel.GetText = () => cachedCountryLookup;
|
||||
locationLabel.GetText = () => client.Location;
|
||||
|
||||
if (client.IsAdmin)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user