@@ -2079,21 +2079,13 @@ class QuicEndpoint {
20792079 */
20802080function processEndpointOption ( endpoint ) {
20812081 if ( endpoint === undefined ) {
2082- return {
2083- endpoint : new QuicEndpoint ( ) ,
2084- created : true ,
2085- } ;
2082+ // No endpoint or endpoint options were given. Create a default.
2083+ return new QuicEndpoint ( ) ;
20862084 } else if ( endpoint instanceof QuicEndpoint ) {
2087- return {
2088- endpoint,
2089- created : false ,
2090- } ;
2085+ // We were given an existing endpoint. Use it as-is.
2086+ return endpoint ;
20912087 }
2092- validateObject ( endpoint , 'options.endpoint' ) ;
2093- return {
2094- endpoint : new QuicEndpoint ( endpoint ) ,
2095- created : true ,
2096- } ;
2088+ return new QuicEndpoint ( endpoint ) ;
20972089}
20982090
20992091/**
@@ -2226,10 +2218,10 @@ function getPreferredAddressPolicy(policy = 'default') {
22262218
22272219/**
22282220 * @param {SessionOptions } options
2229- * @param {boolean } [forServer ]
2221+ * @param {{forServer: boolean, addressFamily: string} } [config ]
22302222 * @returns {SessionOptions }
22312223 */
2232- function processSessionOptions ( options , forServer = false ) {
2224+ function processSessionOptions ( options , config = { } ) {
22332225 validateObject ( options , 'options' ) ;
22342226 const {
22352227 endpoint,
@@ -2248,6 +2240,10 @@ function processSessionOptions(options, forServer = false) {
22482240 [ kApplicationProvider ] : provider ,
22492241 } = options ;
22502242
2243+ const {
2244+ forServer = false ,
2245+ } = config ;
2246+
22512247 if ( provider !== undefined ) {
22522248 validateObject ( provider , 'options[kApplicationProvider]' ) ;
22532249 }
@@ -2256,15 +2252,11 @@ function processSessionOptions(options, forServer = false) {
22562252 validateOneOf ( cc , 'options.cc' , [ CC_ALGO_RENO , CC_ALGO_BBR , CC_ALGO_CUBIC ] ) ;
22572253 }
22582254
2259- const {
2260- endpoint : actualEndpoint ,
2261- created : endpointCreated ,
2262- } = processEndpointOption ( endpoint ) ;
2255+ const actualEndpoint = processEndpointOption ( endpoint ) ;
22632256
22642257 return {
22652258 __proto__ : null ,
22662259 endpoint : actualEndpoint ,
2267- endpointCreated,
22682260 version,
22692261 minVersion,
22702262 preferredAddressPolicy : getPreferredAddressPolicy ( preferredAddressPolicy ) ,
@@ -2294,7 +2286,7 @@ async function listen(callback, options = kEmptyObject) {
22942286 const {
22952287 endpoint,
22962288 ...sessionOptions
2297- } = processSessionOptions ( options , true /* for server */ ) ;
2289+ } = processSessionOptions ( options , { forServer : true } ) ;
22982290 endpoint [ kListen ] ( callback , sessionOptions ) ;
22992291
23002292 if ( onEndpointListeningChannel . hasSubscribers ) {
0 commit comments