@@ -140,8 +140,9 @@ function validateNumber(value, name,
140
140
141
141
function getSocketType ( type = 'udp4' ) {
142
142
switch ( type ) {
143
- case 'udp4' : return AF_INET ;
144
- case 'udp6' : return AF_INET6 ;
143
+ case 'udp4' : return [ AF_INET , false ] ;
144
+ case 'udp6' : return [ AF_INET6 , false ] ;
145
+ case 'udp6-only' : return [ AF_INET6 , true ] ;
145
146
}
146
147
throw new ERR_INVALID_ARG_VALUE ( 'options.type' , type ) ;
147
148
}
@@ -366,7 +367,6 @@ function validateQuicClientSessionOptions(options = {}) {
366
367
address = 'localhost' ,
367
368
alpn = '' ,
368
369
dcid : dcid_value ,
369
- ipv6Only = false ,
370
370
minDHSize = 1024 ,
371
371
port = 0 ,
372
372
preferredAddressPolicy = 'ignore' ,
@@ -434,7 +434,6 @@ function validateQuicClientSessionOptions(options = {}) {
434
434
if ( preferredAddressPolicy !== undefined )
435
435
validateString ( preferredAddressPolicy , 'options.preferredAddressPolicy' ) ;
436
436
437
- validateBoolean ( ipv6Only , 'options.ipv6Only' ) ;
438
437
validateBoolean ( requestOCSP , 'options.requestOCSP' ) ;
439
438
validateBoolean ( verifyHostnameIdentity , 'options.verifyHostnameIdentity' ) ;
440
439
validateBoolean ( qlog , 'options.qlog' ) ;
@@ -444,7 +443,6 @@ function validateQuicClientSessionOptions(options = {}) {
444
443
address,
445
444
alpn,
446
445
dcid,
447
- ipv6Only,
448
446
minDHSize,
449
447
port,
450
448
preferredAddressPolicy :
@@ -495,7 +493,6 @@ function validateQuicEndpointOptions(options = {}, name = 'options') {
495
493
throw new ERR_INVALID_ARG_TYPE ( 'options' , 'Object' , options ) ;
496
494
const {
497
495
address,
498
- ipv6Only = false ,
499
496
lookup,
500
497
port = 0 ,
501
498
reuseAddr = false ,
@@ -507,17 +504,17 @@ function validateQuicEndpointOptions(options = {}, name = 'options') {
507
504
validatePort ( port , 'options.port' ) ;
508
505
validateString ( type , 'options.type' ) ;
509
506
validateLookup ( lookup ) ;
510
- validateBoolean ( ipv6Only , 'options.ipv6Only' ) ;
511
507
validateBoolean ( reuseAddr , 'options.reuseAddr' ) ;
512
508
validateBoolean ( preferred , 'options.preferred' ) ;
509
+ const [ typeVal , ipv6Only ] = getSocketType ( type ) ;
513
510
return {
514
- address ,
511
+ type : typeVal ,
515
512
ipv6Only,
513
+ address,
516
514
lookup,
517
515
port,
518
516
preferred,
519
517
reuseAddr,
520
- type : getSocketType ( type ) ,
521
518
} ;
522
519
}
523
520
@@ -536,15 +533,13 @@ function validateQuicSocketOptions(options = {}) {
536
533
retryTokenTimeout = DEFAULT_RETRYTOKEN_EXPIRATION ,
537
534
server = { } ,
538
535
statelessResetSecret,
539
- type = endpoint . type || 'udp4' ,
540
536
validateAddressLRU = false ,
541
537
validateAddress = false ,
542
538
} = options ;
543
539
544
- validateQuicEndpointOptions ( endpoint , 'options.endpoint' ) ;
540
+ const { type } = validateQuicEndpointOptions ( endpoint , 'options.endpoint' ) ;
545
541
validateObject ( client , 'options.client' ) ;
546
542
validateObject ( server , 'options.server' ) ;
547
- validateString ( type , 'options.type' ) ;
548
543
validateLookup ( lookup ) ;
549
544
validateBoolean ( validateAddress , 'options.validateAddress' ) ;
550
545
validateBoolean ( validateAddressLRU , 'options.validateAddressLRU' ) ;
@@ -595,7 +590,7 @@ function validateQuicSocketOptions(options = {}) {
595
590
maxStatelessResetsPerHost,
596
591
retryTokenTimeout,
597
592
server,
598
- type : getSocketType ( type ) ,
593
+ type,
599
594
validateAddress : validateAddress || validateAddressLRU ,
600
595
validateAddressLRU,
601
596
qlog,
@@ -642,10 +637,8 @@ function validateQuicSocketConnectOptions(options = {}) {
642
637
} = options ;
643
638
if ( address !== undefined )
644
639
validateString ( address , 'options.address' ) ;
645
- return {
646
- type : getSocketType ( type ) ,
647
- address,
648
- } ;
640
+ const [ typeVal ] = getSocketType ( type ) ;
641
+ return { type : typeVal , address } ;
649
642
}
650
643
651
644
function validateCreateSecureContextOptions ( options = { } ) {
0 commit comments