@@ -317,10 +317,7 @@ private static NetworkEndpoint ParseNetworkEndpoint(string ip, ushort port, bool
317
317
if ( ! NetworkEndpoint . TryParse ( ip , port , out endpoint , NetworkFamily . Ipv4 ) &&
318
318
! NetworkEndpoint . TryParse ( ip , port , out endpoint , NetworkFamily . Ipv6 ) )
319
319
{
320
- if ( ! silent )
321
- {
322
- Debug . LogError ( $ "Invalid network endpoint: { ip } :{ port } .") ;
323
- }
320
+ return default ;
324
321
}
325
322
326
323
return endpoint ;
@@ -539,11 +536,21 @@ private bool ClientBindAndConnect()
539
536
serverEndpoint = ConnectionData . ServerEndPoint ;
540
537
}
541
538
539
+ NetworkConnection serverConnection ;
540
+
542
541
// Verify the endpoint is valid before proceeding
543
542
if ( serverEndpoint . Family == NetworkFamily . Invalid )
544
543
{
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
545
551
Debug . LogError ( $ "Target server network address ({ ConnectionData . Address } ) is { nameof ( NetworkFamily . Invalid ) } !") ;
546
552
return false ;
553
+ #endif
547
554
}
548
555
549
556
InitDriver ( ) ;
@@ -556,7 +563,7 @@ private bool ClientBindAndConnect()
556
563
return false ;
557
564
}
558
565
559
- var serverConnection = m_Driver . Connect ( serverEndpoint ) ;
566
+ serverConnection = m_Driver . Connect ( serverEndpoint ) ;
560
567
m_ServerClientId = ParseClientId ( serverConnection ) ;
561
568
562
569
return true ;
@@ -647,7 +654,7 @@ public void SetClientRelayData(string ipAddress, ushort port, byte[] allocationI
647
654
/// <summary>
648
655
/// Sets IP and Port information. This will be ignored if using the Unity Relay and you should call <see cref="SetRelayServerData"/>
649
656
/// </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>
651
658
/// <param name="port">The remote port</param>
652
659
/// <param name="listenAddress">The local listen address</param>
653
660
public void SetConnectionData ( string ipv4Address , ushort port , string listenAddress = null )
0 commit comments