From 3a3c651b8508b60437ebd0bf4ac77a57ad721bc9 Mon Sep 17 00:00:00 2001 From: Joshua Kappers Date: Sun, 22 Sep 2024 00:34:56 -0500 Subject: [PATCH] fix: Ensure server listing address is used when set in config (#1960) --- Projects/UOContent/Misc/ServerList.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Projects/UOContent/Misc/ServerList.cs b/Projects/UOContent/Misc/ServerList.cs index 3a9c39cf8..56cbaad2a 100644 --- a/Projects/UOContent/Misc/ServerList.cs +++ b/Projects/UOContent/Misc/ServerList.cs @@ -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); @@ -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); + } } } @@ -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;