|
12 | 12 | #include <node.h>
|
13 | 13 | #include <node_mem.h>
|
14 | 14 | #include <v8.h>
|
| 15 | +#include <vector> |
15 | 16 |
|
16 | 17 | namespace node {
|
17 | 18 | namespace quic {
|
18 | 19 |
|
19 | 20 | class Endpoint;
|
| 21 | +class Packet; |
20 | 22 |
|
21 | 23 | enum class Side {
|
22 | 24 | CLIENT = NGTCP2_CRYPTO_SIDE_CLIENT,
|
@@ -64,23 +66,37 @@ constexpr size_t kDefaultMaxPacketLength = NGTCP2_MAX_UDP_PAYLOAD_SIZE;
|
64 | 66 | #define QUIC_STRINGS(V) \
|
65 | 67 | V(ack_delay_exponent, "ackDelayExponent") \
|
66 | 68 | V(active_connection_id_limit, "activeConnectionIDLimit") \
|
| 69 | + V(alpn, "alpn") \ |
| 70 | + V(ca, "ca") \ |
| 71 | + V(certs, "certs") \ |
| 72 | + V(crl, "crl") \ |
| 73 | + V(ciphers, "ciphers") \ |
67 | 74 | V(disable_active_migration, "disableActiveMigration") \
|
| 75 | + V(enable_tls_trace, "tlsTrace") \ |
68 | 76 | V(endpoint, "Endpoint") \
|
69 | 77 | V(endpoint_udp, "Endpoint::UDP") \
|
| 78 | + V(groups, "groups") \ |
| 79 | + V(hostname, "hostname") \ |
70 | 80 | V(http3_alpn, &NGHTTP3_ALPN_H3[1]) \
|
71 | 81 | V(initial_max_data, "initialMaxData") \
|
72 | 82 | V(initial_max_stream_data_bidi_local, "initialMaxStreamDataBidiLocal") \
|
73 | 83 | V(initial_max_stream_data_bidi_remote, "initialMaxStreamDataBidiRemote") \
|
74 | 84 | V(initial_max_stream_data_uni, "initialMaxStreamDataUni") \
|
75 | 85 | V(initial_max_streams_bidi, "initialMaxStreamsBidi") \
|
76 | 86 | V(initial_max_streams_uni, "initialMaxStreamsUni") \
|
| 87 | + V(keylog, "keylog") \ |
| 88 | + V(keys, "keys") \ |
77 | 89 | V(logstream, "LogStream") \
|
78 | 90 | V(max_ack_delay, "maxAckDelay") \
|
79 | 91 | V(max_datagram_frame_size, "maxDatagramFrameSize") \
|
80 | 92 | V(max_idle_timeout, "maxIdleTimeout") \
|
81 | 93 | V(packetwrap, "PacketWrap") \
|
| 94 | + V(reject_unauthorized, "rejectUnauthorized") \ |
| 95 | + V(request_peer_certificate, "requestPeerCertificate") \ |
82 | 96 | V(session, "Session") \
|
83 |
| - V(stream, "Stream") |
| 97 | + V(session_id_ctx, "sessionIDContext") \ |
| 98 | + V(stream, "Stream") \ |
| 99 | + V(verify_hostname_identity, "verifyHostnameIdentity") |
84 | 100 |
|
85 | 101 | // =============================================================================
|
86 | 102 | // The BindingState object holds state for the internalBinding('quic') binding
|
@@ -115,12 +131,14 @@ class BindingData final
|
115 | 131 | // bridge out to the JS API.
|
116 | 132 | static void SetCallbacks(const v8::FunctionCallbackInfo<v8::Value>& args);
|
117 | 133 |
|
118 |
| - // TODO(@jasnell) This will be added when Endpoint is implemented. |
119 |
| - // // A set of listening Endpoints. We maintain this to ensure that the |
120 |
| - // Endpoint |
121 |
| - // // cannot be gc'd while it is still listening and there are active |
122 |
| - // // connections. |
123 |
| - // std::unordered_map<Endpoint*, BaseObjectPtr<Endpoint>> listening_endpoints; |
| 134 | + std::vector<BaseObjectPtr<BaseObject>> packet_freelist; |
| 135 | + |
| 136 | + // Purge the packet free list to free up memory. |
| 137 | + static void FlushPacketFreelist( |
| 138 | + const v8::FunctionCallbackInfo<v8::Value>& args); |
| 139 | + |
| 140 | + bool in_ngtcp2_callback_scope = false; |
| 141 | + bool in_nghttp3_callback_scope = false; |
124 | 142 |
|
125 | 143 | // The following set up various storage and accessors for common strings,
|
126 | 144 | // construction templates, and callbacks stored on the BindingData. These
|
@@ -166,6 +184,25 @@ class BindingData final
|
166 | 184 | #undef V
|
167 | 185 | };
|
168 | 186 |
|
| 187 | +void IllegalConstructor(const v8::FunctionCallbackInfo<v8::Value>& args); |
| 188 | + |
| 189 | +// The ngtcp2 and nghttp3 callbacks have certain restrictions |
| 190 | +// that forbid re-entry. We provide the following scopes for |
| 191 | +// use in those to help protect against it. |
| 192 | +struct NgTcp2CallbackScope { |
| 193 | + Environment* env; |
| 194 | + explicit NgTcp2CallbackScope(Environment* env); |
| 195 | + ~NgTcp2CallbackScope(); |
| 196 | + static bool in_ngtcp2_callback(Environment* env); |
| 197 | +}; |
| 198 | + |
| 199 | +struct NgHttp3CallbackScope { |
| 200 | + Environment* env; |
| 201 | + explicit NgHttp3CallbackScope(Environment* env); |
| 202 | + ~NgHttp3CallbackScope(); |
| 203 | + static bool in_nghttp3_callback(Environment* env); |
| 204 | +}; |
| 205 | + |
169 | 206 | } // namespace quic
|
170 | 207 | } // namespace node
|
171 | 208 |
|
|
0 commit comments