@@ -317,10 +317,7 @@ private static NetworkEndpoint ParseNetworkEndpoint(string ip, ushort port, bool
317317 if ( ! NetworkEndpoint . TryParse ( ip , port , out endpoint , NetworkFamily . Ipv4 ) &&
318318 ! NetworkEndpoint . TryParse ( ip , port , out endpoint , NetworkFamily . Ipv6 ) )
319319 {
320- if ( ! silent )
321- {
322- Debug . LogError ( $ "Invalid network endpoint: { ip } :{ port } .") ;
323- }
320+ return default ;
324321 }
325322
326323 return endpoint ;
@@ -539,11 +536,21 @@ private bool ClientBindAndConnect()
539536 serverEndpoint = ConnectionData . ServerEndPoint ;
540537 }
541538
539+ NetworkConnection serverConnection ;
540+
542541 // Verify the endpoint is valid before proceeding
543542 if ( serverEndpoint . Family == NetworkFamily . Invalid )
544543 {
544+ #if HOSTNAME_RESOLUTION_AVAILABLE && UTP_TRANSPORT_2_4_ABOVE
545+ // If it's not valid, try to treat it like a URL.
546+ InitDriver ( ) ;
547+ serverConnection = m_Driver . Connect ( ConnectionData . Address , ConnectionData . Port ) ;
548+ m_ServerClientId = ParseClientId ( serverConnection ) ;
549+ return true ;
550+ #else
545551 Debug . LogError ( $ "Target server network address ({ ConnectionData . Address } ) is { nameof ( NetworkFamily . Invalid ) } !") ;
546552 return false ;
553+ #endif
547554 }
548555
549556 InitDriver ( ) ;
@@ -556,7 +563,7 @@ private bool ClientBindAndConnect()
556563 return false ;
557564 }
558565
559- var serverConnection = m_Driver . Connect ( serverEndpoint ) ;
566+ serverConnection = m_Driver . Connect ( serverEndpoint ) ;
560567 m_ServerClientId = ParseClientId ( serverConnection ) ;
561568
562569 return true ;
@@ -647,7 +654,7 @@ public void SetClientRelayData(string ipAddress, ushort port, byte[] allocationI
647654 /// <summary>
648655 /// Sets IP and Port information. This will be ignored if using the Unity Relay and you should call <see cref="SetRelayServerData"/>
649656 /// </summary>
650- /// <param name="ipv4Address">The remote IP address (despite the name, can be an IPv6 address)</param>
657+ /// <param name="ipv4Address">The remote IP address (despite the name, can be an IPv6 address or a domain name )</param>
651658 /// <param name="port">The remote port</param>
652659 /// <param name="listenAddress">The local listen address</param>
653660 public void SetConnectionData ( string ipv4Address , ushort port , string listenAddress = null )
0 commit comments