Skip to content

Commit

Permalink
fix: Ensure server listing address is used when set in config (#1960)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkappers authored Sep 22, 2024
1 parent 2a7aa19 commit 3a3c651
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Projects/UOContent/Misc/ServerList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public static class ServerList

public static bool AutoDetect { get; private set; }

private static bool _useServerListingAddressConfig { get; set; }

public static void Configure()
{
Address = ServerConfiguration.GetOrUpdateSetting("serverListing.address", null);
Expand All @@ -60,6 +62,13 @@ public static void Initialize()
else
{
Resolve(Address, out _publicAddress);

if (_publicAddress != null)
{
_useServerListingAddressConfig = true;

logger.Information("Server listing address set from config: {address}", _publicAddress);
}
}
}

Expand All @@ -79,9 +88,14 @@ public static void OnServerListEvent(GatewayServer.ServerListEventArgs e)
var localAddress = ipep.Address;
var localPort = ipep.Port;

if (IsPrivateNetwork(localAddress))
if (_useServerListingAddressConfig)
{
localAddress = _publicAddress;
}
else if (IsPrivateNetwork(localAddress))
{
ipep = (IPEndPoint)ns.Connection.RemoteEndPoint;

if (ipep == null || !IsPrivateNetwork(ipep.Address) && _publicAddress != null)
{
localAddress = _publicAddress;
Expand Down

0 comments on commit 3a3c651

Please sign in to comment.