@encharm/cws 4.5.1 → 4.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding.gyp +1 -1
- package/dist/bindings/cws_darwin_arm64_node137.node +0 -0
- package/dist/bindings/cws_linux_x64_node137.node +0 -0
- package/package.json +1 -1
- package/src/Addon.h +6 -1
- package/src/headers/24/acorn_version.h +6 -0
- package/src/headers/24/addon_permission.h +31 -0
- package/src/headers/24/agent.h +195 -0
- package/src/headers/24/aliased_buffer-inl.h +244 -0
- package/src/headers/24/aliased_buffer.h +206 -0
- package/src/headers/24/aliased_struct-inl.h +54 -0
- package/src/headers/24/aliased_struct.h +63 -0
- package/src/headers/24/amaro_version.h +6 -0
- package/src/headers/24/application.h +165 -0
- package/src/headers/24/async_context_frame.h +33 -0
- package/src/headers/24/async_wrap-inl.h +96 -0
- package/src/headers/24/async_wrap.h +244 -0
- package/src/headers/24/base_object-inl.h +330 -0
- package/src/headers/24/base_object.h +338 -0
- package/src/headers/24/base_object_types.h +74 -0
- package/src/headers/24/bindingdata.h +272 -0
- package/src/headers/24/blob_serializer_deserializer-inl.h +385 -0
- package/src/headers/24/blob_serializer_deserializer.h +132 -0
- package/src/headers/24/callback_queue-inl.h +97 -0
- package/src/headers/24/callback_queue.h +79 -0
- package/src/headers/24/cares_wrap.h +447 -0
- package/src/headers/24/child_process_permission.h +31 -0
- package/src/headers/24/cid.h +127 -0
- package/src/headers/24/cjs_module_lexer_version.h +6 -0
- package/src/headers/24/cleanup_queue-inl.h +36 -0
- package/src/headers/24/cleanup_queue.h +79 -0
- package/src/headers/24/compile_cache.h +113 -0
- package/src/headers/24/connect_wrap.h +26 -0
- package/src/headers/24/connection_wrap.h +30 -0
- package/src/headers/24/cppgc_helpers-inl.h +65 -0
- package/src/headers/24/cppgc_helpers.h +162 -0
- package/src/headers/24/crypto/crypto_aes.h +97 -0
- package/src/headers/24/crypto/crypto_argon2.h +86 -0
- package/src/headers/24/crypto/crypto_bio.h +193 -0
- package/src/headers/24/crypto/crypto_chacha20_poly1305.h +64 -0
- package/src/headers/24/crypto/crypto_cipher.h +281 -0
- package/src/headers/24/crypto/crypto_clienthello-inl.h +90 -0
- package/src/headers/24/crypto/crypto_clienthello.h +131 -0
- package/src/headers/24/crypto/crypto_common.h +48 -0
- package/src/headers/24/crypto/crypto_context.h +171 -0
- package/src/headers/24/crypto/crypto_dh.h +126 -0
- package/src/headers/24/crypto/crypto_dsa.h +50 -0
- package/src/headers/24/crypto/crypto_ec.h +163 -0
- package/src/headers/24/crypto/crypto_hash.h +89 -0
- package/src/headers/24/crypto/crypto_hkdf.h +61 -0
- package/src/headers/24/crypto/crypto_hmac.h +92 -0
- package/src/headers/24/crypto/crypto_kem.h +113 -0
- package/src/headers/24/crypto/crypto_keygen.h +290 -0
- package/src/headers/24/crypto/crypto_keys.h +392 -0
- package/src/headers/24/crypto/crypto_ml_dsa.h +21 -0
- package/src/headers/24/crypto/crypto_pbkdf2.h +74 -0
- package/src/headers/24/crypto/crypto_random.h +124 -0
- package/src/headers/24/crypto/crypto_rsa.h +136 -0
- package/src/headers/24/crypto/crypto_scrypt.h +85 -0
- package/src/headers/24/crypto/crypto_sig.h +156 -0
- package/src/headers/24/crypto/crypto_spkac.h +21 -0
- package/src/headers/24/crypto/crypto_timing.h +20 -0
- package/src/headers/24/crypto/crypto_tls.h +309 -0
- package/src/headers/24/crypto/crypto_util.h +598 -0
- package/src/headers/24/crypto/crypto_x509.h +140 -0
- package/src/headers/24/data.h +148 -0
- package/src/headers/24/debug_utils-inl.h +232 -0
- package/src/headers/24/debug_utils.h +193 -0
- package/src/headers/24/defs.h +254 -0
- package/src/headers/24/diagnosticfilename-inl.h +33 -0
- package/src/headers/24/embedded_data.h +17 -0
- package/src/headers/24/encoding_binding.h +60 -0
- package/src/headers/24/endpoint.h +421 -0
- package/src/headers/24/env-inl.h +935 -0
- package/src/headers/24/env.h +1257 -0
- package/src/headers/24/env_properties.h +561 -0
- package/src/headers/24/fs_permission.h +167 -0
- package/src/headers/24/handle_wrap.h +123 -0
- package/src/headers/24/histogram-inl.h +107 -0
- package/src/headers/24/histogram.h +279 -0
- package/src/headers/24/http3.h +44 -0
- package/src/headers/24/inspector_agent.h +165 -0
- package/src/headers/24/inspector_io.h +78 -0
- package/src/headers/24/inspector_permission.h +31 -0
- package/src/headers/24/inspector_profiler.h +149 -0
- package/src/headers/24/inspector_socket.h +60 -0
- package/src/headers/24/inspector_socket_server.h +110 -0
- package/src/headers/24/io_agent.h +30 -0
- package/src/headers/24/js_native_api.h +615 -0
- package/src/headers/24/js_native_api_types.h +211 -0
- package/src/headers/24/js_native_api_v8.h +485 -0
- package/src/headers/24/js_native_api_v8_internals.h +45 -0
- package/src/headers/24/js_stream.h +52 -0
- package/src/headers/24/json_parser.h +40 -0
- package/src/headers/24/json_utils.h +172 -0
- package/src/headers/24/logstream.h +81 -0
- package/src/headers/24/main_thread_interface.h +116 -0
- package/src/headers/24/memory_tracker-inl.h +454 -0
- package/src/headers/24/memory_tracker.h +333 -0
- package/src/headers/24/module_wrap.h +229 -0
- package/src/headers/24/ncrypto.h +1625 -0
- package/src/headers/24/network_agent.h +118 -0
- package/src/headers/24/network_inspector.h +45 -0
- package/src/headers/24/network_resource_manager.h +29 -0
- package/src/headers/24/node.h +1620 -0
- package/src/headers/24/node_api.h +269 -0
- package/src/headers/24/node_api_internals.h +46 -0
- package/src/headers/24/node_api_types.h +52 -0
- package/src/headers/24/node_binding.h +163 -0
- package/src/headers/24/node_blob.h +159 -0
- package/src/headers/24/node_bob-inl.h +36 -0
- package/src/headers/24/node_bob.h +107 -0
- package/src/headers/24/node_buffer.h +92 -0
- package/src/headers/24/node_builtins.h +223 -0
- package/src/headers/24/node_config_file.h +65 -0
- package/src/headers/24/node_constants.h +82 -0
- package/src/headers/24/node_context_data.h +168 -0
- package/src/headers/24/node_contextify.h +261 -0
- package/src/headers/24/node_crypto.h +62 -0
- package/src/headers/24/node_debug.h +25 -0
- package/src/headers/24/node_dir.h +52 -0
- package/src/headers/24/node_dotenv.h +45 -0
- package/src/headers/24/node_errors.h +391 -0
- package/src/headers/24/node_exit_code.h +54 -0
- package/src/headers/24/node_external_reference.h +167 -0
- package/src/headers/24/node_file-inl.h +412 -0
- package/src/headers/24/node_file.h +540 -0
- package/src/headers/24/node_http2.h +1175 -0
- package/src/headers/24/node_http2_state.h +159 -0
- package/src/headers/24/node_http_common-inl.h +198 -0
- package/src/headers/24/node_http_common.h +535 -0
- package/src/headers/24/node_i18n.h +132 -0
- package/src/headers/24/node_internals.h +476 -0
- package/src/headers/24/node_json.h +24 -0
- package/src/headers/24/node_large_page.h +34 -0
- package/src/headers/24/node_locks.h +180 -0
- package/src/headers/24/node_main_instance.h +67 -0
- package/src/headers/24/node_mem-inl.h +112 -0
- package/src/headers/24/node_mem.h +45 -0
- package/src/headers/24/node_messaging.h +389 -0
- package/src/headers/24/node_metadata.h +164 -0
- package/src/headers/24/node_modules.h +93 -0
- package/src/headers/24/node_mutex.h +323 -0
- package/src/headers/24/node_object_wrap.h +132 -0
- package/src/headers/24/node_options-inl.h +524 -0
- package/src/headers/24/node_options.h +682 -0
- package/src/headers/24/node_perf.h +166 -0
- package/src/headers/24/node_perf_common.h +102 -0
- package/src/headers/24/node_platform.h +286 -0
- package/src/headers/24/node_process-inl.h +26 -0
- package/src/headers/24/node_process.h +111 -0
- package/src/headers/24/node_realm-inl.h +153 -0
- package/src/headers/24/node_realm.h +236 -0
- package/src/headers/24/node_report.h +43 -0
- package/src/headers/24/node_revert.h +82 -0
- package/src/headers/24/node_root_certs.h +3546 -0
- package/src/headers/24/node_sea.h +74 -0
- package/src/headers/24/node_shadow_realm.h +46 -0
- package/src/headers/24/node_snapshot_builder.h +57 -0
- package/src/headers/24/node_snapshotable.h +174 -0
- package/src/headers/24/node_sockaddr-inl.h +257 -0
- package/src/headers/24/node_sockaddr.h +394 -0
- package/src/headers/24/node_sqlite.h +270 -0
- package/src/headers/24/node_stat_watcher.h +73 -0
- package/src/headers/24/node_string.h +101 -0
- package/src/headers/24/node_task_runner.h +92 -0
- package/src/headers/24/node_threadsafe_cow-inl.h +54 -0
- package/src/headers/24/node_threadsafe_cow.h +105 -0
- package/src/headers/24/node_trace_buffer.h +83 -0
- package/src/headers/24/node_trace_writer.h +75 -0
- package/src/headers/24/node_union_bytes.h +81 -0
- package/src/headers/24/node_url.h +101 -0
- package/src/headers/24/node_url_pattern.h +118 -0
- package/src/headers/24/node_v8.h +77 -0
- package/src/headers/24/node_v8_platform-inl.h +185 -0
- package/src/headers/24/node_version.h +110 -0
- package/src/headers/24/node_wasi.h +185 -0
- package/src/headers/24/node_wasm_web_api.h +55 -0
- package/src/headers/24/node_watchdog.h +154 -0
- package/src/headers/24/node_webstorage.h +60 -0
- package/src/headers/24/node_worker.h +159 -0
- package/src/headers/24/packet.h +155 -0
- package/src/headers/24/path.h +33 -0
- package/src/headers/24/permission/addon_permission.h +31 -0
- package/src/headers/24/permission/child_process_permission.h +31 -0
- package/src/headers/24/permission/fs_permission.h +167 -0
- package/src/headers/24/permission/inspector_permission.h +31 -0
- package/src/headers/24/permission/permission.h +100 -0
- package/src/headers/24/permission/permission_base.h +65 -0
- package/src/headers/24/permission/wasi_permission.h +31 -0
- package/src/headers/24/permission/worker_permission.h +31 -0
- package/src/headers/24/permission.h +100 -0
- package/src/headers/24/permission_base.h +65 -0
- package/src/headers/24/pipe_wrap.h +80 -0
- package/src/headers/24/preferredaddress.h +72 -0
- package/src/headers/24/protocol_helper.h +27 -0
- package/src/headers/24/queue.h +306 -0
- package/src/headers/24/req_wrap-inl.h +176 -0
- package/src/headers/24/req_wrap.h +79 -0
- package/src/headers/24/runtime_agent.h +41 -0
- package/src/headers/24/session.h +528 -0
- package/src/headers/24/sessionticket.h +108 -0
- package/src/headers/24/spawn_sync.h +243 -0
- package/src/headers/24/stream_base-inl.h +173 -0
- package/src/headers/24/stream_base.h +478 -0
- package/src/headers/24/stream_pipe.h +76 -0
- package/src/headers/24/stream_wrap.h +132 -0
- package/src/headers/24/streams.h +370 -0
- package/src/headers/24/string_bytes.h +109 -0
- package/src/headers/24/string_decoder-inl.h +31 -0
- package/src/headers/24/string_decoder.h +49 -0
- package/src/headers/24/target_agent.h +75 -0
- package/src/headers/24/tcp_wrap.h +105 -0
- package/src/headers/24/threadpoolwork-inl.h +70 -0
- package/src/headers/24/timer_wrap-inl.h +32 -0
- package/src/headers/24/timer_wrap.h +87 -0
- package/src/headers/24/timers.h +75 -0
- package/src/headers/24/tlscontext.h +228 -0
- package/src/headers/24/tokens.h +256 -0
- package/src/headers/24/trace_event.h +722 -0
- package/src/headers/24/trace_event_common.h +1109 -0
- package/src/headers/24/traced_value.h +129 -0
- package/src/headers/24/tracing_agent.h +43 -0
- package/src/headers/24/transportparams.h +166 -0
- package/src/headers/24/tty_wrap.h +65 -0
- package/src/headers/24/udp_wrap.h +230 -0
- package/src/headers/24/undici_version.h +6 -0
- package/src/headers/24/util-inl.h +711 -0
- package/src/headers/24/util.h +1016 -0
- package/src/headers/24/v8-external-memory-accounter.h +60 -0
- package/src/headers/24/v8-fast-api-calls.h +819 -0
- package/src/headers/24/v8-inspector.h +426 -0
- package/src/headers/24/wasi_permission.h +31 -0
- package/src/headers/24/worker_agent.h +40 -0
- package/src/headers/24/worker_inspector.h +124 -0
- package/src/headers/24/worker_permission.h +31 -0
- package/src/headers/24/zlib_version.h +6 -0
|
@@ -0,0 +1,528 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
4
|
+
#if HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC
|
|
5
|
+
|
|
6
|
+
#include <async_wrap.h>
|
|
7
|
+
#include <base_object.h>
|
|
8
|
+
#include <env.h>
|
|
9
|
+
#include <memory_tracker.h>
|
|
10
|
+
#include <ngtcp2/ngtcp2.h>
|
|
11
|
+
#include <node_http_common.h>
|
|
12
|
+
#include <node_sockaddr.h>
|
|
13
|
+
#include <timer_wrap.h>
|
|
14
|
+
#include <util.h>
|
|
15
|
+
#include <optional>
|
|
16
|
+
#include "bindingdata.h"
|
|
17
|
+
#include "cid.h"
|
|
18
|
+
#include "data.h"
|
|
19
|
+
#include "defs.h"
|
|
20
|
+
#include "logstream.h"
|
|
21
|
+
#include "packet.h"
|
|
22
|
+
#include "preferredaddress.h"
|
|
23
|
+
#include "sessionticket.h"
|
|
24
|
+
#include "streams.h"
|
|
25
|
+
#include "tlscontext.h"
|
|
26
|
+
#include "transportparams.h"
|
|
27
|
+
|
|
28
|
+
namespace node::quic {
|
|
29
|
+
|
|
30
|
+
class Endpoint;
|
|
31
|
+
|
|
32
|
+
// A Session represents one half of a persistent connection between two QUIC
|
|
33
|
+
// peers. Every Session is established first by performing a TLS handshake in
|
|
34
|
+
// which the client sends an initial packet to the server containing a TLS
|
|
35
|
+
// client hello. Once the TLS handshake has been completed, the Session can be
|
|
36
|
+
// used to open one or more Streams for the actual data flow back and forth.
|
|
37
|
+
//
|
|
38
|
+
// While client and server Sessions are created in slightly different ways,
|
|
39
|
+
// their lifecycles are generally identical:
|
|
40
|
+
//
|
|
41
|
+
// A Session is either acting as a Client or as a Server.
|
|
42
|
+
//
|
|
43
|
+
// Client Sessions are always created using Endpoint::Connect()
|
|
44
|
+
//
|
|
45
|
+
// Server Sessions are always created by an Endpoint receiving a valid initial
|
|
46
|
+
// request received from a remote client.
|
|
47
|
+
//
|
|
48
|
+
// As soon as Sessions of either type are created, they will immediately start
|
|
49
|
+
// working through the TLS handshake to establish the crypographic keys used to
|
|
50
|
+
// secure the communication. Once those keys are established, the Session can be
|
|
51
|
+
// used to open Streams. Based on how the Session is configured, any number of
|
|
52
|
+
// Streams can exist concurrently on a single Session.
|
|
53
|
+
//
|
|
54
|
+
// The Session wraps an ngtcp2_conn that is initialized when the session object
|
|
55
|
+
// is created. This ngtcp2_conn is destroyed when the session object is freed.
|
|
56
|
+
// However, the session can be in a closed/destroyed state and still have a
|
|
57
|
+
// valid ngtcp2_conn pointer. This is important because the ngtcp2 still might
|
|
58
|
+
// be processing data within the scope of an ngtcp2_conn after the session
|
|
59
|
+
// object itself is closed/destroyed by user code.
|
|
60
|
+
class Session final : public AsyncWrap, private SessionTicket::AppData::Source {
|
|
61
|
+
public:
|
|
62
|
+
// For simplicity, we use the same Application::Options struct for all
|
|
63
|
+
// Application types. This may change in the future. Not all of the options
|
|
64
|
+
// are going to be relevant for all Application types.
|
|
65
|
+
struct Application_Options final : public MemoryRetainer {
|
|
66
|
+
// The maximum number of header pairs permitted for a Stream.
|
|
67
|
+
// Only relevant if the selected application supports headers.
|
|
68
|
+
uint64_t max_header_pairs = DEFAULT_MAX_HEADER_LIST_PAIRS;
|
|
69
|
+
|
|
70
|
+
// The maximum total number of header bytes (including header
|
|
71
|
+
// name and value) permitted for a Stream.
|
|
72
|
+
// Only relevant if the selected application supports headers.
|
|
73
|
+
uint64_t max_header_length = DEFAULT_MAX_HEADER_LENGTH;
|
|
74
|
+
|
|
75
|
+
// HTTP/3 specific options.
|
|
76
|
+
uint64_t max_field_section_size = 0;
|
|
77
|
+
uint64_t qpack_max_dtable_capacity = 0;
|
|
78
|
+
uint64_t qpack_encoder_max_dtable_capacity = 0;
|
|
79
|
+
uint64_t qpack_blocked_streams = 0;
|
|
80
|
+
|
|
81
|
+
bool enable_connect_protocol = true;
|
|
82
|
+
bool enable_datagrams = true;
|
|
83
|
+
|
|
84
|
+
operator const nghttp3_settings() const;
|
|
85
|
+
|
|
86
|
+
SET_NO_MEMORY_INFO()
|
|
87
|
+
SET_MEMORY_INFO_NAME(Application::Options)
|
|
88
|
+
SET_SELF_SIZE(Options)
|
|
89
|
+
|
|
90
|
+
static v8::Maybe<Application_Options> From(Environment* env,
|
|
91
|
+
v8::Local<v8::Value> value);
|
|
92
|
+
|
|
93
|
+
std::string ToString() const;
|
|
94
|
+
|
|
95
|
+
static const Application_Options kDefault;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// An Application implements the ALPN-protocol specific semantics on behalf
|
|
99
|
+
// of a QUIC Session.
|
|
100
|
+
class Application;
|
|
101
|
+
|
|
102
|
+
// The ApplicationProvider optionally supplies the underlying application
|
|
103
|
+
// protocol handler used by a session. The ApplicationProvider is supplied
|
|
104
|
+
// in the *internal* options (that is, it is not exposed as a public, user
|
|
105
|
+
// facing API. If the ApplicationProvider is not specified, then the
|
|
106
|
+
// DefaultApplication is used (see application.cc).
|
|
107
|
+
class ApplicationProvider : public BaseObject {
|
|
108
|
+
public:
|
|
109
|
+
using BaseObject::BaseObject;
|
|
110
|
+
virtual std::unique_ptr<Application> Create(Session* session) = 0;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// The options used to configure a session. Most of these deal directly with
|
|
114
|
+
// the transport parameters that are exchanged with the remote peer during
|
|
115
|
+
// handshake.
|
|
116
|
+
struct Options final : public MemoryRetainer {
|
|
117
|
+
// The QUIC protocol version requested for the session.
|
|
118
|
+
uint32_t version = NGTCP2_PROTO_VER_MAX;
|
|
119
|
+
|
|
120
|
+
// Te minimum QUIC protocol version supported by this session.
|
|
121
|
+
uint32_t min_version = NGTCP2_PROTO_VER_MIN;
|
|
122
|
+
|
|
123
|
+
// By default a client session will ignore the preferred address
|
|
124
|
+
// advertised by the the server. This option is only relevant for
|
|
125
|
+
// client sessions.
|
|
126
|
+
PreferredAddress::Policy preferred_address_strategy =
|
|
127
|
+
PreferredAddress::Policy::IGNORE_PREFERRED;
|
|
128
|
+
|
|
129
|
+
TransportParams::Options transport_params =
|
|
130
|
+
TransportParams::Options::kDefault;
|
|
131
|
+
TLSContext::Options tls_options = TLSContext::Options::kDefault;
|
|
132
|
+
|
|
133
|
+
// A reference to the CID::Factory used to generate CID instances
|
|
134
|
+
// for this session.
|
|
135
|
+
const CID::Factory* cid_factory = &CID::Factory::random();
|
|
136
|
+
// If the CID::Factory is a base object, we keep a reference to it
|
|
137
|
+
// so that it cannot be garbage collected.
|
|
138
|
+
BaseObjectPtr<BaseObject> cid_factory_ref;
|
|
139
|
+
|
|
140
|
+
// If the application provider is specified, it will be used to create
|
|
141
|
+
// the underlying Application instance for the session.
|
|
142
|
+
BaseObjectPtr<ApplicationProvider> application_provider;
|
|
143
|
+
|
|
144
|
+
// When true, QLog output will be enabled for the session.
|
|
145
|
+
bool qlog = false;
|
|
146
|
+
|
|
147
|
+
// The amount of time (in milliseconds) that the endpoint will wait for the
|
|
148
|
+
// completion of the tls handshake.
|
|
149
|
+
uint64_t handshake_timeout = UINT64_MAX;
|
|
150
|
+
|
|
151
|
+
// Maximum initial flow control window size for a stream.
|
|
152
|
+
uint64_t max_stream_window = 0;
|
|
153
|
+
|
|
154
|
+
// Maximum initial flow control window size for the connection.
|
|
155
|
+
uint64_t max_window = 0;
|
|
156
|
+
|
|
157
|
+
// The max_payload_size is the maximum size of a serialized QUIC packet. It
|
|
158
|
+
// should always be set small enough to fit within a single MTU without
|
|
159
|
+
// fragmentation. The default is set by the QUIC specification at 1200. This
|
|
160
|
+
// value should not be changed unless you know for sure that the entire path
|
|
161
|
+
// supports a given MTU without fragmenting at any point in the path.
|
|
162
|
+
uint64_t max_payload_size = kDefaultMaxPacketLength;
|
|
163
|
+
|
|
164
|
+
// The unacknowledged_packet_threshold is the maximum number of
|
|
165
|
+
// unacknowledged packets that an ngtcp2 session will accumulate before
|
|
166
|
+
// sending an acknowledgement. Setting this to 0 uses the ngtcp2 defaults,
|
|
167
|
+
// which is what most will want. The value can be changed to fine tune some
|
|
168
|
+
// of the performance characteristics of the session. This should only be
|
|
169
|
+
// changed if you have a really good reason for doing so.
|
|
170
|
+
uint64_t unacknowledged_packet_threshold = 0;
|
|
171
|
+
|
|
172
|
+
// There are several common congestion control algorithms that ngtcp2 uses
|
|
173
|
+
// to determine how it manages the flow control window: RENO, CUBIC, and
|
|
174
|
+
// BBR. The details of how each works is not relevant here. The choice of
|
|
175
|
+
// which to use by default is arbitrary and we can choose whichever we'd
|
|
176
|
+
// like. Additional performance profiling will be needed to determine which
|
|
177
|
+
// is the better of the two for our needs.
|
|
178
|
+
ngtcp2_cc_algo cc_algorithm = CC_ALGO_CUBIC;
|
|
179
|
+
|
|
180
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
181
|
+
SET_MEMORY_INFO_NAME(Session::Options)
|
|
182
|
+
SET_SELF_SIZE(Options)
|
|
183
|
+
|
|
184
|
+
static v8::Maybe<Options> From(Environment* env,
|
|
185
|
+
v8::Local<v8::Value> value);
|
|
186
|
+
|
|
187
|
+
std::string ToString() const;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
// The additional configuration settings used to create a specific session.
|
|
191
|
+
// while the Options above can be used to configure multiple sessions, a
|
|
192
|
+
// single Config is used to create a single session, which is why they are
|
|
193
|
+
// kept separate.
|
|
194
|
+
struct Config final : MemoryRetainer {
|
|
195
|
+
// Is the Session acting as a client or a server?
|
|
196
|
+
Side side;
|
|
197
|
+
|
|
198
|
+
// The options to use for this session.
|
|
199
|
+
Options options;
|
|
200
|
+
|
|
201
|
+
// The actual QUIC version identified for this session.
|
|
202
|
+
uint32_t version;
|
|
203
|
+
|
|
204
|
+
SocketAddress local_address;
|
|
205
|
+
SocketAddress remote_address;
|
|
206
|
+
|
|
207
|
+
// The destination CID, identifying the remote peer. This value is always
|
|
208
|
+
// provided by the remote peer.
|
|
209
|
+
CID dcid = CID::kInvalid;
|
|
210
|
+
|
|
211
|
+
// The source CID, identifying this session. This value is always created
|
|
212
|
+
// locally.
|
|
213
|
+
CID scid = CID::kInvalid;
|
|
214
|
+
|
|
215
|
+
// Used only by client sessions to identify the original DCID
|
|
216
|
+
// used to initiate the connection.
|
|
217
|
+
CID ocid = CID::kInvalid;
|
|
218
|
+
CID retry_scid = CID::kInvalid;
|
|
219
|
+
CID preferred_address_cid = CID::kInvalid;
|
|
220
|
+
|
|
221
|
+
ngtcp2_settings settings = {};
|
|
222
|
+
operator ngtcp2_settings*() { return &settings; }
|
|
223
|
+
operator const ngtcp2_settings*() const { return &settings; }
|
|
224
|
+
|
|
225
|
+
Config(Environment* env,
|
|
226
|
+
Side side,
|
|
227
|
+
const Options& options,
|
|
228
|
+
uint32_t version,
|
|
229
|
+
const SocketAddress& local_address,
|
|
230
|
+
const SocketAddress& remote_address,
|
|
231
|
+
const CID& dcid,
|
|
232
|
+
const CID& scid,
|
|
233
|
+
const CID& ocid = CID::kInvalid);
|
|
234
|
+
|
|
235
|
+
Config(Environment* env,
|
|
236
|
+
const Options& options,
|
|
237
|
+
const SocketAddress& local_address,
|
|
238
|
+
const SocketAddress& remote_address,
|
|
239
|
+
const CID& ocid = CID::kInvalid);
|
|
240
|
+
|
|
241
|
+
void set_token(const uint8_t* token,
|
|
242
|
+
size_t len,
|
|
243
|
+
ngtcp2_token_type type = NGTCP2_TOKEN_TYPE_UNKNOWN);
|
|
244
|
+
void set_token(const RetryToken& token);
|
|
245
|
+
void set_token(const RegularToken& token);
|
|
246
|
+
|
|
247
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
248
|
+
SET_MEMORY_INFO_NAME(Session::Config)
|
|
249
|
+
SET_SELF_SIZE(Config)
|
|
250
|
+
|
|
251
|
+
std::string ToString() const;
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
static bool HasInstance(Environment* env, v8::Local<v8::Value> value);
|
|
255
|
+
static v8::Local<v8::FunctionTemplate> GetConstructorTemplate(
|
|
256
|
+
Environment* env);
|
|
257
|
+
static void InitPerIsolate(IsolateData* isolate_data,
|
|
258
|
+
v8::Local<v8::ObjectTemplate> target);
|
|
259
|
+
static void InitPerContext(Realm* env, v8::Local<v8::Object> target);
|
|
260
|
+
static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
|
|
261
|
+
|
|
262
|
+
static BaseObjectPtr<Session> Create(
|
|
263
|
+
Endpoint* endpoint,
|
|
264
|
+
const Config& config,
|
|
265
|
+
TLSContext* tls_context,
|
|
266
|
+
const std::optional<SessionTicket>& ticket);
|
|
267
|
+
|
|
268
|
+
// Really should be private but MakeDetachedBaseObject needs visibility.
|
|
269
|
+
Session(Endpoint* endpoint,
|
|
270
|
+
v8::Local<v8::Object> object,
|
|
271
|
+
const Config& config,
|
|
272
|
+
TLSContext* tls_context,
|
|
273
|
+
const std::optional<SessionTicket>& ticket);
|
|
274
|
+
DISALLOW_COPY_AND_MOVE(Session)
|
|
275
|
+
~Session() override;
|
|
276
|
+
|
|
277
|
+
bool is_destroyed() const;
|
|
278
|
+
bool is_server() const;
|
|
279
|
+
|
|
280
|
+
uint32_t version() const;
|
|
281
|
+
Endpoint& endpoint() const;
|
|
282
|
+
TLSSession& tls_session() const;
|
|
283
|
+
Application& application() const;
|
|
284
|
+
const Config& config() const;
|
|
285
|
+
const Options& options() const;
|
|
286
|
+
const SocketAddress& remote_address() const;
|
|
287
|
+
const SocketAddress& local_address() const;
|
|
288
|
+
|
|
289
|
+
std::string diagnostic_name() const override;
|
|
290
|
+
|
|
291
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
292
|
+
SET_MEMORY_INFO_NAME(Session)
|
|
293
|
+
SET_SELF_SIZE(Session)
|
|
294
|
+
|
|
295
|
+
operator ngtcp2_conn*() const;
|
|
296
|
+
|
|
297
|
+
// Ensures that the session/application sends pending data when the scope
|
|
298
|
+
// exits. Scopes can be nested. When nested, pending data will be sent
|
|
299
|
+
// only when the outermost scope is exited.
|
|
300
|
+
struct SendPendingDataScope final {
|
|
301
|
+
Session* session;
|
|
302
|
+
explicit SendPendingDataScope(Session* session);
|
|
303
|
+
explicit SendPendingDataScope(const BaseObjectPtr<Session>& session);
|
|
304
|
+
~SendPendingDataScope();
|
|
305
|
+
DISALLOW_COPY_AND_MOVE(SendPendingDataScope)
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
struct State;
|
|
309
|
+
struct Stats;
|
|
310
|
+
|
|
311
|
+
void HandleQlog(uint32_t flags, const void* data, size_t len);
|
|
312
|
+
|
|
313
|
+
private:
|
|
314
|
+
struct Impl;
|
|
315
|
+
|
|
316
|
+
using StreamsMap = std::unordered_map<int64_t, BaseObjectPtr<Stream>>;
|
|
317
|
+
using QuicConnectionPointer = DeleteFnPtr<ngtcp2_conn, ngtcp2_conn_del>;
|
|
318
|
+
|
|
319
|
+
struct PathValidationFlags final {
|
|
320
|
+
bool preferredAddress = false;
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
struct DatagramReceivedFlags final {
|
|
324
|
+
bool early = false;
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
bool Receive(Store&& store,
|
|
328
|
+
const SocketAddress& local_address,
|
|
329
|
+
const SocketAddress& remote_address);
|
|
330
|
+
|
|
331
|
+
void Send(const BaseObjectPtr<Packet>& packet);
|
|
332
|
+
void Send(const BaseObjectPtr<Packet>& packet, const PathStorage& path);
|
|
333
|
+
uint64_t SendDatagram(Store&& data);
|
|
334
|
+
|
|
335
|
+
// A non-const variation to allow certain modifications.
|
|
336
|
+
Config& config();
|
|
337
|
+
|
|
338
|
+
enum class CreateStreamOption {
|
|
339
|
+
NOTIFY,
|
|
340
|
+
DO_NOT_NOTIFY,
|
|
341
|
+
};
|
|
342
|
+
BaseObjectPtr<Stream> FindStream(int64_t id) const;
|
|
343
|
+
BaseObjectPtr<Stream> CreateStream(
|
|
344
|
+
int64_t id,
|
|
345
|
+
CreateStreamOption option = CreateStreamOption::NOTIFY,
|
|
346
|
+
std::shared_ptr<DataQueue> data_source = nullptr);
|
|
347
|
+
void AddStream(BaseObjectPtr<Stream> stream,
|
|
348
|
+
CreateStreamOption option = CreateStreamOption::NOTIFY);
|
|
349
|
+
void RemoveStream(int64_t id);
|
|
350
|
+
void ResumeStream(int64_t id);
|
|
351
|
+
void StreamDataBlocked(int64_t id);
|
|
352
|
+
void ShutdownStream(int64_t id, QuicError error = QuicError());
|
|
353
|
+
void ShutdownStreamWrite(int64_t id, QuicError code = QuicError());
|
|
354
|
+
|
|
355
|
+
// Use the configured CID::Factory to generate a new CID.
|
|
356
|
+
CID new_cid(size_t len = CID::kMaxLength) const;
|
|
357
|
+
|
|
358
|
+
const TransportParams local_transport_params() const;
|
|
359
|
+
const TransportParams remote_transport_params() const;
|
|
360
|
+
|
|
361
|
+
bool is_destroyed_or_closing() const;
|
|
362
|
+
size_t max_packet_size() const;
|
|
363
|
+
void set_priority_supported(bool on = true);
|
|
364
|
+
|
|
365
|
+
// Open a new locally-initialized stream with the specified directionality.
|
|
366
|
+
// If the session is not yet in a state where the stream can be openen --
|
|
367
|
+
// such as when the handshake is not yet sufficiently far along and ORTT
|
|
368
|
+
// session resumption is not being used -- then the stream will be created
|
|
369
|
+
// in a pending state where actually opening the stream will be deferred.
|
|
370
|
+
v8::MaybeLocal<v8::Object> OpenStream(
|
|
371
|
+
Direction direction, std::shared_ptr<DataQueue> data_source = nullptr);
|
|
372
|
+
|
|
373
|
+
void ExtendStreamOffset(int64_t id, size_t amount);
|
|
374
|
+
void ExtendOffset(size_t amount);
|
|
375
|
+
void SetLastError(QuicError&& error);
|
|
376
|
+
uint64_t max_data_left() const;
|
|
377
|
+
|
|
378
|
+
PendingStream::PendingStreamQueue& pending_bidi_stream_queue() const;
|
|
379
|
+
PendingStream::PendingStreamQueue& pending_uni_stream_queue() const;
|
|
380
|
+
|
|
381
|
+
// Implementation of SessionTicket::AppData::Source
|
|
382
|
+
void CollectSessionTicketAppData(
|
|
383
|
+
SessionTicket::AppData* app_data) const override;
|
|
384
|
+
SessionTicket::AppData::Status ExtractSessionTicketAppData(
|
|
385
|
+
const SessionTicket::AppData& app_data,
|
|
386
|
+
SessionTicket::AppData::Source::Flag flag) override;
|
|
387
|
+
|
|
388
|
+
// Returns true if the Session has entered the closing period after sending a
|
|
389
|
+
// CONNECTION_CLOSE. While true, the Session is only permitted to transmit
|
|
390
|
+
// CONNECTION_CLOSE frames until either the idle timeout period elapses or
|
|
391
|
+
// until the Session is explicitly destroyed.
|
|
392
|
+
bool is_in_closing_period() const;
|
|
393
|
+
|
|
394
|
+
// Returns true if the Session has received a CONNECTION_CLOSE frame from the
|
|
395
|
+
// peer. Once in the draining period, the Session is not permitted to send any
|
|
396
|
+
// frames to the peer. The Session will be silently closed after either the
|
|
397
|
+
// idle timeout period elapses or until the Session is explicitly destroyed.
|
|
398
|
+
bool is_in_draining_period() const;
|
|
399
|
+
|
|
400
|
+
// Returns false if the Session is currently in a state where it is unable to
|
|
401
|
+
// transmit any packets.
|
|
402
|
+
bool can_send_packets() const;
|
|
403
|
+
|
|
404
|
+
// Returns false if the Session is currently in a state where it cannot create
|
|
405
|
+
// new streams. Specifically, a stream is not in a state to create streams if
|
|
406
|
+
// it has been destroyed or is closing.
|
|
407
|
+
bool can_create_streams() const;
|
|
408
|
+
|
|
409
|
+
// Returns false if the Session is currently in a state where it cannot open
|
|
410
|
+
// a new locally-initiated stream. When using 0RTT session resumption, this
|
|
411
|
+
// will become true immediately after the session ticket and transport params
|
|
412
|
+
// have been configured. Otherwise, it becomes true after the remote transport
|
|
413
|
+
// params and tx keys have been installed.
|
|
414
|
+
bool can_open_streams() const;
|
|
415
|
+
|
|
416
|
+
uint64_t max_local_streams_uni() const;
|
|
417
|
+
uint64_t max_local_streams_bidi() const;
|
|
418
|
+
|
|
419
|
+
bool wants_session_ticket() const;
|
|
420
|
+
void SetStreamOpenAllowed();
|
|
421
|
+
|
|
422
|
+
// It's a terrible name but "wrapped" here means that the Session has been
|
|
423
|
+
// passed out to JavaScript and should be "wrapped" by whatever handler is
|
|
424
|
+
// defined there to manage it.
|
|
425
|
+
void set_wrapped();
|
|
426
|
+
|
|
427
|
+
enum class CloseMethod {
|
|
428
|
+
// Immediate close with a roundtrip through JavaScript, causing all
|
|
429
|
+
// currently opened streams to be closed. An attempt will be made to
|
|
430
|
+
// send a CONNECTION_CLOSE frame to the peer. If closing while within
|
|
431
|
+
// the ngtcp2 callback scope, sending the CONNECTION_CLOSE will be
|
|
432
|
+
// deferred until the scope exits.
|
|
433
|
+
DEFAULT,
|
|
434
|
+
// Same as DEFAULT except that no attempt to notify the peer will be
|
|
435
|
+
// made.
|
|
436
|
+
SILENT,
|
|
437
|
+
// Closing gracefully disables the ability to open or accept new streams
|
|
438
|
+
// for this Session. Existing streams are allowed to close naturally on
|
|
439
|
+
// their own.
|
|
440
|
+
// Once called, the Session will be immediately closed once there are no
|
|
441
|
+
// remaining streams. No notification is given to the connected peer that
|
|
442
|
+
// we are in a graceful closing state. A CONNECTION_CLOSE will be sent
|
|
443
|
+
// only once FinishClose() is called.
|
|
444
|
+
GRACEFUL
|
|
445
|
+
};
|
|
446
|
+
// Initiate closing of the session.
|
|
447
|
+
void Close(CloseMethod method = CloseMethod::DEFAULT);
|
|
448
|
+
|
|
449
|
+
void FinishClose();
|
|
450
|
+
void Destroy();
|
|
451
|
+
|
|
452
|
+
// Close the session and send a connection close packet to the peer.
|
|
453
|
+
// If creating the packet fails the session will be silently closed.
|
|
454
|
+
// The connection close packet will use the value of last_error_ as
|
|
455
|
+
// the error code transmitted to the peer.
|
|
456
|
+
void SendConnectionClose();
|
|
457
|
+
void OnTimeout();
|
|
458
|
+
|
|
459
|
+
void UpdateTimer();
|
|
460
|
+
// Has to be called after certain operations that generate packets.
|
|
461
|
+
void UpdatePacketTxTime();
|
|
462
|
+
void UpdateDataStats();
|
|
463
|
+
void UpdatePath(const PathStorage& path);
|
|
464
|
+
|
|
465
|
+
void ProcessPendingBidiStreams();
|
|
466
|
+
void ProcessPendingUniStreams();
|
|
467
|
+
|
|
468
|
+
// JavaScript callouts
|
|
469
|
+
|
|
470
|
+
void EmitClose(const QuicError& error = QuicError());
|
|
471
|
+
void EmitDatagram(Store&& datagram, DatagramReceivedFlags flag);
|
|
472
|
+
void EmitDatagramStatus(uint64_t id, DatagramStatus status);
|
|
473
|
+
void EmitHandshakeComplete();
|
|
474
|
+
void EmitKeylog(const char* line);
|
|
475
|
+
|
|
476
|
+
struct ValidatedPath {
|
|
477
|
+
std::shared_ptr<SocketAddress> local;
|
|
478
|
+
std::shared_ptr<SocketAddress> remote;
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
void EmitPathValidation(PathValidationResult result,
|
|
482
|
+
PathValidationFlags flags,
|
|
483
|
+
const ValidatedPath& newPath,
|
|
484
|
+
const std::optional<ValidatedPath>& oldPath);
|
|
485
|
+
void EmitSessionTicket(Store&& ticket);
|
|
486
|
+
void EmitStream(const BaseObjectWeakPtr<Stream>& stream);
|
|
487
|
+
void EmitVersionNegotiation(const ngtcp2_pkt_hd& hd,
|
|
488
|
+
const uint32_t* sv,
|
|
489
|
+
size_t nsv);
|
|
490
|
+
void DatagramStatus(uint64_t datagramId, DatagramStatus status);
|
|
491
|
+
void DatagramReceived(const uint8_t* data,
|
|
492
|
+
size_t datalen,
|
|
493
|
+
DatagramReceivedFlags flag);
|
|
494
|
+
void GenerateNewConnectionId(ngtcp2_cid* cid, size_t len, uint8_t* token);
|
|
495
|
+
bool HandshakeCompleted();
|
|
496
|
+
void HandshakeConfirmed();
|
|
497
|
+
void SelectPreferredAddress(PreferredAddress* preferredAddress);
|
|
498
|
+
|
|
499
|
+
static std::unique_ptr<Application> SelectApplication(Session* session,
|
|
500
|
+
const Config& config);
|
|
501
|
+
|
|
502
|
+
QuicConnectionPointer InitConnection();
|
|
503
|
+
|
|
504
|
+
Side side_;
|
|
505
|
+
ngtcp2_mem allocator_;
|
|
506
|
+
std::unique_ptr<Impl> impl_;
|
|
507
|
+
QuicConnectionPointer connection_;
|
|
508
|
+
std::unique_ptr<TLSSession> tls_session_;
|
|
509
|
+
BaseObjectPtr<LogStream> qlog_stream_;
|
|
510
|
+
BaseObjectPtr<LogStream> keylog_stream_;
|
|
511
|
+
|
|
512
|
+
friend class Application;
|
|
513
|
+
friend class DefaultApplication;
|
|
514
|
+
friend class Http3ApplicationImpl;
|
|
515
|
+
friend class Endpoint;
|
|
516
|
+
friend class Stream;
|
|
517
|
+
friend class PendingStream;
|
|
518
|
+
friend class TLSContext;
|
|
519
|
+
friend class TLSSession;
|
|
520
|
+
friend class TransportParams;
|
|
521
|
+
friend struct Impl;
|
|
522
|
+
friend struct SendPendingDataScope;
|
|
523
|
+
};
|
|
524
|
+
|
|
525
|
+
} // namespace node::quic
|
|
526
|
+
|
|
527
|
+
#endif // HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC
|
|
528
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
4
|
+
#if HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC
|
|
5
|
+
|
|
6
|
+
#include <crypto/crypto_common.h>
|
|
7
|
+
#include <env.h>
|
|
8
|
+
#include <memory_tracker.h>
|
|
9
|
+
#include <uv.h>
|
|
10
|
+
#include <v8.h>
|
|
11
|
+
#include "data.h"
|
|
12
|
+
#include "defs.h"
|
|
13
|
+
|
|
14
|
+
namespace node::quic {
|
|
15
|
+
|
|
16
|
+
// A TLS 1.3 Session resumption ticket. Encapsulates both the TLS
|
|
17
|
+
// ticket and the encoded QUIC transport parameters. The encoded
|
|
18
|
+
// structure should be considered to be opaque for end users.
|
|
19
|
+
// In JavaScript, the ticket will be represented as a Buffer
|
|
20
|
+
// instance with opaque data. To resume a session, the user code
|
|
21
|
+
// would pass that Buffer back into to client connection API.
|
|
22
|
+
class SessionTicket final : public MemoryRetainer {
|
|
23
|
+
public:
|
|
24
|
+
static v8::Maybe<SessionTicket> FromV8Value(Environment* env,
|
|
25
|
+
v8::Local<v8::Value> value);
|
|
26
|
+
|
|
27
|
+
SessionTicket() = default;
|
|
28
|
+
SessionTicket(Store&& ticket, Store&& transport_params);
|
|
29
|
+
|
|
30
|
+
const uv_buf_t ticket() const;
|
|
31
|
+
|
|
32
|
+
const ngtcp2_vec transport_params() const;
|
|
33
|
+
|
|
34
|
+
v8::MaybeLocal<v8::Object> encode(Environment* env) const;
|
|
35
|
+
|
|
36
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
37
|
+
SET_MEMORY_INFO_NAME(SessionTicket)
|
|
38
|
+
SET_SELF_SIZE(SessionTicket)
|
|
39
|
+
|
|
40
|
+
class AppData;
|
|
41
|
+
|
|
42
|
+
// The callback that OpenSSL will call when generating the session ticket
|
|
43
|
+
// and it needs to collect additional application specific data.
|
|
44
|
+
static int GenerateCallback(SSL* ssl, void* arg);
|
|
45
|
+
|
|
46
|
+
// The callback that OpenSSL will call when consuming the session ticket
|
|
47
|
+
// and it needs to pass embedded application data back into the app.
|
|
48
|
+
static SSL_TICKET_RETURN DecryptedCallback(SSL* ssl,
|
|
49
|
+
SSL_SESSION* session,
|
|
50
|
+
const unsigned char* keyname,
|
|
51
|
+
size_t keyname_len,
|
|
52
|
+
SSL_TICKET_STATUS status,
|
|
53
|
+
void* arg);
|
|
54
|
+
|
|
55
|
+
private:
|
|
56
|
+
Store ticket_;
|
|
57
|
+
Store transport_params_;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// SessionTicket::AppData is a utility class that is used only during the
|
|
61
|
+
// generation or access of TLS stateless session tickets. It exists solely to
|
|
62
|
+
// provide a easier way for Session::Application instances to set relevant
|
|
63
|
+
// metadata in the session ticket when it is created, and the extract and
|
|
64
|
+
// subsequently verify that data when a ticket is received and is being
|
|
65
|
+
// validated. The app data is completely opaque to anything other than the
|
|
66
|
+
// server-side of the Session::Application that sets it.
|
|
67
|
+
class SessionTicket::AppData final {
|
|
68
|
+
public:
|
|
69
|
+
enum class Status {
|
|
70
|
+
TICKET_IGNORE = SSL_TICKET_RETURN_IGNORE,
|
|
71
|
+
TICKET_IGNORE_RENEW = SSL_TICKET_RETURN_IGNORE_RENEW,
|
|
72
|
+
TICKET_USE = SSL_TICKET_RETURN_USE,
|
|
73
|
+
TICKET_USE_RENEW = SSL_TICKET_RETURN_USE_RENEW,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
explicit AppData(SSL* session);
|
|
77
|
+
DISALLOW_COPY_AND_MOVE(AppData)
|
|
78
|
+
|
|
79
|
+
bool Set(const uv_buf_t& data);
|
|
80
|
+
std::optional<const uv_buf_t> Get() const;
|
|
81
|
+
|
|
82
|
+
// A source of application data collected during the creation of the
|
|
83
|
+
// session ticket. This interface will be implemented by the QUIC
|
|
84
|
+
// Session.
|
|
85
|
+
class Source {
|
|
86
|
+
public:
|
|
87
|
+
enum class Flag { STATUS_NONE, STATUS_RENEW };
|
|
88
|
+
|
|
89
|
+
// Collect application data into the given AppData instance.
|
|
90
|
+
virtual void CollectSessionTicketAppData(AppData* app_data) const = 0;
|
|
91
|
+
|
|
92
|
+
// Extract application data from the given AppData instance.
|
|
93
|
+
virtual Status ExtractSessionTicketAppData(
|
|
94
|
+
const AppData& app_data, Flag flag = Flag::STATUS_NONE) = 0;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
static void Collect(SSL* ssl);
|
|
98
|
+
static Status Extract(SSL* ssl);
|
|
99
|
+
|
|
100
|
+
private:
|
|
101
|
+
bool set_ = false;
|
|
102
|
+
SSL* ssl_;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
} // namespace node::quic
|
|
106
|
+
|
|
107
|
+
#endif // HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC
|
|
108
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|