| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ca0080c commit b91a934
21 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -192,8 +192,15 @@ | |||
| 192 | 192 | 'src/udp_wrap.cc', | |
| 193 | 193 | 'src/util.cc', | |
| 194 | 194 | 'src/uv.cc', | |
| 195 | + 'src/quic/bindingdata.cc', | ||
| 195 | 196 | 'src/quic/cid.cc', | |
| 196 | 197 | 'src/quic/data.cc', | |
| 198 | + 'src/quic/logstream.cc', | ||
| 199 | + 'src/quic/packet.cc', | ||
| 200 | + 'src/quic/preferredaddress.cc', | ||
| 201 | + 'src/quic/sessionticket.cc', | ||
| 202 | + 'src/quic/tokens.cc', | ||
| 203 | + # 'src/quic/transportparams.cc', | ||
| 197 | 204 | # headers to make for a more pleasant IDE experience | |
| 198 | 205 | 'src/aliased_buffer.h', | |
| 199 | 206 | 'src/aliased_buffer-inl.h', | |
@@ -331,9 +338,16 @@ | |||
| 331 | 338 | 'src/udp_wrap.h', | |
| 332 | 339 | 'src/util.h', | |
| 333 | 340 | 'src/util-inl.h', | |
| 341 | + 'src/quic/bindingdata.h', | ||
| 334 | 342 | 'src/quic/cid.h', | |
| 335 | 343 | 'src/quic/data.h', | |
| 336 | 344 | 'src/quic/defs.h', | |
| 345 | + 'src/quic/logstream.h', | ||
| 346 | + 'src/quic/packet.h', | ||
| 347 | + 'src/quic/preferredaddress.h', | ||
| 348 | + 'src/quic/sessionticket.h', | ||
| 349 | + 'src/quic/tokens.h', | ||
| 350 | + # 'src/quic/transportparams.h', | ||
| 337 | 351 | 'src/quic/guard.h', | |
| 338 | 352 | ], | |
| 339 | 353 | 'node_crypto_sources': [ | |
@@ -398,31 +412,17 @@ | |||
| 398 | 412 | ], | |
| 399 | 413 | 'node_quic_sources': [ | |
| 400 | 414 | 'src/quic/application.cc', | |
| 401 | - 'src/quic/bindingdata.cc', | ||
| 402 | 415 | 'src/quic/endpoint.cc', | |
| 403 | 416 | 'src/quic/http3.cc', | |
| 404 | - 'src/quic/logstream.cc', | ||
| 405 | - 'src/quic/packet.cc', | ||
| 406 | - 'src/quic/preferredaddress.cc', | ||
| 407 | 417 | 'src/quic/session.cc', | |
| 408 | - 'src/quic/sessionticket.cc', | ||
| 409 | 418 | 'src/quic/streams.cc', | |
| 410 | 419 | 'src/quic/tlscontext.cc', | |
| 411 | - 'src/quic/tokens.cc', | ||
| 412 | - 'src/quic/transportparams.cc', | ||
| 413 | 420 | 'src/quic/application.h', | |
| 414 | - 'src/quic/bindingdata.h', | ||
| 415 | 421 | 'src/quic/endpoint.h', | |
| 416 | 422 | 'src/quic/http3.h', | |
| 417 | - 'src/quic/logstream.h', | ||
| 418 | - 'src/quic/packet.h', | ||
| 419 | - 'src/quic/preferredaddress.h', | ||
| 420 | 423 | 'src/quic/session.h', | |
| 421 | - 'src/quic/sessionticket.h', | ||
| 422 | 424 | 'src/quic/streams.h', | |
| 423 | 425 | 'src/quic/tlscontext.h', | |
| 424 | - 'src/quic/tokens.h', | ||
| 425 | - 'src/quic/transportparams.h', | ||
| 426 | 426 | 'src/quic/quic.cc', | |
| 427 | 427 | ], | |
| 428 | 428 | 'node_cctest_openssl_sources': [ | |
@@ -431,6 +431,7 @@ | |||
| 431 | 431 | 'test/cctest/test_node_crypto_env.cc', | |
| 432 | 432 | 'test/cctest/test_quic_cid.cc', | |
| 433 | 433 | 'test/cctest/test_quic_error.cc', | |
| 434 | + 'test/cctest/test_quic_preferredaddress.cc', | ||
| 434 | 435 | 'test/cctest/test_quic_tokens.cc', | |
| 435 | 436 | ], | |
| 436 | 437 | 'node_cctest_inspector_sources': [ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -290,7 +290,7 @@ void Session::Application::SendPendingData() { | |||
| 290 | 290 | // The stream_data is the next block of data from the application stream. | |
| 291 | 291 | if (GetStreamData(&stream_data) < 0) { | |
| 292 | 292 | Debug(session_, "Application failed to get stream data"); | |
| 293 | - packet->Done(UV_ECANCELED); | ||
| 293 | + packet->CancelPacket(); | ||
| 294 | 294 | session_->SetLastError(QuicError::ForNgtcp2Error(NGTCP2_ERR_INTERNAL)); | |
| 295 | 295 | return session_->Close(CloseMethod::SILENT); | |
| 296 | 296 | } | |
@@ -357,7 +357,7 @@ void Session::Application::SendPendingData() { | |||
| 357 | 357 | if (ndatalen >= 0 && !StreamCommit(&stream_data, ndatalen)) { | |
| 358 | 358 | Debug(session_, | |
| 359 | 359 | "Failed to commit stream data while writing packets"); | |
| 360 | - packet->Done(UV_ECANCELED); | ||
| 360 | + packet->CancelPacket();; | ||
| 361 | 361 | session_->SetLastError( | |
| 362 | 362 | QuicError::ForNgtcp2Error(NGTCP2_ERR_INTERNAL)); | |
| 363 | 363 | return session_->Close(CloseMethod::SILENT); | |
@@ -371,11 +371,11 @@ void Session::Application::SendPendingData() { | |||
| 371 | 371 | Debug(session_, | |
| 372 | 372 | "Application encountered error while writing packet: %s", | |
| 373 | 373 | ngtcp2_strerror(nwrite)); | |
| 374 | - packet->Done(UV_ECANCELED); | ||
| 374 | + packet->CancelPacket(); | ||
| 375 | 375 | session_->SetLastError(QuicError::ForNgtcp2Error(nwrite)); | |
| 376 | 376 | return session_->Close(CloseMethod::SILENT); | |
| 377 | 377 | } else if (ndatalen >= 0 && !StreamCommit(&stream_data, ndatalen)) { | |
| 378 | - packet->Done(UV_ECANCELED); | ||
| 378 | + packet->CancelPacket(); | ||
| 379 | 379 | session_->SetLastError(QuicError::ForNgtcp2Error(NGTCP2_ERR_INTERNAL)); | |
| 380 | 380 | return session_->Close(CloseMethod::SILENT); | |
| 381 | 381 | } | |
@@ -394,7 +394,7 @@ void Session::Application::SendPendingData() { | |||
| 394 | 394 | packet->Truncate(datalen); | |
| 395 | 395 | session_->Send(packet, path); | |
| 396 | 396 | } else { | |
| 397 | - packet->Done(UV_ECANCELED); | ||
| 397 | + packet->CancelPacket(); | ||
| 398 | 398 | } | |
| 399 | 399 | ||
| 400 | 400 | return; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,6 @@ | |||
| 1 | - #if HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC | ||
| 1 | + #if HAVE_OPENSSL | ||
| 2 | + #include "guard.h" | ||
| 3 | + #ifndef OPENSSL_NO_QUIC | ||
| 2 | 4 | #include "bindingdata.h" | |
| 3 | 5 | #include <base_object-inl.h> | |
| 4 | 6 | #include <env-inl.h> | |
@@ -49,10 +51,12 @@ void BindingData::CheckAllocatedSize(size_t previous_size) const { | |||
| 49 | 51 | } | |
| 50 | 52 | ||
| 51 | 53 | void BindingData::IncreaseAllocatedSize(size_t size) { | |
| 54 | + CHECK_GE(current_ngtcp2_memory_ + size, current_ngtcp2_memory_); | ||
| 52 | 55 | current_ngtcp2_memory_ += size; | |
| 53 | 56 | } | |
| 54 | 57 | ||
| 55 | 58 | void BindingData::DecreaseAllocatedSize(size_t size) { | |
| 59 | + CHECK_LE(current_ngtcp2_memory_ - size, current_ngtcp2_memory_); | ||
| 56 | 60 | current_ngtcp2_memory_ -= size; | |
| 57 | 61 | } | |
| 58 | 62 | ||
@@ -220,4 +224,5 @@ void IllegalConstructor(const FunctionCallbackInfo<Value>& args) { | |||
| 220 | 224 | } // namespace quic | |
| 221 | 225 | } // namespace node | |
| 222 | 226 | ||
| 223 | - #endif // HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC | ||
| 227 | + #endif // OPENSSL_NO_QUIC | ||
| 228 | + #endif // HAVE_OPENSSL | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,6 @@ | |||
| 1 | 1 | #pragma once | |
| 2 | 2 | ||
| 3 | 3 | #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS | |
| 4 | - #if HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC | ||
| 5 | 4 | ||
| 6 | 5 | #include <base_object.h> | |
| 7 | 6 | #include <env.h> | |
@@ -26,32 +25,32 @@ class Packet; | |||
| 26 | 25 | // The FunctionTemplates the BindingData will store for us. | |
| 27 | 26 | #define QUIC_CONSTRUCTORS(V) \ | |
| 28 | 27 | V(endpoint) \ | |
| 28 | + V(http3application) \ | ||
| 29 | 29 | V(logstream) \ | |
| 30 | 30 | V(packet) \ | |
| 31 | 31 | V(session) \ | |
| 32 | 32 | V(stream) \ | |
| 33 | - V(udp) \ | ||
| 34 | - V(http3application) | ||
| 33 | + V(udp) | ||
| 35 | 34 | ||
| 36 | 35 | // The callbacks are persistent v8::Function references that are set in the | |
| 37 | 36 | // quic::BindingState used to communicate data and events back out to the JS | |
| 38 | 37 | // environment. They are set once from the JavaScript side when the | |
| 39 | 38 | // internalBinding('quic') is first loaded. | |
| 40 | 39 | #define QUIC_JS_CALLBACKS(V) \ | |
| 41 | 40 | V(endpoint_close, EndpointClose) \ | |
| 42 | - V(session_new, SessionNew) \ | ||
| 43 | 41 | V(session_close, SessionClose) \ | |
| 44 | 42 | V(session_datagram, SessionDatagram) \ | |
| 45 | 43 | V(session_datagram_status, SessionDatagramStatus) \ | |
| 46 | 44 | V(session_handshake, SessionHandshake) \ | |
| 45 | + V(session_new, SessionNew) \ | ||
| 46 | + V(session_path_validation, SessionPathValidation) \ | ||
| 47 | 47 | V(session_ticket, SessionTicket) \ | |
| 48 | 48 | V(session_version_negotiation, SessionVersionNegotiation) \ | |
| 49 | - V(session_path_validation, SessionPathValidation) \ | ||
| 49 | + V(stream_blocked, StreamBlocked) \ | ||
| 50 | 50 | V(stream_close, StreamClose) \ | |
| 51 | 51 | V(stream_created, StreamCreated) \ | |
| 52 | - V(stream_reset, StreamReset) \ | ||
| 53 | 52 | V(stream_headers, StreamHeaders) \ | |
| 54 | - V(stream_blocked, StreamBlocked) \ | ||
| 53 | + V(stream_reset, StreamReset) \ | ||
| 55 | 54 | V(stream_trailers, StreamTrailers) | |
| 56 | 55 | ||
| 57 | 56 | // The various JS strings the implementation uses. | |
@@ -64,10 +63,10 @@ class Packet; | |||
| 64 | 63 | V(application_provider, "provider") \ | |
| 65 | 64 | V(bbr, "bbr") \ | |
| 66 | 65 | V(ca, "ca") \ | |
| 67 | - V(certs, "certs") \ | ||
| 68 | 66 | V(cc_algorithm, "cc") \ | |
| 69 | - V(crl, "crl") \ | ||
| 67 | + V(certs, "certs") \ | ||
| 70 | 68 | V(ciphers, "ciphers") \ | |
| 69 | + V(crl, "crl") \ | ||
| 71 | 70 | V(cubic, "cubic") \ | |
| 72 | 71 | V(disable_stateless_reset, "disableStatelessReset") \ | |
| 73 | 72 | V(enable_connect_protocol, "enableConnectProtocol") \ | |
@@ -114,8 +113,8 @@ class Packet; | |||
| 114 | 113 | V(qpack_max_dtable_capacity, "qpackMaxDTableCapacity") \ | |
| 115 | 114 | V(reject_unauthorized, "rejectUnauthorized") \ | |
| 116 | 115 | V(reno, "reno") \ | |
| 117 | - V(retry_token_expiration, "retryTokenExpiration") \ | ||
| 118 | 116 | V(reset_token_secret, "resetTokenSecret") \ | |
| 117 | + V(retry_token_expiration, "retryTokenExpiration") \ | ||
| 119 | 118 | V(rx_loss, "rxDiagnosticLoss") \ | |
| 120 | 119 | V(servername, "servername") \ | |
| 121 | 120 | V(session, "Session") \ | |
@@ -150,6 +149,9 @@ class BindingData final | |||
| 150 | 149 | static void RegisterExternalReferences(ExternalReferenceRegistry* registry); | |
| 151 | 150 | ||
| 152 | 151 | static BindingData& Get(Environment* env); | |
| 152 | + static inline BindingData& Get(Realm* realm) { | ||
| 153 | + return Get(realm->env()); | ||
| 154 | + } | ||
| 153 | 155 | ||
| 154 | 156 | BindingData(Realm* realm, v8::Local<v8::Object> object); | |
| 155 | 157 | DISALLOW_COPY_AND_MOVE(BindingData) | |
@@ -179,6 +181,7 @@ class BindingData final | |||
| 179 | 181 | ||
| 180 | 182 | bool in_ngtcp2_callback_scope = false; | |
| 181 | 183 | bool in_nghttp3_callback_scope = false; | |
| 184 | + size_t current_ngtcp2_memory_ = 0; | ||
| 182 | 185 | ||
| 183 | 186 | // The following set up various storage and accessors for common strings, | |
| 184 | 187 | // construction templates, and callbacks stored on the BindingData. These | |
@@ -205,8 +208,6 @@ class BindingData final | |||
| 205 | 208 | QUIC_JS_CALLBACKS(V) | |
| 206 | 209 | #undef V | |
| 207 | 210 | ||
| 208 | - size_t current_ngtcp2_memory_ = 0; | ||
| 209 | - | ||
| 210 | 211 | #define V(name) v8::Global<v8::FunctionTemplate> name##_constructor_template_; | |
| 211 | 212 | QUIC_CONSTRUCTORS(V) | |
| 212 | 213 | #undef V | |
@@ -229,15 +230,15 @@ void IllegalConstructor(const v8::FunctionCallbackInfo<v8::Value>& args); | |||
| 229 | 230 | // The ngtcp2 and nghttp3 callbacks have certain restrictions | |
| 230 | 231 | // that forbid re-entry. We provide the following scopes for | |
| 231 | 232 | // use in those to help protect against it. | |
| 232 | - struct NgTcp2CallbackScope { | ||
| 233 | + struct NgTcp2CallbackScope final { | ||
| 233 | 234 | Environment* env; | |
| 234 | 235 | explicit NgTcp2CallbackScope(Environment* env); | |
| 235 | 236 | DISALLOW_COPY_AND_MOVE(NgTcp2CallbackScope) | |
| 236 | 237 | ~NgTcp2CallbackScope(); | |
| 237 | 238 | static bool in_ngtcp2_callback(Environment* env); | |
| 238 | 239 | }; | |
| 239 | 240 | ||
| 240 | - struct NgHttp3CallbackScope { | ||
| 241 | + struct NgHttp3CallbackScope final { | ||
| 241 | 242 | Environment* env; | |
| 242 | 243 | explicit NgHttp3CallbackScope(Environment* env); | |
| 243 | 244 | DISALLOW_COPY_AND_MOVE(NgHttp3CallbackScope) | |
@@ -268,5 +269,4 @@ struct CallbackScope final : public CallbackScopeBase { | |||
| 268 | 269 | ||
| 269 | 270 | } // namespace node::quic | |
| 270 | 271 | ||
| 271 | - #endif // HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC | ||
| 272 | 272 | #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -751,14 +751,14 @@ void Endpoint::Send(const BaseObjectPtr<Packet>& packet) { | |||
| 751 | 751 | // dropped. This can happen to any type of packet. We use this only in | |
| 752 | 752 | // testing to test various reliability issues. | |
| 753 | 753 | if (is_diagnostic_packet_loss(options_.tx_loss)) [[unlikely]] { | |
| 754 | - packet->Done(0); | ||
| 754 | + packet->Done(); | ||
| 755 | 755 | // Simulating tx packet loss | |
| 756 | 756 | return; | |
| 757 | 757 | } | |
| 758 | 758 | #endif // DEBUG | |
| 759 | 759 | ||
| 760 | 760 | if (is_closed() || is_closing() || packet->length() == 0) { | |
| 761 | - packet->Done(UV_ECANCELED); | ||
| 761 | + packet->CancelPacket(); | ||
| 762 | 762 | return; | |
| 763 | 763 | } | |
| 764 | 764 | Debug(this, "Sending %s", packet->ToString()); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,6 @@ | |||
| 1 | - #if HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC | ||
| 2 | - | ||
| 1 | + #if HAVE_OPENSSL | ||
| 2 | + #include "guard.h" | ||
| 3 | + #ifndef OPENSSL_NO_QUIC | ||
| 3 | 4 | #include "logstream.h" | |
| 4 | 5 | #include <async_wrap-inl.h> | |
| 5 | 6 | #include <base_object-inl.h> | |
@@ -149,4 +150,5 @@ void LogStream::ensure_space(size_t amt) { | |||
| 149 | 150 | } // namespace quic | |
| 150 | 151 | } // namespace node | |
| 151 | 152 | ||
| 152 | - #endif // HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC | ||
| 153 | + #endif // OPENSSL_NO_QUIC | ||
| 154 | + #endif // HAVE_OPENSSL | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,19 +1,18 @@ | |||
| 1 | 1 | #pragma once | |
| 2 | 2 | ||
| 3 | 3 | #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS | |
| 4 | - #if HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC | ||
| 5 | 4 | ||
| 6 | 5 | #include <async_wrap.h> | |
| 7 | 6 | #include <base_object.h> | |
| 8 | 7 | #include <env.h> | |
| 9 | 8 | #include <stream_base.h> | |
| 10 | - #include <deque> | ||
| 9 | + #include <list> | ||
| 11 | 10 | ||
| 12 | 11 | namespace node::quic { | |
| 13 | 12 | ||
| 14 | 13 | // The LogStream is a utility that the QUIC impl uses to publish both QLog | |
| 15 | 14 | // and Keylog diagnostic data (one instance for each). | |
| 16 | - class LogStream : public AsyncWrap, public StreamBase { | ||
| 15 | + class LogStream final : public AsyncWrap, public StreamBase { | ||
| 17 | 16 | public: | |
| 18 | 17 | static v8::Local<v8::FunctionTemplate> GetConstructorTemplate( | |
| 19 | 18 | Environment* env); | |
@@ -26,7 +25,7 @@ class LogStream : public AsyncWrap, public StreamBase { | |||
| 26 | 25 | ||
| 27 | 26 | LogStream(Environment* env, v8::Local<v8::Object> obj); | |
| 28 | 27 | ||
| 29 | - enum class EmitOption { | ||
| 28 | + enum class EmitOption : uint8_t { | ||
| 30 | 29 | NONE, | |
| 31 | 30 | FIN, | |
| 32 | 31 | }; | |
@@ -65,10 +64,10 @@ class LogStream : public AsyncWrap, public StreamBase { | |||
| 65 | 64 | uv_buf_t buf; | |
| 66 | 65 | }; | |
| 67 | 66 | size_t total_ = 0; | |
| 67 | + std::list<Chunk> buffer_; | ||
| 68 | 68 | bool fin_seen_ = false; | |
| 69 | 69 | bool ended_ = false; | |
| 70 | 70 | bool reading_ = false; | |
| 71 | - std::deque<Chunk> buffer_; | ||
| 72 | 71 | ||
| 73 | 72 | // The value here is fairly arbitrary. Once we get everything | |
| 74 | 73 | // fully implemented and start working with this, we might | |
@@ -81,5 +80,4 @@ class LogStream : public AsyncWrap, public StreamBase { | |||
| 81 | 80 | ||
| 82 | 81 | } // namespace node::quic | |
| 83 | 82 | ||
| 84 | - #endif // HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC | ||
| 85 | 83 | #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS | |
| Back | FazBrowse Home | New Git URL |
0 commit comments