@@ -33,7 +33,6 @@ let debug = require('internal/util/debuglog').debuglog('quic', (fn) => {
3333
3434const {
3535 Endpoint : Endpoint_ ,
36- Http3Application : Http3 ,
3736 setCallbacks,
3837
3938 // The constants to be exposed to end users for various options.
@@ -118,7 +117,6 @@ const {
118117const kEmptyObject = { __proto__ : null } ;
119118
120119const {
121- kApplicationProvider,
122120 kBlocked,
123121 kConnect,
124122 kDatagram,
@@ -2222,7 +2220,7 @@ function processIdentityOptions(identity, label) {
22222220function processTlsOptions ( tls , forServer ) {
22232221 const {
22242222 servername,
2225- protocol ,
2223+ alpn ,
22262224 ciphers = DEFAULT_CIPHERS ,
22272225 groups = DEFAULT_GROUPS ,
22282226 keylog = false ,
@@ -2240,9 +2238,6 @@ function processTlsOptions(tls, forServer) {
22402238 if ( servername !== undefined ) {
22412239 validateString ( servername , 'options.servername' ) ;
22422240 }
2243- if ( protocol !== undefined ) {
2244- validateString ( protocol , 'options.protocol' ) ;
2245- }
22462241 if ( ciphers !== undefined ) {
22472242 validateString ( ciphers , 'options.ciphers' ) ;
22482243 }
@@ -2253,11 +2248,42 @@ function processTlsOptions(tls, forServer) {
22532248 validateBoolean ( verifyClient , 'options.verifyClient' ) ;
22542249 validateBoolean ( tlsTrace , 'options.tlsTrace' ) ;
22552250
2251+ // Encode the ALPN option to wire format (length-prefixed protocol names).
2252+ // Server: array of protocol names. Client: single protocol name.
2253+ // If not specified, the C++ default (h3) is used.
2254+ let encodedAlpn ;
2255+ if ( alpn !== undefined ) {
2256+ const protocols = forServer ?
2257+ ( ArrayIsArray ( alpn ) ? alpn : [ alpn ] ) :
2258+ [ alpn ] ;
2259+ if ( ! forServer ) {
2260+ validateString ( alpn , 'options.alpn' ) ;
2261+ }
2262+ let totalLen = 0 ;
2263+ for ( let i = 0 ; i < protocols . length ; i ++ ) {
2264+ validateString ( protocols [ i ] , `options.alpn[${ i } ]` ) ;
2265+ if ( protocols [ i ] . length === 0 || protocols [ i ] . length > 255 ) {
2266+ throw new ERR_INVALID_ARG_VALUE ( `options.alpn[${ i } ]` , protocols [ i ] ,
2267+ 'must be between 1 and 255 characters' ) ;
2268+ }
2269+ totalLen += 1 + protocols [ i ] . length ;
2270+ }
2271+ // Build wire format: [len1][name1][len2][name2]...
2272+ const buf = Buffer . allocUnsafe ( totalLen ) ;
2273+ let offset = 0 ;
2274+ for ( let i = 0 ; i < protocols . length ; i ++ ) {
2275+ buf [ offset ++ ] = protocols [ i ] . length ;
2276+ buf . write ( protocols [ i ] , offset , 'ascii' ) ;
2277+ offset += protocols [ i ] . length ;
2278+ }
2279+ encodedAlpn = buf . toString ( 'latin1' ) ;
2280+ }
2281+
22562282 // Shared TLS options (same for all identities on the endpoint).
22572283 const shared = {
22582284 __proto__ : null ,
22592285 servername,
2260- protocol ,
2286+ alpn : encodedAlpn ,
22612287 ciphers,
22622288 groups,
22632289 keylog,
@@ -2360,17 +2386,12 @@ function processSessionOptions(options, config = {}) {
23602386 maxStreamWindow,
23612387 maxWindow,
23622388 cc,
2363- [ kApplicationProvider ] : provider ,
23642389 } = options ;
23652390
23662391 const {
23672392 forServer = false ,
23682393 } = config ;
23692394
2370- if ( provider !== undefined ) {
2371- validateObject ( provider , 'options[kApplicationProvider]' ) ;
2372- }
2373-
23742395 if ( cc !== undefined ) {
23752396 validateOneOf ( cc , 'options.cc' , [ CC_ALGO_RENO , CC_ALGO_BBR , CC_ALGO_CUBIC ] ) ;
23762397 }
@@ -2392,7 +2413,6 @@ function processSessionOptions(options, config = {}) {
23922413 maxStreamWindow,
23932414 maxWindow,
23942415 sessionTicket,
2395- provider,
23962416 cc,
23972417 } ;
23982418}
@@ -2494,7 +2514,6 @@ module.exports = {
24942514 QuicEndpoint,
24952515 QuicSession,
24962516 QuicStream,
2497- Http3,
24982517 CC_ALGO_RENO ,
24992518 CC_ALGO_CUBIC ,
25002519 CC_ALGO_BBR ,
0 commit comments