@@ -581,6 +581,14 @@ function getStats(obj, idx) {
581581 return stats [ idx ] ;
582582}
583583
584+ function addressOrLocalhost ( address , type ) {
585+ return address || ( type === AF_INET6 ? '::' : '0.0.0.0' ) ;
586+ }
587+
588+ function lookupOrDefault ( lookup , type ) {
589+ return lookup || ( type === AF_INET6 ? lookup6 : lookup4 ) ;
590+ }
591+
584592// QuicEndpoint wraps a UDP socket and is owned
585593// by a QuicSocket. It does not exist independently
586594// of the QuicSocket.
@@ -610,9 +618,9 @@ class QuicEndpoint {
610618 } = validateQuicEndpointOptions ( options ) ;
611619 const state = this [ kInternalState ] ;
612620 state . socket = socket ;
613- state . address = address || ( type === AF_INET6 ? '::' : '0.0.0.0' ) ;
621+ state . address = addressOrLocalhost ( address , type ) ;
622+ state . lookup = lookupOrDefault ( lookup , type ) ;
614623 state . ipv6Only = ipv6Only ;
615- state . lookup = lookup || ( type === AF_INET6 ? lookup6 : lookup4 ) ;
616624 state . port = port ;
617625 state . reuseAddr = reuseAddr ;
618626 state . type = type ;
@@ -901,8 +909,8 @@ class QuicSocket extends EventEmitter {
901909 const state = this [ kInternalState ] ;
902910
903911 state . client = client ;
904- state . lookup = lookup || ( type === AF_INET6 ? lookup6 : lookup4 ) ;
905912 state . server = server ;
913+ state . lookup = lookupOrDefault ( lookup , type ) ;
906914
907915 let socketOptions = 0 ;
908916 if ( validateAddress )
@@ -1286,7 +1294,7 @@ class QuicSocket extends EventEmitter {
12861294 // Notice here that connectAfterLookup is bound to the QuicSession
12871295 // that was created...
12881296 lookup (
1289- address || ( type === AF_INET6 ? '::' : '0.0.0.0' ) ,
1297+ addressOrLocalhost ( address , type ) ,
12901298 connectAfterLookup . bind ( session , type ) ) ;
12911299 }
12921300
0 commit comments