From d1c7d4a8b6a3728d34217c65c407aeba733f2ede Mon Sep 17 00:00:00 2001 From: Erik Date: Fri, 24 Apr 2026 23:58:42 +0200 Subject: [PATCH] net: resolve ACDREAM_TEST_HOST via DNS, not just IPAddress.Parse MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allows hostnames like `play.coldeve.ac` in ACDREAM_TEST_HOST. Previously the env var fed `IPAddress.Parse` directly and threw "An invalid IP address was specified" on anything that wasn't a literal dotted IP. Now: `IPAddress.TryParse` first (fast path, unchanged for 127.0.0.1 / literal IPs); on failure, fall back to `Dns.GetHostAddresses` and prefer the first IPv4 address (ACE + retail both use IPv4 UDP exclusively). Tested against `play.coldeve.ac:9000` — resolves to 51.79.80.150, handshake succeeds, login to character Barris works end-to-end. --- src/AcDream.App/Rendering/GameWindow.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/AcDream.App/Rendering/GameWindow.cs b/src/AcDream.App/Rendering/GameWindow.cs index 44359db..cbd4b27 100644 --- a/src/AcDream.App/Rendering/GameWindow.cs +++ b/src/AcDream.App/Rendering/GameWindow.cs @@ -1066,7 +1066,21 @@ public sealed class GameWindow : IDisposable try { - var endpoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse(host), int.Parse(portStr)); + // Resolve DNS names (e.g. play.coldeve.ac) as well as literal + // IP addresses. `IPAddress.Parse` throws on hostnames; fall + // back to `Dns.GetHostAddresses` and prefer IPv4 (ACE + retail + // use IPv4 UDP exclusively). + System.Net.IPAddress ip; + if (!System.Net.IPAddress.TryParse(host, out ip!)) + { + var addrs = System.Net.Dns.GetHostAddresses(host); + ip = System.Array.Find(addrs, + a => a.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) + ?? (addrs.Length > 0 ? addrs[0] : throw new System.Exception( + $"DNS resolved no addresses for '{host}'")); + Console.WriteLine($"live: resolved {host} → {ip}"); + } + var endpoint = new System.Net.IPEndPoint(ip, int.Parse(portStr)); Console.WriteLine($"live: connecting to {endpoint} as {user}"); _liveSession = new AcDream.Core.Net.WorldSession(endpoint); _liveSession.EntitySpawned += OnLiveEntitySpawned;