From 546797f2b1f5b2a95c05a34fb007bd06c201df8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Wed, 28 Jun 2023 13:52:45 +0200 Subject: [PATCH 01/34] quic: prevent copying ngtcp2_cid The existing code explicitly uses the CID(const ngtcp2_cid*) constructor that does not copy the given ngtcp2_cid, but the range-based for loop still unnecessarily copies the ngtcp2_cid. Use auto& to avoid copying. PR-URL: https://github.com/nodejs/node/pull/48561 Reviewed-By: Luigi Pinca Reviewed-By: Mohammed Keyvanzadeh --- src/quic/session.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/quic/session.cc b/src/quic/session.cc index a6204f8da1b434..87a4a8e54557f7 100644 --- a/src/quic/session.cc +++ b/src/quic/session.cc @@ -643,7 +643,7 @@ void Session::Destroy() { endpoint_->DisassociateCID(config_.dcid); endpoint_->DisassociateCID(config_.preferred_address_cid); - for (auto cid : cids) endpoint_->DisassociateCID(CID(&cid)); + for (const auto& cid : cids) endpoint_->DisassociateCID(CID(&cid)); for (const auto& token : tokens) { if (token.token_present) From affc6aca035494ff976b362bb83419640cb61493 Mon Sep 17 00:00:00 2001 From: Rafael Gonzaga Date: Wed, 28 Jun 2023 10:07:19 -0300 Subject: [PATCH 02/34] benchmark: add bar.R Signed-off-by: RafaelGSS PR-URL: https://github.com/nodejs/node/pull/47729 Reviewed-By: Yagiz Nizipli Reviewed-By: Marco Ippolito --- benchmark/bar.R | 36 +++++++++++++++++++ .../writing-and-running-benchmarks.md | 5 ++- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 benchmark/bar.R diff --git a/benchmark/bar.R b/benchmark/bar.R new file mode 100644 index 00000000000000..007727fb94fdc1 --- /dev/null +++ b/benchmark/bar.R @@ -0,0 +1,36 @@ +#!/usr/bin/env Rscript +library(ggplot2); +library(plyr); + +# get __dirname and load ./_cli.R +args = commandArgs(trailingOnly = F); +dirname = dirname(sub("--file=", "", args[grep("--file", args)])); +source(paste0(dirname, '/_cli.R'), chdir=T); + +if (!is.null(args.options$help) || + (!is.null(args.options$plot) && args.options$plot == TRUE)) { + stop("usage: cat file.csv | Rscript bar.R + --help show this message + --plot filename save plot to filename"); +} + +plot.filename = args.options$plot; + +dat = read.csv( + file('stdin'), + colClasses=c('character', 'character', 'character', 'numeric', 'numeric') +); +dat = data.frame(dat); + +dat$nameTwoLines = paste0(dat$filename, '\n', dat$configuration); +dat$name = paste0(dat$filename, ' ', dat$configuration); + +# Create a box plot +if (!is.null(plot.filename)) { + p = ggplot(data=dat, aes(x=nameTwoLines, y=rate, fill=binary)); + p = p + geom_bar(stat="summary", position=position_dodge()); + p = p + ylab("rate of operations (higher is better)"); + p = p + xlab("benchmark"); + p = p + theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5)); + ggsave(plot.filename, p); +} diff --git a/doc/contributing/writing-and-running-benchmarks.md b/doc/contributing/writing-and-running-benchmarks.md index eca74d4ba1c9a0..2c8d5eb3ed237b 100644 --- a/doc/contributing/writing-and-running-benchmarks.md +++ b/doc/contributing/writing-and-running-benchmarks.md @@ -293,7 +293,10 @@ module, you can use the `--filter` option:_ ``` For analyzing the benchmark results, use [node-benchmark-compare][] or the R -script `benchmark/compare.R`. +scripts: + +* `benchmark/compare.R` +* `benchmark/bar.R` ```console $ node-benchmark-compare compare-pr-5134.csv # or cat compare-pr-5134.csv | Rscript benchmark/compare.R From 86ba5bea9e2f387ff4a8cb01295dc1bf600e5c61 Mon Sep 17 00:00:00 2001 From: Tim Perry <1526883+pimterry@users.noreply.github.com> Date: Wed, 28 Jun 2023 15:30:30 +0100 Subject: [PATCH 03/34] tls: add ALPNCallback server option for dynamic ALPN negotiation PR-URL: https://github.com/nodejs/node/pull/45190 Reviewed-By: James M Snell Reviewed-By: Benjamin Gruenbaum Reviewed-By: Debadree Chatterjee --- doc/api/errors.md | 14 ++++ doc/api/tls.md | 14 ++++ lib/_tls_wrap.js | 59 +++++++++++++++ lib/internal/errors.js | 10 +++ src/crypto/crypto_tls.cc | 49 +++++++++++++ src/crypto/crypto_tls.h | 2 + src/env_properties.h | 1 + test/parallel/test-tls-alpn-server-client.js | 75 +++++++++++++++++++- 8 files changed, 221 insertions(+), 3 deletions(-) diff --git a/doc/api/errors.md b/doc/api/errors.md index 8a212f3c19f1bc..3e338a4e8f8cd6 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -2746,6 +2746,20 @@ This error represents a failed test. Additional information about the failure is available via the `cause` property. The `failureType` property specifies what the test was doing when the failure occurred. + + +### `ERR_TLS_ALPN_CALLBACK_INVALID_RESULT` + +This error is thrown when an `ALPNCallback` returns a value that is not in the +list of ALPN protocols offered by the client. + + + +### `ERR_TLS_ALPN_CALLBACK_WITH_PROTOCOLS` + +This error is thrown when creating a `TLSServer` if the TLS options include +both `ALPNProtocols` and `ALPNCallback`. These options are mutually exclusive. + ### `ERR_TLS_CERT_ALTNAME_FORMAT` diff --git a/doc/api/tls.md b/doc/api/tls.md index e1f0d28509ae34..71a63cabc4e4af 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -2049,6 +2049,9 @@ where `secureSocket` has the same API as `pair.cleartext`. + +> Stability: 1 - Experimental + +Calls [`server.close()`][] and returns a promise that fulfills when the +server has closed. + ## Class: `http.ServerResponse` + +> Stability: 1 - Experimental + +Calls [`server.close()`][] and returns a promise that fulfills when the +server has closed. + #### `server.setTimeout([msecs][, callback])` + +> Stability: 1 - Experimental + +Calls [`server.close()`][httpsServerClose] and returns a promise that +fulfills when the server has closed. + ### `server.closeAllConnections()`