diff --git a/.github/workflows/test-shared.yml b/.github/workflows/test-shared.yml index 310640538414ab..f7f2c4c0e074c7 100644 --- a/.github/workflows/test-shared.yml +++ b/.github/workflows/test-shared.yml @@ -198,7 +198,7 @@ jobs: --arg ccache '(import {}).sccache' \ --arg devTools '[]' \ --arg benchmarkTools '[]' \ - ${{ endsWith(matrix.system, '-darwin') && '--arg withAmaro false --arg withSQLite false --arg extraConfigFlags ''["--without-inspector" "--without-node-options"]'' \' || '\' }} + ${{ endsWith(matrix.system, '-darwin') && '--arg withAmaro false --arg withQuic true --arg withSQLite false --arg extraConfigFlags ''["--without-inspector" "--without-node-options"]'' \' || '\' }} --run ' make -C "$TAR_DIR" run-ci -j4 V=1 TEST_CI_ARGS="-p actions --measure-flakiness 9 --skip-tests=$CI_SKIP_TESTS" ' diff --git a/configure.py b/configure.py index 4c38b55a9f9929..6c089f6e625797 100755 --- a/configure.py +++ b/configure.py @@ -970,6 +970,12 @@ default=None, help='build without SQLite (disables SQLite and Web Storage API)') +parser.add_argument('--experimental-quic', + action='store_true', + dest='experimental_quic', + default=None, + help='build with experimental QUIC support') + parser.add_argument('--ninja', action='store_true', dest='use_ninja', @@ -2035,6 +2041,10 @@ def without_sqlite_error(option): configure_library('sqlite', o, pkgname='sqlite3') +def configure_quic(o): + o['variables']['node_use_quic'] = b(options.experimental_quic and + not options.without_ssl) + def configure_static(o): if options.fully_static or options.partly_static: if flavor == 'mac': @@ -2487,6 +2497,7 @@ def make_bin_override(): configure_library('zstd', output, pkgname='libzstd') configure_v8(output, configurations) configure_openssl(output) +configure_quic(output) configure_intl(output) configure_static(output) configure_inspector(output) diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js index 20f1e04c47c843..2fafdb92a78e04 100644 --- a/lib/internal/bootstrap/node.js +++ b/lib/internal/bootstrap/node.js @@ -288,7 +288,8 @@ const features = { get quic() { // TODO(@jasnell): When the implementation is updated to support Boring, // then this should be refactored to depend not only on the OpenSSL version. - return !openSSLIsBoringSSL && + return process.config.variables.node_use_quic && + !openSSLIsBoringSSL && getOptionValue('--experimental-quic') && process.config.variables.openssl_version >= 810549279; // >= 3.5.1 }, diff --git a/node.gyp b/node.gyp index 6dfe2257b80e54..55adfc7bb15a93 100644 --- a/node.gyp +++ b/node.gyp @@ -32,6 +32,7 @@ 'node_use_bundled_v8%': 'true', 'node_use_node_snapshot%': 'false', 'node_use_openssl%': 'true', + 'node_use_quic%': 'false', 'node_use_sqlite%': 'true', 'node_use_v8_platform%': 'true', 'node_v8_options%': '', @@ -190,22 +191,6 @@ 'src/udp_wrap.cc', 'src/util.cc', 'src/uv.cc', - 'src/quic/bindingdata.cc', - 'src/quic/cid.cc', - 'src/quic/data.cc', - 'src/quic/logstream.cc', - 'src/quic/packet.cc', - 'src/quic/preferredaddress.cc', - 'src/quic/sessionticket.cc', - 'src/quic/tokens.cc', - 'src/quic/application.cc', - 'src/quic/endpoint.cc', - 'src/quic/http3.cc', - 'src/quic/session.cc', - 'src/quic/streams.cc', - 'src/quic/tlscontext.cc', - 'src/quic/transportparams.cc', - 'src/quic/quic.cc', # headers to make for a more pleasant IDE experience 'src/aliased_buffer.h', 'src/aliased_buffer-inl.h', @@ -343,6 +328,24 @@ 'src/udp_wrap.h', 'src/util.h', 'src/util-inl.h', + ], + 'node_quic_sources': [ + 'src/quic/bindingdata.cc', + 'src/quic/cid.cc', + 'src/quic/data.cc', + 'src/quic/logstream.cc', + 'src/quic/packet.cc', + 'src/quic/preferredaddress.cc', + 'src/quic/sessionticket.cc', + 'src/quic/tokens.cc', + 'src/quic/application.cc', + 'src/quic/endpoint.cc', + 'src/quic/http3.cc', + 'src/quic/session.cc', + 'src/quic/streams.cc', + 'src/quic/tlscontext.cc', + 'src/quic/transportparams.cc', + 'src/quic/quic.cc', 'src/quic/bindingdata.h', 'src/quic/cid.h', 'src/quic/data.h', @@ -425,6 +428,8 @@ 'test/cctest/test_crypto_clienthello.cc', 'test/cctest/test_node_crypto.cc', 'test/cctest/test_node_crypto_env.cc', + ], + 'node_cctest_quic_sources': [ 'test/cctest/test_quic_cid.cc', 'test/cctest/test_quic_error.cc', 'test/cctest/test_quic_preferredaddress.cc', @@ -998,6 +1003,11 @@ '<@(node_sqlite_sources)', ], }], + [ 'node_use_quic=="true"', { + 'sources': [ + '<@(node_quic_sources)', + ], + }], [ 'OS in "linux freebsd mac solaris openharmony" and ' 'target_arch=="x64" and ' 'node_target_type=="executable"', { @@ -1292,6 +1302,13 @@ }, { 'sources!': [ '<@(node_cctest_openssl_sources)' ], }], + [ 'node_use_quic=="true"', { + 'defines': [ + 'HAVE_QUIC=1', + ], + }, { + 'sources!': [ '<@(node_cctest_quic_sources)' ], + }], ['v8_enable_inspector==1', { 'defines': [ 'HAVE_INSPECTOR=1', diff --git a/node.gypi b/node.gypi index 8aded9e48c6141..32889a9c774353 100644 --- a/node.gypi +++ b/node.gypi @@ -385,13 +385,9 @@ 'defines': [ 'OPENSSL_API_COMPAT=0x10100000L', ], 'dependencies': [ './deps/openssl/openssl.gyp:openssl', - './deps/ngtcp2/ngtcp2.gyp:ngtcp2', - './deps/ngtcp2/ngtcp2.gyp:nghttp3', # For tests './deps/openssl/openssl.gyp:openssl-cli', - './deps/ngtcp2/ngtcp2.gyp:ngtcp2_test_server', - './deps/ngtcp2/ngtcp2.gyp:ngtcp2_test_client', ], 'conditions': [ # -force_load or --whole-archive are not applicable for @@ -443,5 +439,22 @@ }, { 'defines': [ 'HAVE_SQLITE=0' ] }], + [ 'node_use_quic=="true"', { + 'defines': [ 'HAVE_QUIC=1' ], + 'conditions': [ + [ 'node_shared_openssl=="false"', { + 'dependencies': [ + './deps/ngtcp2/ngtcp2.gyp:ngtcp2', + './deps/ngtcp2/ngtcp2.gyp:nghttp3', + + # For tests + './deps/ngtcp2/ngtcp2.gyp:ngtcp2_test_server', + './deps/ngtcp2/ngtcp2.gyp:ngtcp2_test_client', + ], + }], + ], + }, { + 'defines': [ 'HAVE_QUIC=0' ] + }], ], } diff --git a/shell.nix b/shell.nix index cae2418ca20f4d..7bf418d784d2a3 100644 --- a/shell.nix +++ b/shell.nix @@ -13,12 +13,14 @@ # Build options icu ? pkgs.icu, withAmaro ? true, + withQuic ? false, withSQLite ? true, withSSL ? true, withTemporal ? false, sharedLibDeps ? import ./tools/nix/sharedLibDeps.nix { inherit pkgs + withQuic withSQLite withSSL withTemporal @@ -81,6 +83,7 @@ pkgs.mkShell { ] ++ extraConfigFlags ++ pkgs.lib.optional (!withAmaro) "--without-amaro" + ++ pkgs.lib.optional withQuic "--experimental-quic" ++ pkgs.lib.optional (!withSQLite) "--without-sqlite" ++ pkgs.lib.optional (!withSSL) "--without-ssl" ++ pkgs.lib.optional withTemporal "--v8-enable-temporal-support" diff --git a/src/quic/application.cc b/src/quic/application.cc index de8995fe578f0b..36f11fb9131464 100644 --- a/src/quic/application.cc +++ b/src/quic/application.cc @@ -1,4 +1,4 @@ -#if HAVE_OPENSSL +#if HAVE_OPENSSL && HAVE_QUIC #include "guard.h" #ifndef OPENSSL_NO_QUIC #include "application.h" @@ -639,4 +639,4 @@ std::unique_ptr Session::SelectApplication( } // namespace node #endif // OPENSSL_NO_QUIC -#endif // HAVE_OPENSSL +#endif // HAVE_OPENSSL && HAVE_QUIC diff --git a/src/quic/bindingdata.cc b/src/quic/bindingdata.cc index 143b9005e44464..ba5c945e40525e 100644 --- a/src/quic/bindingdata.cc +++ b/src/quic/bindingdata.cc @@ -1,4 +1,4 @@ -#if HAVE_OPENSSL +#if HAVE_OPENSSL && HAVE_QUIC #include "guard.h" #ifndef OPENSSL_NO_QUIC #include "bindingdata.h" @@ -224,4 +224,4 @@ JS_METHOD_IMPL(IllegalConstructor) { } // namespace node #endif // OPENSSL_NO_QUIC -#endif // HAVE_OPENSSL +#endif // HAVE_OPENSSL && HAVE_QUIC diff --git a/src/quic/cid.cc b/src/quic/cid.cc index 2f72d24c892f43..7255bf2f39adf3 100644 --- a/src/quic/cid.cc +++ b/src/quic/cid.cc @@ -1,4 +1,4 @@ -#if HAVE_OPENSSL +#if HAVE_OPENSSL && HAVE_QUIC #include "guard.h" #ifndef OPENSSL_NO_QUIC #include @@ -151,4 +151,4 @@ const CID::Factory& CID::Factory::random() { } // namespace node::quic #endif // OPENSSL_NO_QUIC -#endif // HAVE_OPENSS +#endif // HAVE_OPENSSL && HAVE_QUIC diff --git a/src/quic/data.cc b/src/quic/data.cc index 90e97aa8d0d09f..438640d9407ee4 100644 --- a/src/quic/data.cc +++ b/src/quic/data.cc @@ -1,4 +1,4 @@ -#if HAVE_OPENSSL +#if HAVE_OPENSSL && HAVE_QUIC #include "guard.h" #ifndef OPENSSL_NO_QUIC #include "data.h" @@ -394,4 +394,4 @@ const QuicError QuicError::INTERNAL_ERROR = ForNgtcp2Error(NGTCP2_ERR_INTERNAL); } // namespace node #endif // OPENSSL_NO_QUIC -#endif // HAVE_OPENSSL +#endif // HAVE_OPENSSL && HAVE_QUIC diff --git a/src/quic/endpoint.cc b/src/quic/endpoint.cc index 1edbfe8f32cc37..a861f9716b8f00 100644 --- a/src/quic/endpoint.cc +++ b/src/quic/endpoint.cc @@ -1,4 +1,4 @@ -#if HAVE_OPENSSL +#if HAVE_OPENSSL && HAVE_QUIC #include "guard.h" #ifndef OPENSSL_NO_QUIC #include "endpoint.h" @@ -1740,4 +1740,4 @@ JS_METHOD_IMPL(Endpoint::Ref) { } // namespace quic } // namespace node #endif // OPENSSL_NO_QUIC -#endif // HAVE_OPENSSL +#endif // HAVE_OPENSSL && HAVE_QUIC diff --git a/src/quic/http3.cc b/src/quic/http3.cc index 57678f94ef4cd3..b3244fdad365be 100644 --- a/src/quic/http3.cc +++ b/src/quic/http3.cc @@ -1,4 +1,4 @@ -#if HAVE_OPENSSL +#if HAVE_OPENSSL && HAVE_QUIC #include "guard.h" #ifndef OPENSSL_NO_QUIC #include "http3.h" @@ -996,4 +996,4 @@ std::unique_ptr Http3Application::Create( } // namespace quic } // namespace node #endif // OPENSSL_NO_QUIC -#endif // HAVE_OPENSSL +#endif // HAVE_OPENSSL && HAVE_QUIC diff --git a/src/quic/logstream.cc b/src/quic/logstream.cc index 952d769b6222c6..4705d75bdafac0 100644 --- a/src/quic/logstream.cc +++ b/src/quic/logstream.cc @@ -1,4 +1,4 @@ -#if HAVE_OPENSSL +#if HAVE_OPENSSL && HAVE_QUIC #include "guard.h" #ifndef OPENSSL_NO_QUIC #include "logstream.h" @@ -137,4 +137,4 @@ void LogStream::ensure_space(size_t amt) { } // namespace node #endif // OPENSSL_NO_QUIC -#endif // HAVE_OPENSSL +#endif // HAVE_OPENSSL && HAVE_QUIC diff --git a/src/quic/packet.cc b/src/quic/packet.cc index ab9a43817c2682..cb563f681aa4b7 100644 --- a/src/quic/packet.cc +++ b/src/quic/packet.cc @@ -1,4 +1,4 @@ -#if HAVE_OPENSSL +#if HAVE_OPENSSL && HAVE_QUIC #include "guard.h" #ifndef OPENSSL_NO_QUIC #include "packet.h" @@ -405,4 +405,4 @@ BaseObjectPtr Packet::CreateVersionNegotiationPacket( } // namespace node #endif // OPENSSL_NO_QUIC -#endif // HAVE_OPENSSL +#endif // HAVE_OPENSSL && HAVE_QUIC diff --git a/src/quic/preferredaddress.cc b/src/quic/preferredaddress.cc index daea15ab2a8f86..b45e4689a21c81 100644 --- a/src/quic/preferredaddress.cc +++ b/src/quic/preferredaddress.cc @@ -1,4 +1,4 @@ -#if HAVE_OPENSSL +#if HAVE_OPENSSL && HAVE_QUIC #include "guard.h" #ifndef OPENSSL_NO_QUIC #include @@ -156,4 +156,4 @@ const CID PreferredAddress::cid() const { } // namespace node #endif // OPENSSL_NO_QUIC -#endif // HAVE_OPENSSL +#endif // HAVE_OPENSSL && HAVE_QUIC diff --git a/src/quic/quic.cc b/src/quic/quic.cc index edfb5dc9e66295..e36879e4e7d36b 100644 --- a/src/quic/quic.cc +++ b/src/quic/quic.cc @@ -1,4 +1,4 @@ -#if HAVE_OPENSSL +#if HAVE_OPENSSL && HAVE_QUIC #include "guard.h" #ifndef OPENSSL_NO_QUIC @@ -56,4 +56,4 @@ NODE_BINDING_PER_ISOLATE_INIT(quic, node::quic::CreatePerIsolateProperties) NODE_BINDING_EXTERNAL_REFERENCE(quic, node::quic::RegisterExternalReferences) #endif // OPENSSL_NO_QUIC -#endif // HAVE_OPENSSL +#endif // HAVE_OPENSSL && HAVE_QUIC diff --git a/src/quic/session.cc b/src/quic/session.cc index 882fd9bac0e54f..39ffad3e09faa8 100644 --- a/src/quic/session.cc +++ b/src/quic/session.cc @@ -1,4 +1,4 @@ -#if HAVE_OPENSSL +#if HAVE_OPENSSL && HAVE_QUIC #include "guard.h" #ifndef OPENSSL_NO_QUIC #include "session.h" @@ -2876,4 +2876,4 @@ void Session::InitPerContext(Realm* realm, Local target) { } // namespace node #endif // OPENSSL_NO_QUIC -#endif // HAVE_OPENSSL +#endif // HAVE_OPENSSL && HAVE_QUIC diff --git a/src/quic/sessionticket.cc b/src/quic/sessionticket.cc index cf78f18dffc4de..8956b44068e2ee 100644 --- a/src/quic/sessionticket.cc +++ b/src/quic/sessionticket.cc @@ -1,4 +1,4 @@ -#if HAVE_OPENSSL +#if HAVE_OPENSSL && HAVE_QUIC #include "guard.h" #ifndef OPENSSL_NO_QUIC #include "sessionticket.h" @@ -182,4 +182,4 @@ SessionTicket::AppData::Status SessionTicket::AppData::Extract(SSL* ssl) { } // namespace node #endif // OPENSSL_NO_QUIC -#endif // HAVE_OPENSSL +#endif // HAVE_OPENSSL && HAVE_QUIC diff --git a/src/quic/streams.cc b/src/quic/streams.cc index 8fe5b72ce1fe5b..f84bf4252e4877 100644 --- a/src/quic/streams.cc +++ b/src/quic/streams.cc @@ -1,4 +1,4 @@ -#if HAVE_OPENSSL +#if HAVE_OPENSSL && HAVE_QUIC #include "guard.h" #ifndef OPENSSL_NO_QUIC #include "streams.h" @@ -1322,4 +1322,4 @@ void Stream::Unschedule() { } // namespace node #endif // OPENSSL_NO_QUIC -#endif // HAVE_OPENSSL +#endif // HAVE_OPENSSL && HAVE_QUIC diff --git a/src/quic/tlscontext.cc b/src/quic/tlscontext.cc index 7e7c286b135893..3fbf88269b7365 100644 --- a/src/quic/tlscontext.cc +++ b/src/quic/tlscontext.cc @@ -1,4 +1,4 @@ -#if HAVE_OPENSSL +#if HAVE_OPENSSL && HAVE_QUIC #include "guard.h" #ifndef OPENSSL_NO_QUIC #include @@ -834,4 +834,4 @@ void TLSSession::MemoryInfo(MemoryTracker* tracker) const { } // namespace quic } // namespace node #endif // OPENSSL_NO_QUIC -#endif // HAVE_OPENSSL +#endif // HAVE_OPENSSL && HAVE_QUIC diff --git a/src/quic/tokens.cc b/src/quic/tokens.cc index a2653ab746e09f..962e321786fe08 100644 --- a/src/quic/tokens.cc +++ b/src/quic/tokens.cc @@ -1,4 +1,4 @@ -#if HAVE_OPENSSL +#if HAVE_OPENSSL && HAVE_QUIC #include "guard.h" #ifndef OPENSSL_NO_QUIC #include "tokens.h" @@ -303,4 +303,4 @@ RegularToken::operator const char*() const { } // namespace node::quic #endif // OPENSSL_NO_QUIC -#endif // HAVE_OPENSSL +#endif // HAVE_OPENSSL && HAVE_QUIC diff --git a/src/quic/transportparams.cc b/src/quic/transportparams.cc index f46e0dbcd7739d..40460e86ca1ed1 100644 --- a/src/quic/transportparams.cc +++ b/src/quic/transportparams.cc @@ -1,4 +1,4 @@ -#if HAVE_OPENSSL +#if HAVE_OPENSSL && HAVE_QUIC #include "guard.h" #ifndef OPENSSL_NO_QUIC #include "transportparams.h" @@ -304,4 +304,4 @@ void TransportParams::Initialize(Environment* env, Local target) { } // namespace node #endif // OPENSSL_NO_QUIC -#endif // HAVE_OPENSSL +#endif // HAVE_OPENSSL && HAVE_QUIC diff --git a/test/cctest/test_quic_cid.cc b/test/cctest/test_quic_cid.cc index 50be7d0fb5348c..8513a25db9dfb2 100644 --- a/test/cctest/test_quic_cid.cc +++ b/test/cctest/test_quic_cid.cc @@ -1,4 +1,4 @@ -#if HAVE_OPENSSL +#if HAVE_OPENSSL && HAVE_QUIC #include "quic/guard.h" #ifndef OPENSSL_NO_QUIC #include @@ -117,4 +117,4 @@ TEST(CID, Basic) { } } #endif // OPENSSL_NO_QUIC -#endif // HAVE_OPENSSL +#endif // HAVE_OPENSSL && HAVE_QUIC diff --git a/test/cctest/test_quic_error.cc b/test/cctest/test_quic_error.cc index 70c18db54fcc93..6c7e394ea5e0a7 100644 --- a/test/cctest/test_quic_error.cc +++ b/test/cctest/test_quic_error.cc @@ -1,4 +1,4 @@ -#if HAVE_OPENSSL +#if HAVE_OPENSSL && HAVE_QUIC #include "quic/guard.h" #ifndef OPENSSL_NO_QUIC #include @@ -126,4 +126,4 @@ TEST(QuicError, TlsAlert) { } #endif // OPENSSL_NO_QUIC -#endif // HAVE_OPENSSL +#endif // HAVE_OPENSSL && HAVE_QUIC diff --git a/test/cctest/test_quic_preferredaddress.cc b/test/cctest/test_quic_preferredaddress.cc index e691f95ff0634f..0b7abc423f5abd 100644 --- a/test/cctest/test_quic_preferredaddress.cc +++ b/test/cctest/test_quic_preferredaddress.cc @@ -1,4 +1,4 @@ -#if HAVE_OPENSSL +#if HAVE_OPENSSL && HAVE_QUIC #include "quic/guard.h" #ifndef OPENSSL_NO_QUIC #include @@ -81,4 +81,4 @@ TEST(PreferredAddress, SetTransportParams) { CHECK_EQ(ipv4_2.address, "123.123.123.123"); } #endif // OPENSSL_NO_QUIC -#endif // HAVE_OPENSSL +#endif // HAVE_OPENSSL && HAVE_QUIC diff --git a/test/cctest/test_quic_tokens.cc b/test/cctest/test_quic_tokens.cc index 53e4d96599c3c7..1003b1a0e8005f 100644 --- a/test/cctest/test_quic_tokens.cc +++ b/test/cctest/test_quic_tokens.cc @@ -1,4 +1,4 @@ -#if HAVE_OPENSSL +#if HAVE_OPENSSL && HAVE_QUIC #include "quic/guard.h" #ifndef OPENSSL_NO_QUIC #include @@ -169,4 +169,4 @@ TEST(RegularToken, Basic) { CHECK(!token.Validate(NGTCP2_PROTO_VER_MAX, address, secret, 10000000000)); } #endif // OPENSSL_NO_QUIC -#endif // HAVE_OPENSSL +#endif // HAVE_OPENSSL && HAVE_QUIC diff --git a/tools/nix/sharedLibDeps.nix b/tools/nix/sharedLibDeps.nix index d6b6a907178522..d0b88f9c2e6072 100644 --- a/tools/nix/sharedLibDeps.nix +++ b/tools/nix/sharedLibDeps.nix @@ -1,5 +1,6 @@ { pkgs ? import ./pkgs.nix { }, + withQuic ? false, withSQLite ? true, withSSL ? true, withTemporal ? false, @@ -12,8 +13,6 @@ gtest libuv nbytes - nghttp3 - ngtcp2 simdjson simdutf uvwasi @@ -33,6 +32,12 @@ ]; }; } +// (pkgs.lib.optionalAttrs withQuic { + inherit (pkgs) + nghttp3 + ngtcp2 + ; +}) // (pkgs.lib.optionalAttrs withSQLite { inherit (pkgs) sqlite; })