| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent abb881e commit c128942
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -516,13 +516,6 @@ class DefaultApplication final : public Session::Application { | |||
| 516 | 516 | if (!session().max_data_left()) return 0; | |
| 517 | 517 | if (stream_queue_.IsEmpty()) return 0; | |
| 518 | 518 | ||
| 519 | - const auto get_length = [](auto vec, size_t count) { | ||
| 520 | - CHECK_NOT_NULL(vec); | ||
| 521 | - size_t len = 0; | ||
| 522 | - for (size_t n = 0; n < count; n++) len += vec[n].len; | ||
| 523 | - return len; | ||
| 524 | - }; | ||
| 525 | - | ||
| 526 | 519 | Stream* stream = stream_queue_.PopFront(); | |
| 527 | 520 | CHECK_NOT_NULL(stream); | |
| 528 | 521 | stream_data->stream.reset(stream); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -92,7 +92,7 @@ bool is_diagnostic_packet_loss(double probability) { | |||
| 92 | 92 | return (static_cast<double>(c) / 255) < probability; | |
| 93 | 93 | } | |
| 94 | 94 | ||
| 95 | - template <typename Opt, double Opt::* member> | ||
| 95 | + template <typename Opt, double Opt::*member> | ||
| 96 | 96 | bool SetOption(Environment* env, | |
| 97 | 97 | Opt* options, | |
| 98 | 98 | const Local<Object>& object, | |
@@ -113,7 +113,7 @@ bool SetOption(Environment* env, | |||
| 113 | 113 | } | |
| 114 | 114 | #endif // DEBUG | |
| 115 | 115 | ||
| 116 | - template <typename Opt, uint8_t Opt::* member> | ||
| 116 | + template <typename Opt, uint8_t Opt::*member> | ||
| 117 | 117 | bool SetOption(Environment* env, | |
| 118 | 118 | Opt* options, | |
| 119 | 119 | const Local<Object>& object, | |
@@ -140,7 +140,7 @@ bool SetOption(Environment* env, | |||
| 140 | 140 | return true; | |
| 141 | 141 | } | |
| 142 | 142 | ||
| 143 | - template <typename Opt, TokenSecret Opt::* member> | ||
| 143 | + template <typename Opt, TokenSecret Opt::*member> | ||
| 144 | 144 | bool SetOption(Environment* env, | |
| 145 | 145 | Opt* options, | |
| 146 | 146 | const Local<Object>& object, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -208,7 +208,7 @@ void ngtcp2_debug_log(void* user_data, const char* fmt, ...) { | |||
| 208 | 208 | va_end(ap); | |
| 209 | 209 | } | |
| 210 | 210 | ||
| 211 | - template <typename Opt, PreferredAddress::Policy Opt::* member> | ||
| 211 | + template <typename Opt, PreferredAddress::Policy Opt::*member> | ||
| 212 | 212 | bool SetOption(Environment* env, | |
| 213 | 213 | Opt* options, | |
| 214 | 214 | const Local<Object>& object, | |
@@ -223,7 +223,7 @@ bool SetOption(Environment* env, | |||
| 223 | 223 | return true; | |
| 224 | 224 | } | |
| 225 | 225 | ||
| 226 | - template <typename Opt, TLSContext::Options Opt::* member> | ||
| 226 | + template <typename Opt, TLSContext::Options Opt::*member> | ||
| 227 | 227 | bool SetOption(Environment* env, | |
| 228 | 228 | Opt* options, | |
| 229 | 229 | const Local<Object>& object, | |
@@ -238,7 +238,7 @@ bool SetOption(Environment* env, | |||
| 238 | 238 | return true; | |
| 239 | 239 | } | |
| 240 | 240 | ||
| 241 | - template <typename Opt, TransportParams::Options Opt::* member> | ||
| 241 | + template <typename Opt, TransportParams::Options Opt::*member> | ||
| 242 | 242 | bool SetOption(Environment* env, | |
| 243 | 243 | Opt* options, | |
| 244 | 244 | const Local<Object>& object, | |
@@ -253,7 +253,7 @@ bool SetOption(Environment* env, | |||
| 253 | 253 | return true; | |
| 254 | 254 | } | |
| 255 | 255 | ||
| 256 | - template <typename Opt, ngtcp2_cc_algo Opt::* member> | ||
| 256 | + template <typename Opt, ngtcp2_cc_algo Opt::*member> | ||
| 257 | 257 | bool SetOption(Environment* env, | |
| 258 | 258 | Opt* options, | |
| 259 | 259 | const Local<Object>& object, | |
@@ -2480,7 +2480,9 @@ bool Session::HandshakeCompleted() { | |||
| 2480 | 2480 | ||
| 2481 | 2481 | // If early data was attempted but rejected by the server, | |
| 2482 | 2482 | // tell ngtcp2 so it can retransmit the data as 1-RTT. | |
| 2483 | - if (!is_server() && !tls_session().early_data_was_accepted()) | ||
| 2483 | + // The status of early data will only be rejected if an | ||
| 2484 | + // attempt was actually made to send early data. | ||
| 2485 | + if (!is_server() && tls_session().early_data_was_rejected()) | ||
| 2484 | 2486 | ngtcp2_conn_tls_early_data_rejected(*this); | |
| 2485 | 2487 | ||
| 2486 | 2488 | // When in a server session, handshake completed == handshake confirmed. | |
@@ -2709,6 +2711,7 @@ void Session::EmitHandshakeComplete() { | |||
| 2709 | 2711 | Undefined(isolate), // Cipher version | |
| 2710 | 2712 | Undefined(isolate), // Validation error reason | |
| 2711 | 2713 | Undefined(isolate), // Validation error code | |
| 2714 | + Boolean::New(isolate, tls_session().early_data_was_attempted()), | ||
| 2712 | 2715 | Boolean::New(isolate, tls_session().early_data_was_accepted())}; | |
| 2713 | 2716 | ||
| 2714 | 2717 | auto& tls = tls_session(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -91,7 +91,7 @@ void EnableTrace(Environment* env, BIOPointer* bio, SSL* ssl) { | |||
| 91 | 91 | #endif | |
| 92 | 92 | } | |
| 93 | 93 | ||
| 94 | - template <typename T, typename Opt, std::vector<T> Opt::* member> | ||
| 94 | + template <typename T, typename Opt, std::vector<T> Opt::*member> | ||
| 95 | 95 | bool SetOption(Environment* env, | |
| 96 | 96 | Opt* options, | |
| 97 | 97 | const Local<Object>& object, | |
@@ -270,6 +270,14 @@ bool OSSLContext::get_early_data_accepted() const { | |||
| 270 | 270 | return SSL_get_early_data_status(*this) == SSL_EARLY_DATA_ACCEPTED; | |
| 271 | 271 | } | |
| 272 | 272 | ||
| 273 | + bool OSSLContext::get_early_data_rejected() const { | ||
| 274 | + return SSL_get_early_data_status(*this) == SSL_EARLY_DATA_REJECTED; | ||
| 275 | + } | ||
| 276 | + | ||
| 277 | + bool OSSLContext::get_early_data_attempted() const { | ||
| 278 | + return SSL_get_early_data_status(*this) != SSL_EARLY_DATA_NOT_SENT; | ||
| 279 | + } | ||
| 280 | + | ||
| 273 | 281 | bool OSSLContext::set_session_ticket(const ncrypto::SSLSessionPointer& ticket) { | |
| 274 | 282 | if (!ticket) return false; | |
| 275 | 283 | if (SSL_set_session(*this, ticket.get()) != 1) return false; | |
@@ -765,6 +773,16 @@ bool TLSSession::early_data_was_accepted() const { | |||
| 765 | 773 | return ossl_context_.get_early_data_accepted(); | |
| 766 | 774 | } | |
| 767 | 775 | ||
| 776 | + bool TLSSession::early_data_was_rejected() const { | ||
| 777 | + CHECK_NE(ngtcp2_conn_get_handshake_completed(*session_), 0); | ||
| 778 | + return ossl_context_.get_early_data_rejected(); | ||
| 779 | + } | ||
| 780 | + | ||
| 781 | + bool TLSSession::early_data_was_attempted() const { | ||
| 782 | + CHECK_NE(ngtcp2_conn_get_handshake_completed(*session_), 0); | ||
| 783 | + return ossl_context_.get_early_data_attempted(); | ||
| 784 | + } | ||
| 785 | + | ||
| 768 | 786 | void TLSSession::Initialize( | |
| 769 | 787 | const std::optional<SessionTicket>& maybeSessionTicket) { | |
| 770 | 788 | auto& ctx = context(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -55,6 +55,8 @@ class OSSLContext final { | |||
| 55 | 55 | bool set_transport_params(const ngtcp2_vec& tp) const; | |
| 56 | 56 | ||
| 57 | 57 | bool get_early_data_accepted() const; | |
| 58 | + bool get_early_data_rejected() const; | ||
| 59 | + bool get_early_data_attempted() const; | ||
| 58 | 60 | ||
| 59 | 61 | // Sets the session ticket for 0-RTT resumption. Returns true if the | |
| 60 | 62 | // ticket was set successfully and the ticket supports early data. | |
@@ -106,6 +108,8 @@ class TLSSession final : public MemoryRetainer { | |||
| 106 | 108 | // accepted by the TLS session. This will assert if the handshake has | |
| 107 | 109 | // not been completed. | |
| 108 | 110 | bool early_data_was_accepted() const; | |
| 111 | + bool early_data_was_rejected() const; | ||
| 112 | + bool early_data_was_attempted() const; | ||
| 109 | 113 | ||
| 110 | 114 | v8::MaybeLocal<v8::Object> cert(Environment* env) const; | |
| 111 | 115 | v8::MaybeLocal<v8::Object> peer_cert(Environment* env) const; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -200,7 +200,9 @@ std::optional<CID> RetryToken::Validate(uint32_t version, | |||
| 200 | 200 | const CID& dcid, | |
| 201 | 201 | const TokenSecret& token_secret, | |
| 202 | 202 | uint64_t verification_expiration) { | |
| 203 | - if (ptr_.base == nullptr || ptr_.len == 0) return std::nullopt; | ||
| 203 | + if (ptr_.base == nullptr || ptr_.len == 0 || verification_expiration == 0) { | ||
| 204 | + return std::nullopt; | ||
| 205 | + } | ||
| 204 | 206 | ngtcp2_cid ocid; | |
| 205 | 207 | int ret = ngtcp2_crypto_verify_retry_token( | |
| 206 | 208 | &ocid, | |
@@ -266,7 +268,9 @@ bool RegularToken::Validate(uint32_t version, | |||
| 266 | 268 | const SocketAddress& addr, | |
| 267 | 269 | const TokenSecret& token_secret, | |
| 268 | 270 | uint64_t verification_expiration) { | |
| 269 | - if (ptr_.base == nullptr || ptr_.len == 0) return false; | ||
| 271 | + if (ptr_.base == nullptr || ptr_.len == 0 || verification_expiration == 0) { | ||
| 272 | + return false; | ||
| 273 | + } | ||
| 270 | 274 | return ngtcp2_crypto_verify_regular_token( | |
| 271 | 275 | ptr_.base, | |
| 272 | 276 | ptr_.len, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,44 @@ | |||
| 1 | + // Flags: --experimental-quic --no-warnings | ||
| 2 | + | ||
| 3 | + import { hasQuic, skip, mustCall } from '../common/index.mjs'; | ||
| 4 | + import assert from 'node:assert'; | ||
| 5 | + import * as fixtures from '../common/fixtures.mjs'; | ||
| 6 | + | ||
| 7 | + if (!hasQuic) { | ||
| 8 | + skip('QUIC is not enabled'); | ||
| 9 | + } | ||
| 10 | + | ||
| 11 | + const { listen, connect } = await import('node:quic'); | ||
| 12 | + const { createPrivateKey } = await import('node:crypto'); | ||
| 13 | + | ||
| 14 | + const key = createPrivateKey(fixtures.readKey('agent1-key.pem')); | ||
| 15 | + const cert = fixtures.readKey('agent1-cert.pem'); | ||
| 16 | + | ||
| 17 | + // Test h3 ALPN negotiation with Http3ApplicationImpl. | ||
| 18 | + // Both server and client use the default ALPN (h3). | ||
| 19 | + | ||
| 20 | + const serverOpened = Promise.withResolvers(); | ||
| 21 | + const clientOpened = Promise.withResolvers(); | ||
| 22 | + | ||
| 23 | + const serverEndpoint = await listen(mustCall((serverSession) => { | ||
| 24 | + serverSession.opened.then(mustCall((info) => { | ||
| 25 | + assert.strictEqual(info.protocol, 'h3'); | ||
| 26 | + serverOpened.resolve(); | ||
| 27 | + serverSession.close(); | ||
| 28 | + })); | ||
| 29 | + }), { | ||
| 30 | + sni: { '*': { keys: [key], certs: [cert] } }, | ||
| 31 | + }); | ||
| 32 | + | ||
| 33 | + assert.ok(serverEndpoint.address !== undefined); | ||
| 34 | + | ||
| 35 | + const clientSession = await connect(serverEndpoint.address, { | ||
| 36 | + servername: 'localhost', | ||
| 37 | + }); | ||
| 38 | + clientSession.opened.then(mustCall((info) => { | ||
| 39 | + assert.strictEqual(info.protocol, 'h3'); | ||
| 40 | + clientOpened.resolve(); | ||
| 41 | + })); | ||
| 42 | + | ||
| 43 | + await Promise.all([serverOpened.promise, clientOpened.promise]); | ||
| 44 | + clientSession.close(); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments