12
12
#include < node.h>
13
13
#include < node_mem.h>
14
14
#include < v8.h>
15
+ #include < limits>
16
+ #include < unordered_map>
15
17
#include < vector>
16
18
17
19
namespace node {
@@ -26,6 +28,9 @@ enum class Side {
26
28
};
27
29
28
30
constexpr size_t kDefaultMaxPacketLength = NGTCP2_MAX_UDP_PAYLOAD_SIZE;
31
+ constexpr size_t kMaxSizeT = std::numeric_limits<size_t >::max();
32
+ constexpr uint64_t kMaxSafeJsInteger = 9007199254740991 ;
33
+ constexpr auto kSocketAddressInfoTimeout = 60 * NGTCP2_SECONDS;
29
34
30
35
// ============================================================================
31
36
@@ -44,7 +49,6 @@ constexpr size_t kDefaultMaxPacketLength = NGTCP2_MAX_UDP_PAYLOAD_SIZE;
44
49
// internalBinding('quic') is first loaded.
45
50
#define QUIC_JS_CALLBACKS (V ) \
46
51
V (endpoint_close, EndpointClose) \
47
- V (endpoint_error, EndpointError) \
48
52
V(session_new, SessionNew) \
49
53
V(session_close, SessionClose) \
50
54
V(session_error, SessionError) \
@@ -66,12 +70,15 @@ constexpr size_t kDefaultMaxPacketLength = NGTCP2_MAX_UDP_PAYLOAD_SIZE;
66
70
#define QUIC_STRINGS (V ) \
67
71
V (ack_delay_exponent, " ackDelayExponent" ) \
68
72
V(active_connection_id_limit, " activeConnectionIDLimit" ) \
73
+ V(address_lru_size, " addressLRUSize" ) \
69
74
V(alpn, " alpn" ) \
70
75
V(ca, " ca" ) \
71
76
V(certs, " certs" ) \
77
+ V(cc_algorithm, " cc" ) \
72
78
V(crl, " crl" ) \
73
79
V(ciphers, " ciphers" ) \
74
80
V(disable_active_migration, " disableActiveMigration" ) \
81
+ V(disable_stateless_reset, " disableStatelessReset" ) \
75
82
V(enable_tls_trace, " tlsTrace" ) \
76
83
V(endpoint, " Endpoint" ) \
77
84
V(endpoint_udp, " Endpoint::UDP" ) \
@@ -84,18 +91,35 @@ constexpr size_t kDefaultMaxPacketLength = NGTCP2_MAX_UDP_PAYLOAD_SIZE;
84
91
V(initial_max_stream_data_uni, " initialMaxStreamDataUni" ) \
85
92
V(initial_max_streams_bidi, " initialMaxStreamsBidi" ) \
86
93
V(initial_max_streams_uni, " initialMaxStreamsUni" ) \
94
+ V(ipv6_only, " ipv6Only" ) \
87
95
V(keylog, " keylog" ) \
88
96
V(keys, " keys" ) \
89
97
V(logstream, " LogStream" ) \
90
98
V(max_ack_delay, " maxAckDelay" ) \
99
+ V(max_connections_per_host, " maxConnectionsPerHost" ) \
100
+ V(max_connections_total, " maxConnectionsTotal" ) \
91
101
V(max_datagram_frame_size, " maxDatagramFrameSize" ) \
92
102
V(max_idle_timeout, " maxIdleTimeout" ) \
103
+ V(max_payload_size, " maxPayloadSize" ) \
104
+ V(max_retries, " maxRetries" ) \
105
+ V(max_stateless_resets, " maxStatelessResetsPerHost" ) \
93
106
V(packetwrap, " PacketWrap" ) \
94
107
V(reject_unauthorized, " rejectUnauthorized" ) \
108
+ V(retry_token_expiration, " retryTokenExpiration" ) \
95
109
V(request_peer_certificate, " requestPeerCertificate" ) \
110
+ V(reset_token_secret, " resetTokenSecret" ) \
111
+ V(rx_loss, " rxDiagnosticLoss" ) \
96
112
V(session, " Session" ) \
97
113
V(session_id_ctx, " sessionIDContext" ) \
98
114
V(stream, " Stream" ) \
115
+ V(token_expiration, " tokenExpiration" ) \
116
+ V(token_secret, " tokenSecret" ) \
117
+ V(tx_loss, " txDiagnosticLoss" ) \
118
+ V(udp_receive_buffer_size, " udpReceiveBufferSize" ) \
119
+ V(udp_send_buffer_size, " udpSendBufferSize" ) \
120
+ V(udp_ttl, " udpTTL" ) \
121
+ V(unacknowledged_packet_threshold, " unacknowledgedPacketThreshold" ) \
122
+ V(validate_address, " validateAddress" ) \
99
123
V(verify_hostname_identity, " verifyHostnameIdentity" )
100
124
101
125
// =============================================================================
@@ -133,6 +157,8 @@ class BindingData final
133
157
134
158
std::vector<BaseObjectPtr<BaseObject>> packet_freelist;
135
159
160
+ std::unordered_map<Endpoint*, BaseObjectPtr<BaseObject>> listening_endpoints;
161
+
136
162
// Purge the packet free list to free up memory.
137
163
static void FlushPacketFreelist (
138
164
const v8::FunctionCallbackInfo<v8::Value>& args);
@@ -203,6 +229,26 @@ struct NgHttp3CallbackScope {
203
229
static bool in_nghttp3_callback (Environment* env);
204
230
};
205
231
232
+ struct CallbackScopeBase {
233
+ Environment* env;
234
+ v8::Context::Scope context_scope;
235
+ v8::TryCatch try_catch;
236
+
237
+ explicit CallbackScopeBase (Environment* env);
238
+ CallbackScopeBase (const CallbackScopeBase&) = delete ;
239
+ CallbackScopeBase (CallbackScopeBase&&) = delete ;
240
+ CallbackScopeBase& operator =(const CallbackScopeBase&) = delete ;
241
+ CallbackScopeBase& operator =(CallbackScopeBase&&) = delete ;
242
+ ~CallbackScopeBase ();
243
+ };
244
+
245
+ template <typename T>
246
+ struct CallbackScope final : public CallbackScopeBase {
247
+ BaseObjectPtr<T> ref;
248
+ explicit CallbackScope (const T* ptr)
249
+ : CallbackScopeBase(ptr->env ()), ref(ptr) {}
250
+ };
251
+
206
252
} // namespace quic
207
253
} // namespace node
208
254
0 commit comments