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;