@@ -581,6 +581,14 @@ function getStats(obj, idx) {
581
581
return stats [ idx ] ;
582
582
}
583
583
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
+
584
592
// QuicEndpoint wraps a UDP socket and is owned
585
593
// by a QuicSocket. It does not exist independently
586
594
// of the QuicSocket.
@@ -610,9 +618,9 @@ class QuicEndpoint {
610
618
} = validateQuicEndpointOptions ( options ) ;
611
619
const state = this [ kInternalState ] ;
612
620
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 ) ;
614
623
state . ipv6Only = ipv6Only ;
615
- state . lookup = lookup || ( type === AF_INET6 ? lookup6 : lookup4 ) ;
616
624
state . port = port ;
617
625
state . reuseAddr = reuseAddr ;
618
626
state . type = type ;
@@ -901,8 +909,8 @@ class QuicSocket extends EventEmitter {
901
909
const state = this [ kInternalState ] ;
902
910
903
911
state . client = client ;
904
- state . lookup = lookup || ( type === AF_INET6 ? lookup6 : lookup4 ) ;
905
912
state . server = server ;
913
+ state . lookup = lookupOrDefault ( lookup , type ) ;
906
914
907
915
let socketOptions = 0 ;
908
916
if ( validateAddress )
@@ -1286,7 +1294,7 @@ class QuicSocket extends EventEmitter {
1286
1294
// Notice here that connectAfterLookup is bound to the QuicSession
1287
1295
// that was created...
1288
1296
lookup (
1289
- address || ( type === AF_INET6 ? '::' : '0.0.0.0' ) ,
1297
+ addressOrLocalhost ( address , type ) ,
1290
1298
connectAfterLookup . bind ( session , type ) ) ;
1291
1299
}
1292
1300
0 commit comments