Merge pull request #4108 from Mailaender/unknown-hosts
Allow the display of unknown IP addresses
This commit is contained in:
@@ -33,7 +33,6 @@ namespace OpenRA.Mods.RA.Server
|
|||||||
server.SendMessage(masterServerMessages.Dequeue());
|
server.SendMessage(masterServerMessages.Dequeue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void LobbyInfoSynced(S server) { PingMasterServer(server); }
|
public void LobbyInfoSynced(S server) { PingMasterServer(server); }
|
||||||
public void GameStarted(S server) { PingMasterServer(server); }
|
public void GameStarted(S server) { PingMasterServer(server); }
|
||||||
public void GameEnded(S server) { PingMasterServer(server); }
|
public void GameEnded(S server) { PingMasterServer(server); }
|
||||||
@@ -65,7 +64,7 @@ namespace OpenRA.Mods.RA.Server
|
|||||||
wc.DownloadData(
|
wc.DownloadData(
|
||||||
server.Settings.MasterServer + url.F(
|
server.Settings.MasterServer + url.F(
|
||||||
server.Settings.ExternalPort, Uri.EscapeUriString(server.Settings.Name),
|
server.Settings.ExternalPort, Uri.EscapeUriString(server.Settings.Name),
|
||||||
(int) server.State,
|
(int)server.State,
|
||||||
server.lobbyInfo.Clients.Where(c1 => c1.Bot == null).Count(),
|
server.lobbyInfo.Clients.Where(c1 => c1.Bot == null).Count(),
|
||||||
server.lobbyInfo.Clients.Where(c1 => c1.Bot != null).Count(),
|
server.lobbyInfo.Clients.Where(c1 => c1.Bot != null).Count(),
|
||||||
Game.CurrentMods.Select(f => "{0}@{1}".F(f.Key, f.Value.Version)).JoinWith(","),
|
Game.CurrentMods.Select(f => "{0}@{1}".F(f.Key, f.Value.Version)).JoinWith(","),
|
||||||
@@ -80,11 +79,11 @@ namespace OpenRA.Mods.RA.Server
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Log.Write("server", ex.ToString());
|
Log.Write("server", ex.ToString());
|
||||||
lock( masterServerMessages )
|
lock (masterServerMessages)
|
||||||
masterServerMessages.Enqueue( "Master server communication failed." );
|
masterServerMessages.Enqueue("Master server communication failed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
isBusy = false;
|
isBusy = false;
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Widgets;
|
|
||||||
using OpenRA.Network;
|
using OpenRA.Network;
|
||||||
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA.Widgets.Logic
|
namespace OpenRA.Mods.RA.Widgets.Logic
|
||||||
{
|
{
|
||||||
@@ -31,13 +31,13 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
var latencyPrefixFont = Game.Renderer.Fonts[latencyPrefix.Font];
|
var latencyPrefixFont = Game.Renderer.Fonts[latencyPrefix.Font];
|
||||||
|
|
||||||
var ip = widget.Get<LabelWidget>("IP");
|
var ip = widget.Get<LabelWidget>("IP");
|
||||||
var ipFont = Game.Renderer.Fonts[ip.Font];
|
var addressFont = Game.Renderer.Fonts[ip.Font];
|
||||||
|
|
||||||
var location = widget.Get<LabelWidget>("LOCATION");
|
var location = widget.Get<LabelWidget>("LOCATION");
|
||||||
var locationFont = Game.Renderer.Fonts[location.Font];
|
var locationFont = Game.Renderer.Fonts[location.Font];
|
||||||
|
|
||||||
var locationOffset = location.Bounds.Y;
|
var locationOffset = location.Bounds.Y;
|
||||||
var ipOffset = ip.Bounds.Y;
|
var addressOffset = ip.Bounds.Y;
|
||||||
var latencyOffset = latency.Bounds.Y;
|
var latencyOffset = latency.Bounds.Y;
|
||||||
var tooltipHeight = widget.Bounds.Height;
|
var tooltipHeight = widget.Bounds.Height;
|
||||||
|
|
||||||
@@ -46,16 +46,16 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
tooltipContainer.IsVisible = () => (orderManager.LobbyInfo.ClientWithIndex(clientIndex) != null);
|
tooltipContainer.IsVisible = () => (orderManager.LobbyInfo.ClientWithIndex(clientIndex) != null);
|
||||||
tooltipContainer.BeforeRender = () =>
|
tooltipContainer.BeforeRender = () =>
|
||||||
{
|
{
|
||||||
var latencyPrefixSize = latencyPrefix.Bounds.X + latencyPrefixFont.Measure(latencyPrefix.GetText()+" ").X;
|
var latencyPrefixSize = latencyPrefix.Bounds.X + latencyPrefixFont.Measure(latencyPrefix.GetText() + " ").X;
|
||||||
var width = Math.Max(locationFont.Measure(location.GetText()).X, (Math.Max(adminFont.Measure(admin.GetText()).X,
|
var width = Math.Max(locationFont.Measure(location.GetText()).X, Math.Max(adminFont.Measure(admin.GetText()).X,
|
||||||
Math.Max(ipFont.Measure(ip.GetText()).X, latencyPrefixSize + latencyFont.Measure(latency.GetText()).X))));
|
Math.Max(addressFont.Measure(ip.GetText()).X, latencyPrefixSize + latencyFont.Measure(latency.GetText()).X)));
|
||||||
widget.Bounds.Width = width + 2 * margin;
|
widget.Bounds.Width = width + 2 * margin;
|
||||||
latency.Bounds.Width = widget.Bounds.Width;
|
latency.Bounds.Width = widget.Bounds.Width;
|
||||||
ip.Bounds.Width = widget.Bounds.Width;
|
ip.Bounds.Width = widget.Bounds.Width;
|
||||||
admin.Bounds.Width = widget.Bounds.Width;
|
admin.Bounds.Width = widget.Bounds.Width;
|
||||||
location.Bounds.Width = widget.Bounds.Width;
|
location.Bounds.Width = widget.Bounds.Width;
|
||||||
|
|
||||||
ip.Bounds.Y = ipOffset;
|
ip.Bounds.Y = addressOffset;
|
||||||
latency.Bounds.Y = latencyOffset;
|
latency.Bounds.Y = latencyOffset;
|
||||||
location.Bounds.Y = locationOffset;
|
location.Bounds.Y = locationOffset;
|
||||||
widget.Bounds.Height = tooltipHeight;
|
widget.Bounds.Height = tooltipHeight;
|
||||||
@@ -75,14 +75,13 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
admin.IsVisible = () => orderManager.LobbyInfo.ClientWithIndex(clientIndex).IsAdmin;
|
admin.IsVisible = () => orderManager.LobbyInfo.ClientWithIndex(clientIndex).IsAdmin;
|
||||||
latency.GetText = () => LobbyUtils.LatencyDescription(orderManager.LobbyInfo.ClientWithIndex(clientIndex).Latency);
|
latency.GetText = () => LobbyUtils.LatencyDescription(orderManager.LobbyInfo.ClientWithIndex(clientIndex).Latency);
|
||||||
latency.GetColor = () => LobbyUtils.LatencyColor(orderManager.LobbyInfo.ClientWithIndex(clientIndex).Latency);
|
latency.GetColor = () => LobbyUtils.LatencyColor(orderManager.LobbyInfo.ClientWithIndex(clientIndex).Latency);
|
||||||
var ipAddress = orderManager.LobbyInfo.ClientWithIndex(clientIndex).IpAddress;
|
var address = orderManager.LobbyInfo.ClientWithIndex(clientIndex).IpAddress;
|
||||||
if ((ipAddress == null || ipAddress == "127.0.0.1") && UPnP.NatDevice != null)
|
if (address == "127.0.0.1" && UPnP.NatDevice != null)
|
||||||
ipAddress = UPnP.NatDevice.GetExternalIP().ToString();
|
address = UPnP.NatDevice.GetExternalIP().ToString();
|
||||||
var cachedDescriptiveIP = LobbyUtils.DescriptiveIpAddress(ipAddress);
|
var cachedDescriptiveIP = LobbyUtils.DescriptiveIpAddress(address);
|
||||||
ip.GetText = () => cachedDescriptiveIP;
|
ip.GetText = () => cachedDescriptiveIP;
|
||||||
var cachedCountryLookup = LobbyUtils.LookupCountry(ipAddress);
|
var cachedCountryLookup = LobbyUtils.LookupCountry(address);
|
||||||
location.GetText = () => cachedCountryLookup;
|
location.GetText = () => cachedCountryLookup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user