Skip to content

Commit

Permalink
Merge pull request #1 from Bohicatv/main
Browse files Browse the repository at this point in the history
fix: Ensure server listing address is used when set in config (modernuo#1960)
  • Loading branch information
Eaprime1 authored Sep 24, 2024
2 parents 2a7aa19 + 3a3c651 commit 0e003b5
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 0e003b5

Please sign in to comment.