@@ -2079,21 +2079,13 @@ class QuicEndpoint {
2079
2079
*/
2080
2080
function processEndpointOption ( endpoint ) {
2081
2081
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 ( ) ;
2086
2084
} 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 ;
2091
2087
}
2092
- validateObject ( endpoint , 'options.endpoint' ) ;
2093
- return {
2094
- endpoint : new QuicEndpoint ( endpoint ) ,
2095
- created : true ,
2096
- } ;
2088
+ return new QuicEndpoint ( endpoint ) ;
2097
2089
}
2098
2090
2099
2091
/**
@@ -2226,10 +2218,10 @@ function getPreferredAddressPolicy(policy = 'default') {
2226
2218
2227
2219
/**
2228
2220
* @param {SessionOptions } options
2229
- * @param {boolean } [forServer ]
2221
+ * @param {{forServer: boolean, addressFamily: string} } [config ]
2230
2222
* @returns {SessionOptions }
2231
2223
*/
2232
- function processSessionOptions ( options , forServer = false ) {
2224
+ function processSessionOptions ( options , config = { } ) {
2233
2225
validateObject ( options , 'options' ) ;
2234
2226
const {
2235
2227
endpoint,
@@ -2248,6 +2240,10 @@ function processSessionOptions(options, forServer = false) {
2248
2240
[ kApplicationProvider ] : provider ,
2249
2241
} = options ;
2250
2242
2243
+ const {
2244
+ forServer = false ,
2245
+ } = config ;
2246
+
2251
2247
if ( provider !== undefined ) {
2252
2248
validateObject ( provider , 'options[kApplicationProvider]' ) ;
2253
2249
}
@@ -2256,15 +2252,11 @@ function processSessionOptions(options, forServer = false) {
2256
2252
validateOneOf ( cc , 'options.cc' , [ CC_ALGO_RENO , CC_ALGO_BBR , CC_ALGO_CUBIC ] ) ;
2257
2253
}
2258
2254
2259
- const {
2260
- endpoint : actualEndpoint ,
2261
- created : endpointCreated ,
2262
- } = processEndpointOption ( endpoint ) ;
2255
+ const actualEndpoint = processEndpointOption ( endpoint ) ;
2263
2256
2264
2257
return {
2265
2258
__proto__ : null ,
2266
2259
endpoint : actualEndpoint ,
2267
- endpointCreated,
2268
2260
version,
2269
2261
minVersion,
2270
2262
preferredAddressPolicy : getPreferredAddressPolicy ( preferredAddressPolicy ) ,
@@ -2294,7 +2286,7 @@ async function listen(callback, options = kEmptyObject) {
2294
2286
const {
2295
2287
endpoint,
2296
2288
...sessionOptions
2297
- } = processSessionOptions ( options , true /* for server */ ) ;
2289
+ } = processSessionOptions ( options , { forServer : true } ) ;
2298
2290
endpoint [ kListen ] ( callback , sessionOptions ) ;
2299
2291
2300
2292
if ( onEndpointListeningChannel . hasSubscribers ) {
0 commit comments