Skip to content

Commit 84f080b

Browse files
authored
Added support for IPv6 (SubnauticaNitrox#1264)
* Added support for IPv6 * Simplified regex * Simplified regex
1 parent 76f8ca5 commit 84f080b

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

NitroxClient/MonoBehaviours/Gui/MainMenu/MainMenuMultiplayerPanel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public void RemoveServer(int index)
104104

105105
public void OpenJoinServerMenu(string serverIp)
106106
{
107-
IPEndPoint endpoint = ResolveIpv4(serverIp) ?? ResolveHostName(serverIp);
107+
IPEndPoint endpoint = ResolveIp(serverIp) ?? ResolveHostName(serverIp);
108108
if (endpoint == null)
109109
{
110110
Log.InGame($"Unable to resolve remote address: {serverIp}");
@@ -163,9 +163,9 @@ private void LoadSavedServers()
163163
}
164164
}
165165

166-
private IPEndPoint ResolveIpv4(string serverIp)
166+
private IPEndPoint ResolveIp(string serverIp)
167167
{
168-
Match match = Regex.Match(serverIp, @"^((?:\d{1,3}\.){3}\d{1,3})\:?(\d{2,5})?$"); // Pattern test url: https://regex101.com/r/NZsD0l/1
168+
Match match = Regex.Match(serverIp, @"^((?:(?:[\da-f]+:??){8}|[\d\.]+|[^:\s]+)):?(\d+)?$"); // Pattern test url: https://regex101.com/r/WY4FWp/10
169169
if (!match.Success)
170170
{
171171
return null;

0 commit comments

Comments
 (0)