Skip to content

Commit

Permalink
fix: Ensure server listing address is used when set in config
Browse files Browse the repository at this point in the history
  • Loading branch information
jkappers committed Sep 21, 2024
1 parent 2a7aa19 commit 4bbb83c
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 is not 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 4bbb83c

Please sign in to comment.