Skip to content

Commit 853277a

Browse files
authored
quic: move quic behind compile time flag
Move node:quic behind a compile-time flag, disabled by default. Use --experimental-quic at configure time to enable. - Add --experimental-quic flag to configure.py - Add node_use_quic variable and HAVE_QUIC define - Make QUIC sources conditional in node.gyp - Move ngtcp2/nghttp3 deps under QUIC condition in node.gypi - Update C++ guards to check HAVE_QUIC - Update process.features.quic to check node_use_quic PR-URL: #61444 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Aviv Keller <me@aviv.sh> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent f254bcb commit 853277a

24 files changed

+103
-61
lines changed

configure.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,12 @@
970970
default=None,
971971
help='build without SQLite (disables SQLite and Web Storage API)')
972972

973+
parser.add_argument('--experimental-quic',
974+
action='store_true',
975+
dest='experimental_quic',
976+
default=None,
977+
help='build with experimental QUIC support')
978+
973979
parser.add_argument('--ninja',
974980
action='store_true',
975981
dest='use_ninja',
@@ -2030,6 +2036,10 @@ def without_sqlite_error(option):
20302036

20312037
configure_library('sqlite', o, pkgname='sqlite3')
20322038

2039+
def configure_quic(o):
2040+
o['variables']['node_use_quic'] = b(options.experimental_quic and
2041+
not options.without_ssl)
2042+
20332043
def configure_static(o):
20342044
if options.fully_static or options.partly_static:
20352045
if flavor == 'mac':
@@ -2482,6 +2492,7 @@ def make_bin_override():
24822492
configure_library('zstd', output, pkgname='libzstd')
24832493
configure_v8(output, configurations)
24842494
configure_openssl(output)
2495+
configure_quic(output)
24852496
configure_intl(output)
24862497
configure_static(output)
24872498
configure_inspector(output)

lib/internal/bootstrap/node.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@ const features = {
288288
get quic() {
289289
// TODO(@jasnell): When the implementation is updated to support Boring,
290290
// then this should be refactored to depend not only on the OpenSSL version.
291-
return !openSSLIsBoringSSL &&
291+
return process.config.variables.node_use_quic &&
292+
!openSSLIsBoringSSL &&
292293
getOptionValue('--experimental-quic') &&
293294
process.config.variables.openssl_version >= 810549279; // >= 3.5.1
294295
},

node.gyp

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
'node_use_bundled_v8%': 'true',
3333
'node_use_node_snapshot%': 'false',
3434
'node_use_openssl%': 'true',
35+
'node_use_quic%': 'false',
3536
'node_use_sqlite%': 'true',
3637
'node_use_v8_platform%': 'true',
3738
'node_v8_options%': '',
@@ -190,22 +191,6 @@
190191
'src/udp_wrap.cc',
191192
'src/util.cc',
192193
'src/uv.cc',
193-
'src/quic/bindingdata.cc',
194-
'src/quic/cid.cc',
195-
'src/quic/data.cc',
196-
'src/quic/logstream.cc',
197-
'src/quic/packet.cc',
198-
'src/quic/preferredaddress.cc',
199-
'src/quic/sessionticket.cc',
200-
'src/quic/tokens.cc',
201-
'src/quic/application.cc',
202-
'src/quic/endpoint.cc',
203-
'src/quic/http3.cc',
204-
'src/quic/session.cc',
205-
'src/quic/streams.cc',
206-
'src/quic/tlscontext.cc',
207-
'src/quic/transportparams.cc',
208-
'src/quic/quic.cc',
209194
# headers to make for a more pleasant IDE experience
210195
'src/aliased_buffer.h',
211196
'src/aliased_buffer-inl.h',
@@ -343,6 +328,24 @@
343328
'src/udp_wrap.h',
344329
'src/util.h',
345330
'src/util-inl.h',
331+
],
332+
'node_quic_sources': [
333+
'src/quic/bindingdata.cc',
334+
'src/quic/cid.cc',
335+
'src/quic/data.cc',
336+
'src/quic/logstream.cc',
337+
'src/quic/packet.cc',
338+
'src/quic/preferredaddress.cc',
339+
'src/quic/sessionticket.cc',
340+
'src/quic/tokens.cc',
341+
'src/quic/application.cc',
342+
'src/quic/endpoint.cc',
343+
'src/quic/http3.cc',
344+
'src/quic/session.cc',
345+
'src/quic/streams.cc',
346+
'src/quic/tlscontext.cc',
347+
'src/quic/transportparams.cc',
348+
'src/quic/quic.cc',
346349
'src/quic/bindingdata.h',
347350
'src/quic/cid.h',
348351
'src/quic/data.h',
@@ -425,6 +428,8 @@
425428
'test/cctest/test_crypto_clienthello.cc',
426429
'test/cctest/test_node_crypto.cc',
427430
'test/cctest/test_node_crypto_env.cc',
431+
],
432+
'node_cctest_quic_sources': [
428433
'test/cctest/test_quic_cid.cc',
429434
'test/cctest/test_quic_error.cc',
430435
'test/cctest/test_quic_preferredaddress.cc',
@@ -998,6 +1003,11 @@
9981003
'<@(node_sqlite_sources)',
9991004
],
10001005
}],
1006+
[ 'node_use_quic=="true"', {
1007+
'sources': [
1008+
'<@(node_quic_sources)',
1009+
],
1010+
}],
10011011
[ 'OS in "linux freebsd mac solaris openharmony" and '
10021012
'target_arch=="x64" and '
10031013
'node_target_type=="executable"', {
@@ -1292,6 +1302,13 @@
12921302
}, {
12931303
'sources!': [ '<@(node_cctest_openssl_sources)' ],
12941304
}],
1305+
[ 'node_use_quic=="true"', {
1306+
'defines': [
1307+
'HAVE_QUIC=1',
1308+
],
1309+
}, {
1310+
'sources!': [ '<@(node_cctest_quic_sources)' ],
1311+
}],
12951312
['v8_enable_inspector==1', {
12961313
'defines': [
12971314
'HAVE_INSPECTOR=1',

node.gypi

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,13 +385,9 @@
385385
'defines': [ 'OPENSSL_API_COMPAT=0x10100000L', ],
386386
'dependencies': [
387387
'./deps/openssl/openssl.gyp:openssl',
388-
'./deps/ngtcp2/ngtcp2.gyp:ngtcp2',
389-
'./deps/ngtcp2/ngtcp2.gyp:nghttp3',
390388

391389
# For tests
392390
'./deps/openssl/openssl.gyp:openssl-cli',
393-
'./deps/ngtcp2/ngtcp2.gyp:ngtcp2_test_server',
394-
'./deps/ngtcp2/ngtcp2.gyp:ngtcp2_test_client',
395391
],
396392
'conditions': [
397393
# -force_load or --whole-archive are not applicable for
@@ -443,5 +439,22 @@
443439
}, {
444440
'defines': [ 'HAVE_SQLITE=0' ]
445441
}],
442+
[ 'node_use_quic=="true"', {
443+
'defines': [ 'HAVE_QUIC=1' ],
444+
'conditions': [
445+
[ 'node_shared_openssl=="false"', {
446+
'dependencies': [
447+
'./deps/ngtcp2/ngtcp2.gyp:ngtcp2',
448+
'./deps/ngtcp2/ngtcp2.gyp:nghttp3',
449+
450+
# For tests
451+
'./deps/ngtcp2/ngtcp2.gyp:ngtcp2_test_server',
452+
'./deps/ngtcp2/ngtcp2.gyp:ngtcp2_test_client',
453+
],
454+
}],
455+
],
456+
}, {
457+
'defines': [ 'HAVE_QUIC=0' ]
458+
}],
446459
],
447460
}

src/quic/application.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if HAVE_OPENSSL
1+
#if HAVE_OPENSSL && HAVE_QUIC
22
#include "guard.h"
33
#ifndef OPENSSL_NO_QUIC
44
#include "application.h"
@@ -639,4 +639,4 @@ std::unique_ptr<Session::Application> Session::SelectApplication(
639639
} // namespace node
640640

641641
#endif // OPENSSL_NO_QUIC
642-
#endif // HAVE_OPENSSL
642+
#endif // HAVE_OPENSSL && HAVE_QUIC

src/quic/bindingdata.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if HAVE_OPENSSL
1+
#if HAVE_OPENSSL && HAVE_QUIC
22
#include "guard.h"
33
#ifndef OPENSSL_NO_QUIC
44
#include "bindingdata.h"
@@ -224,4 +224,4 @@ JS_METHOD_IMPL(IllegalConstructor) {
224224
} // namespace node
225225

226226
#endif // OPENSSL_NO_QUIC
227-
#endif // HAVE_OPENSSL
227+
#endif // HAVE_OPENSSL && HAVE_QUIC

src/quic/cid.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if HAVE_OPENSSL
1+
#if HAVE_OPENSSL && HAVE_QUIC
22
#include "guard.h"
33
#ifndef OPENSSL_NO_QUIC
44
#include <crypto/crypto_util.h>
@@ -151,4 +151,4 @@ const CID::Factory& CID::Factory::random() {
151151

152152
} // namespace node::quic
153153
#endif // OPENSSL_NO_QUIC
154-
#endif // HAVE_OPENSS
154+
#endif // HAVE_OPENSSL && HAVE_QUIC

src/quic/data.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if HAVE_OPENSSL
1+
#if HAVE_OPENSSL && HAVE_QUIC
22
#include "guard.h"
33
#ifndef OPENSSL_NO_QUIC
44
#include "data.h"
@@ -394,4 +394,4 @@ const QuicError QuicError::INTERNAL_ERROR = ForNgtcp2Error(NGTCP2_ERR_INTERNAL);
394394
} // namespace node
395395

396396
#endif // OPENSSL_NO_QUIC
397-
#endif // HAVE_OPENSSL
397+
#endif // HAVE_OPENSSL && HAVE_QUIC

src/quic/endpoint.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if HAVE_OPENSSL
1+
#if HAVE_OPENSSL && HAVE_QUIC
22
#include "guard.h"
33
#ifndef OPENSSL_NO_QUIC
44
#include "endpoint.h"
@@ -1740,4 +1740,4 @@ JS_METHOD_IMPL(Endpoint::Ref) {
17401740
} // namespace quic
17411741
} // namespace node
17421742
#endif // OPENSSL_NO_QUIC
1743-
#endif // HAVE_OPENSSL
1743+
#endif // HAVE_OPENSSL && HAVE_QUIC

src/quic/http3.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if HAVE_OPENSSL
1+
#if HAVE_OPENSSL && HAVE_QUIC
22
#include "guard.h"
33
#ifndef OPENSSL_NO_QUIC
44
#include "http3.h"
@@ -996,4 +996,4 @@ std::unique_ptr<Session::Application> Http3Application::Create(
996996
} // namespace quic
997997
} // namespace node
998998
#endif // OPENSSL_NO_QUIC
999-
#endif // HAVE_OPENSSL
999+
#endif // HAVE_OPENSSL && HAVE_QUIC

0 commit comments

Comments
 (0)