@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,447 @@
|
|
|
1
|
+
#ifndef SRC_CARES_WRAP_H_
|
|
2
|
+
#define SRC_CARES_WRAP_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#define CARES_STATICLIB
|
|
7
|
+
|
|
8
|
+
#include "async_wrap.h"
|
|
9
|
+
#include "base_object.h"
|
|
10
|
+
#include "env.h"
|
|
11
|
+
#include "memory_tracker.h"
|
|
12
|
+
#include "node.h"
|
|
13
|
+
#include "node_internals.h"
|
|
14
|
+
#include "util.h"
|
|
15
|
+
|
|
16
|
+
#include "ares.h"
|
|
17
|
+
#include "v8.h"
|
|
18
|
+
#include "uv.h"
|
|
19
|
+
|
|
20
|
+
#include <unordered_set>
|
|
21
|
+
|
|
22
|
+
#ifdef __POSIX__
|
|
23
|
+
# include <netdb.h>
|
|
24
|
+
#endif // __POSIX__
|
|
25
|
+
|
|
26
|
+
# include <ares_nameser.h>
|
|
27
|
+
|
|
28
|
+
namespace node {
|
|
29
|
+
namespace cares_wrap {
|
|
30
|
+
|
|
31
|
+
constexpr int ns_t_cname_or_a = -1;
|
|
32
|
+
constexpr int DNS_ESETSRVPENDING = -1000;
|
|
33
|
+
constexpr uint8_t DNS_ORDER_VERBATIM = 0;
|
|
34
|
+
constexpr uint8_t DNS_ORDER_IPV4_FIRST = 1;
|
|
35
|
+
constexpr uint8_t DNS_ORDER_IPV6_FIRST = 2;
|
|
36
|
+
|
|
37
|
+
class ChannelWrap;
|
|
38
|
+
|
|
39
|
+
inline void safe_free_hostent(struct hostent* host);
|
|
40
|
+
|
|
41
|
+
using HostEntPointer = DeleteFnPtr<hostent, ares_free_hostent>;
|
|
42
|
+
using SafeHostEntPointer = DeleteFnPtr<hostent, safe_free_hostent>;
|
|
43
|
+
|
|
44
|
+
inline const char* ToErrorCodeString(int status) {
|
|
45
|
+
switch (status) {
|
|
46
|
+
#define V(code) case ARES_##code: return #code;
|
|
47
|
+
V(EADDRGETNETWORKPARAMS)
|
|
48
|
+
V(EBADFAMILY)
|
|
49
|
+
V(EBADFLAGS)
|
|
50
|
+
V(EBADHINTS)
|
|
51
|
+
V(EBADNAME)
|
|
52
|
+
V(EBADQUERY)
|
|
53
|
+
V(EBADRESP)
|
|
54
|
+
V(EBADSTR)
|
|
55
|
+
V(ECANCELLED)
|
|
56
|
+
V(ECONNREFUSED)
|
|
57
|
+
V(EDESTRUCTION)
|
|
58
|
+
V(EFILE)
|
|
59
|
+
V(EFORMERR)
|
|
60
|
+
V(ELOADIPHLPAPI)
|
|
61
|
+
V(ENODATA)
|
|
62
|
+
V(ENOMEM)
|
|
63
|
+
V(ENONAME)
|
|
64
|
+
V(ENOTFOUND)
|
|
65
|
+
V(ENOTIMP)
|
|
66
|
+
V(ENOTINITIALIZED)
|
|
67
|
+
V(EOF)
|
|
68
|
+
V(EREFUSED)
|
|
69
|
+
V(ESERVFAIL)
|
|
70
|
+
V(ETIMEOUT)
|
|
71
|
+
#undef V
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return "UNKNOWN_ARES_ERROR";
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
inline void cares_wrap_hostent_cpy(
|
|
78
|
+
struct hostent* dest,
|
|
79
|
+
const struct hostent* src) {
|
|
80
|
+
dest->h_addr_list = nullptr;
|
|
81
|
+
dest->h_addrtype = 0;
|
|
82
|
+
dest->h_aliases = nullptr;
|
|
83
|
+
dest->h_length = 0;
|
|
84
|
+
dest->h_name = nullptr;
|
|
85
|
+
|
|
86
|
+
/* copy `h_name` */
|
|
87
|
+
size_t name_size = strlen(src->h_name) + 1;
|
|
88
|
+
dest->h_name = node::Malloc<char>(name_size);
|
|
89
|
+
memcpy(dest->h_name, src->h_name, name_size);
|
|
90
|
+
|
|
91
|
+
/* copy `h_aliases` */
|
|
92
|
+
size_t alias_count;
|
|
93
|
+
for (alias_count = 0;
|
|
94
|
+
src->h_aliases[alias_count] != nullptr;
|
|
95
|
+
alias_count++) {
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
dest->h_aliases = node::Malloc<char*>(alias_count + 1);
|
|
99
|
+
for (size_t i = 0; i < alias_count; i++) {
|
|
100
|
+
const size_t cur_alias_size = strlen(src->h_aliases[i]) + 1;
|
|
101
|
+
dest->h_aliases[i] = node::Malloc(cur_alias_size);
|
|
102
|
+
memcpy(dest->h_aliases[i], src->h_aliases[i], cur_alias_size);
|
|
103
|
+
}
|
|
104
|
+
dest->h_aliases[alias_count] = nullptr;
|
|
105
|
+
|
|
106
|
+
/* copy `h_addr_list` */
|
|
107
|
+
size_t list_count;
|
|
108
|
+
for (list_count = 0;
|
|
109
|
+
src->h_addr_list[list_count] != nullptr;
|
|
110
|
+
list_count++) {
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
dest->h_addr_list = node::Malloc<char*>(list_count + 1);
|
|
114
|
+
for (size_t i = 0; i < list_count; i++) {
|
|
115
|
+
dest->h_addr_list[i] = node::Malloc(src->h_length);
|
|
116
|
+
memcpy(dest->h_addr_list[i], src->h_addr_list[i], src->h_length);
|
|
117
|
+
}
|
|
118
|
+
dest->h_addr_list[list_count] = nullptr;
|
|
119
|
+
|
|
120
|
+
/* work after work */
|
|
121
|
+
dest->h_length = src->h_length;
|
|
122
|
+
dest->h_addrtype = src->h_addrtype;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
struct NodeAresTask final : public MemoryRetainer {
|
|
127
|
+
ChannelWrap* channel;
|
|
128
|
+
ares_socket_t sock;
|
|
129
|
+
uv_poll_t poll_watcher;
|
|
130
|
+
|
|
131
|
+
inline void MemoryInfo(MemoryTracker* trakcer) const override;
|
|
132
|
+
SET_MEMORY_INFO_NAME(NodeAresTask)
|
|
133
|
+
SET_SELF_SIZE(NodeAresTask)
|
|
134
|
+
|
|
135
|
+
struct Hash {
|
|
136
|
+
inline size_t operator()(NodeAresTask* a) const {
|
|
137
|
+
return std::hash<ares_socket_t>()(a->sock);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
struct Equal {
|
|
142
|
+
inline bool operator()(NodeAresTask* a, NodeAresTask* b) const {
|
|
143
|
+
return a->sock == b->sock;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
static NodeAresTask* Create(ChannelWrap* channel, ares_socket_t sock);
|
|
148
|
+
|
|
149
|
+
using List = std::unordered_set<NodeAresTask*, Hash, Equal>;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
class ChannelWrap final : public AsyncWrap {
|
|
153
|
+
public:
|
|
154
|
+
ChannelWrap(Environment* env,
|
|
155
|
+
v8::Local<v8::Object> object,
|
|
156
|
+
int timeout,
|
|
157
|
+
int tries,
|
|
158
|
+
int max_timeout);
|
|
159
|
+
~ChannelWrap() override;
|
|
160
|
+
|
|
161
|
+
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
162
|
+
|
|
163
|
+
void Setup();
|
|
164
|
+
void EnsureServers();
|
|
165
|
+
void StartTimer();
|
|
166
|
+
void CloseTimer();
|
|
167
|
+
|
|
168
|
+
void ModifyActivityQueryCount(int count);
|
|
169
|
+
|
|
170
|
+
inline uv_timer_t* timer_handle() { return timer_handle_; }
|
|
171
|
+
inline ares_channel cares_channel() { return channel_; }
|
|
172
|
+
inline void set_query_last_ok(bool ok) { query_last_ok_ = ok; }
|
|
173
|
+
inline void set_is_servers_default(bool is_default) {
|
|
174
|
+
is_servers_default_ = is_default;
|
|
175
|
+
}
|
|
176
|
+
inline int active_query_count() { return active_query_count_; }
|
|
177
|
+
inline NodeAresTask::List* task_list() { return &task_list_; }
|
|
178
|
+
|
|
179
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
180
|
+
SET_MEMORY_INFO_NAME(ChannelWrap)
|
|
181
|
+
SET_SELF_SIZE(ChannelWrap)
|
|
182
|
+
|
|
183
|
+
static void AresTimeout(uv_timer_t* handle);
|
|
184
|
+
|
|
185
|
+
private:
|
|
186
|
+
uv_timer_t* timer_handle_ = nullptr;
|
|
187
|
+
ares_channel channel_ = nullptr;
|
|
188
|
+
bool query_last_ok_ = true;
|
|
189
|
+
bool is_servers_default_ = true;
|
|
190
|
+
bool library_inited_ = false;
|
|
191
|
+
int timeout_;
|
|
192
|
+
int tries_;
|
|
193
|
+
int max_timeout_;
|
|
194
|
+
int active_query_count_ = 0;
|
|
195
|
+
NodeAresTask::List task_list_;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
class GetAddrInfoReqWrap final : public ReqWrap<uv_getaddrinfo_t> {
|
|
199
|
+
public:
|
|
200
|
+
GetAddrInfoReqWrap(Environment* env,
|
|
201
|
+
v8::Local<v8::Object> req_wrap_obj,
|
|
202
|
+
uint8_t order);
|
|
203
|
+
|
|
204
|
+
SET_NO_MEMORY_INFO()
|
|
205
|
+
SET_MEMORY_INFO_NAME(GetAddrInfoReqWrap)
|
|
206
|
+
SET_SELF_SIZE(GetAddrInfoReqWrap)
|
|
207
|
+
|
|
208
|
+
uint8_t order() const { return order_; }
|
|
209
|
+
|
|
210
|
+
private:
|
|
211
|
+
const uint8_t order_;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
class GetNameInfoReqWrap final : public ReqWrap<uv_getnameinfo_t> {
|
|
215
|
+
public:
|
|
216
|
+
GetNameInfoReqWrap(Environment* env, v8::Local<v8::Object> req_wrap_obj);
|
|
217
|
+
|
|
218
|
+
SET_NO_MEMORY_INFO()
|
|
219
|
+
SET_MEMORY_INFO_NAME(GetNameInfoReqWrap)
|
|
220
|
+
SET_SELF_SIZE(GetNameInfoReqWrap)
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
struct ResponseData final {
|
|
224
|
+
int status;
|
|
225
|
+
bool is_host;
|
|
226
|
+
SafeHostEntPointer host;
|
|
227
|
+
MallocedBuffer<unsigned char> buf;
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
template <typename Traits>
|
|
231
|
+
class QueryWrap final : public AsyncWrap {
|
|
232
|
+
public:
|
|
233
|
+
QueryWrap(ChannelWrap* channel, v8::Local<v8::Object> req_wrap_obj)
|
|
234
|
+
: AsyncWrap(channel->env(), req_wrap_obj, AsyncWrap::PROVIDER_QUERYWRAP),
|
|
235
|
+
channel_(channel),
|
|
236
|
+
trace_name_(Traits::name) {}
|
|
237
|
+
|
|
238
|
+
~QueryWrap() {
|
|
239
|
+
CHECK_EQ(false, persistent().IsEmpty());
|
|
240
|
+
|
|
241
|
+
// Let Callback() know that this object no longer exists.
|
|
242
|
+
if (callback_ptr_ != nullptr)
|
|
243
|
+
*callback_ptr_ = nullptr;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
int Send(const char* name) {
|
|
247
|
+
return Traits::Send(this, name);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
void AresQuery(const char* name,
|
|
251
|
+
ares_dns_class_t dnsclass,
|
|
252
|
+
ares_dns_rec_type_t type) {
|
|
253
|
+
channel_->EnsureServers();
|
|
254
|
+
TRACE_EVENT_NESTABLE_ASYNC_BEGIN1(
|
|
255
|
+
TRACING_CATEGORY_NODE2(dns, native), trace_name_, this,
|
|
256
|
+
"name", TRACE_STR_COPY(name));
|
|
257
|
+
ares_query_dnsrec(channel_->cares_channel(),
|
|
258
|
+
name,
|
|
259
|
+
dnsclass,
|
|
260
|
+
type,
|
|
261
|
+
Callback,
|
|
262
|
+
MakeCallbackPointer(),
|
|
263
|
+
nullptr);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
void ParseError(int status) {
|
|
267
|
+
CHECK_NE(status, ARES_SUCCESS);
|
|
268
|
+
v8::HandleScope handle_scope(env()->isolate());
|
|
269
|
+
v8::Context::Scope context_scope(env()->context());
|
|
270
|
+
const char* code = ToErrorCodeString(status);
|
|
271
|
+
v8::Local<v8::Value> arg = OneByteString(env()->isolate(), code);
|
|
272
|
+
TRACE_EVENT_NESTABLE_ASYNC_END1(
|
|
273
|
+
TRACING_CATEGORY_NODE2(dns, native), trace_name_, this,
|
|
274
|
+
"error", status);
|
|
275
|
+
MakeCallback(env()->oncomplete_string(), 1, &arg);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const BaseObjectPtr<ChannelWrap>& channel() const { return channel_; }
|
|
279
|
+
|
|
280
|
+
void AfterResponse() {
|
|
281
|
+
CHECK(response_data_);
|
|
282
|
+
|
|
283
|
+
int status = response_data_->status;
|
|
284
|
+
|
|
285
|
+
if (status != ARES_SUCCESS)
|
|
286
|
+
return ParseError(status);
|
|
287
|
+
|
|
288
|
+
if (!Traits::Parse(this, response_data_).To(&status)) {
|
|
289
|
+
return ParseError(ARES_ECANCELLED);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
if (status != ARES_SUCCESS)
|
|
293
|
+
ParseError(status);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
void* MakeCallbackPointer() {
|
|
297
|
+
CHECK_NULL(callback_ptr_);
|
|
298
|
+
callback_ptr_ = new QueryWrap<Traits>*(this);
|
|
299
|
+
return callback_ptr_;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
static QueryWrap<Traits>* FromCallbackPointer(void* arg) {
|
|
303
|
+
std::unique_ptr<QueryWrap<Traits>*> wrap_ptr {
|
|
304
|
+
static_cast<QueryWrap<Traits>**>(arg)
|
|
305
|
+
};
|
|
306
|
+
QueryWrap<Traits>* wrap = *wrap_ptr.get();
|
|
307
|
+
if (wrap == nullptr) return nullptr;
|
|
308
|
+
wrap->callback_ptr_ = nullptr;
|
|
309
|
+
return wrap;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
static void Callback(void* arg,
|
|
313
|
+
ares_status_t status,
|
|
314
|
+
size_t timeouts,
|
|
315
|
+
const ares_dns_record_t* dnsrec) {
|
|
316
|
+
QueryWrap<Traits>* wrap = FromCallbackPointer(arg);
|
|
317
|
+
if (wrap == nullptr) return;
|
|
318
|
+
|
|
319
|
+
unsigned char* buf_copy = nullptr;
|
|
320
|
+
size_t answer_len = 0;
|
|
321
|
+
if (status == ARES_SUCCESS) {
|
|
322
|
+
// No need to explicitly call ares_free_string here,
|
|
323
|
+
// as it is a wrapper around free, which is already
|
|
324
|
+
// invoked when MallocedBuffer is destructed.
|
|
325
|
+
ares_dns_write(dnsrec, &buf_copy, &answer_len);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
wrap->response_data_ = std::make_unique<ResponseData>();
|
|
329
|
+
ResponseData* data = wrap->response_data_.get();
|
|
330
|
+
data->status = status;
|
|
331
|
+
data->is_host = false;
|
|
332
|
+
data->buf = MallocedBuffer<unsigned char>(buf_copy, answer_len);
|
|
333
|
+
|
|
334
|
+
wrap->QueueResponseCallback(status);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
static void Callback(
|
|
338
|
+
void* arg,
|
|
339
|
+
int status,
|
|
340
|
+
int timeouts,
|
|
341
|
+
struct hostent* host) {
|
|
342
|
+
QueryWrap<Traits>* wrap = FromCallbackPointer(arg);
|
|
343
|
+
if (wrap == nullptr) return;
|
|
344
|
+
|
|
345
|
+
struct hostent* host_copy = nullptr;
|
|
346
|
+
if (status == ARES_SUCCESS) {
|
|
347
|
+
host_copy = node::Malloc<hostent>(1);
|
|
348
|
+
cares_wrap_hostent_cpy(host_copy, host);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
wrap->response_data_ = std::make_unique<ResponseData>();
|
|
352
|
+
ResponseData* data = wrap->response_data_.get();
|
|
353
|
+
data->status = status;
|
|
354
|
+
data->host.reset(host_copy);
|
|
355
|
+
data->is_host = true;
|
|
356
|
+
|
|
357
|
+
wrap->QueueResponseCallback(status);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
void QueueResponseCallback(int status) {
|
|
361
|
+
BaseObjectPtr<QueryWrap<Traits>> strong_ref{this};
|
|
362
|
+
env()->SetImmediate([this, strong_ref](Environment*) {
|
|
363
|
+
AfterResponse();
|
|
364
|
+
|
|
365
|
+
// Delete once strong_ref goes out of scope.
|
|
366
|
+
Detach();
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
channel_->set_query_last_ok(status != ARES_ECONNREFUSED);
|
|
370
|
+
channel_->ModifyActivityQueryCount(-1);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
void CallOnComplete(
|
|
374
|
+
v8::Local<v8::Value> answer,
|
|
375
|
+
v8::Local<v8::Value> extra = v8::Local<v8::Value>()) {
|
|
376
|
+
v8::HandleScope handle_scope(env()->isolate());
|
|
377
|
+
v8::Context::Scope context_scope(env()->context());
|
|
378
|
+
v8::Local<v8::Value> argv[] = {
|
|
379
|
+
v8::Integer::New(env()->isolate(), 0),
|
|
380
|
+
answer,
|
|
381
|
+
extra
|
|
382
|
+
};
|
|
383
|
+
const int argc = arraysize(argv) - extra.IsEmpty();
|
|
384
|
+
TRACE_EVENT_NESTABLE_ASYNC_END0(
|
|
385
|
+
TRACING_CATEGORY_NODE2(dns, native), trace_name_, this);
|
|
386
|
+
|
|
387
|
+
MakeCallback(env()->oncomplete_string(), argc, argv);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
void MemoryInfo(MemoryTracker* tracker) const override {
|
|
391
|
+
tracker->TrackField("channel", channel_);
|
|
392
|
+
if (response_data_) {
|
|
393
|
+
tracker->TrackFieldWithSize("response", response_data_->buf.size);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
SET_MEMORY_INFO_NAME(QueryWrap)
|
|
398
|
+
SET_SELF_SIZE(QueryWrap<Traits>)
|
|
399
|
+
|
|
400
|
+
private:
|
|
401
|
+
BaseObjectPtr<ChannelWrap> channel_;
|
|
402
|
+
|
|
403
|
+
std::unique_ptr<ResponseData> response_data_;
|
|
404
|
+
const char* trace_name_;
|
|
405
|
+
// Pointer to pointer to 'this' that can be reset from the destructor,
|
|
406
|
+
// in order to let Callback() know that 'this' no longer exists.
|
|
407
|
+
QueryWrap<Traits>** callback_ptr_ = nullptr;
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
#define QUERY_TYPES(V) \
|
|
411
|
+
V(Reverse, reverse, getHostByAddr) \
|
|
412
|
+
V(A, resolve4, queryA) \
|
|
413
|
+
V(Any, resolveAny, queryAny) \
|
|
414
|
+
V(Aaaa, resolve6, queryAaaa) \
|
|
415
|
+
V(Caa, resolveCaa, queryCaa) \
|
|
416
|
+
V(Cname, resolveCname, queryCname) \
|
|
417
|
+
V(Mx, resolveMx, queryMx) \
|
|
418
|
+
V(Naptr, resolveNaptr, queryNaptr) \
|
|
419
|
+
V(Ns, resolveNs, queryNs) \
|
|
420
|
+
V(Ptr, resolvePtr, queryPtr) \
|
|
421
|
+
V(Srv, resolveSrv, querySrv) \
|
|
422
|
+
V(Soa, resolveSoa, querySoa) \
|
|
423
|
+
V(Tlsa, resolveTlsa, queryTlsa) \
|
|
424
|
+
V(Txt, resolveTxt, queryTxt)
|
|
425
|
+
|
|
426
|
+
// All query type handlers share the same basic structure, so we can simplify
|
|
427
|
+
// the code a bit by using a macro to define that structure.
|
|
428
|
+
#define TYPE_TRAITS(Name, label) \
|
|
429
|
+
struct Name##Traits final { \
|
|
430
|
+
static constexpr const char* name = #label; \
|
|
431
|
+
static int Send(QueryWrap<Name##Traits>* wrap, const char* name); \
|
|
432
|
+
static v8::Maybe<int> Parse( \
|
|
433
|
+
QueryWrap<Name##Traits>* wrap, \
|
|
434
|
+
const std::unique_ptr<ResponseData>& response); \
|
|
435
|
+
}; \
|
|
436
|
+
using Query##Name##Wrap = QueryWrap<Name##Traits>;
|
|
437
|
+
|
|
438
|
+
#define V(NAME, LABEL, _) TYPE_TRAITS(NAME, LABEL)
|
|
439
|
+
QUERY_TYPES(V)
|
|
440
|
+
#undef V
|
|
441
|
+
#undef TYPE_TRAITS
|
|
442
|
+
} // namespace cares_wrap
|
|
443
|
+
} // namespace node
|
|
444
|
+
|
|
445
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
446
|
+
|
|
447
|
+
#endif // SRC_CARES_WRAP_H_
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#ifndef SRC_PERMISSION_CHILD_PROCESS_PERMISSION_H_
|
|
2
|
+
#define SRC_PERMISSION_CHILD_PROCESS_PERMISSION_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include <vector>
|
|
7
|
+
#include "permission/permission_base.h"
|
|
8
|
+
|
|
9
|
+
namespace node {
|
|
10
|
+
|
|
11
|
+
namespace permission {
|
|
12
|
+
|
|
13
|
+
class ChildProcessPermission final : public PermissionBase {
|
|
14
|
+
public:
|
|
15
|
+
void Apply(Environment* env,
|
|
16
|
+
const std::vector<std::string>& allow,
|
|
17
|
+
PermissionScope scope) override;
|
|
18
|
+
bool is_granted(Environment* env,
|
|
19
|
+
PermissionScope perm,
|
|
20
|
+
const std::string_view& param = "") const override;
|
|
21
|
+
|
|
22
|
+
private:
|
|
23
|
+
bool deny_all_;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
} // namespace permission
|
|
27
|
+
|
|
28
|
+
} // namespace node
|
|
29
|
+
|
|
30
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
31
|
+
#endif // SRC_PERMISSION_CHILD_PROCESS_PERMISSION_H_
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
4
|
+
#if HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC
|
|
5
|
+
#include <memory_tracker.h>
|
|
6
|
+
#include <ngtcp2/ngtcp2.h>
|
|
7
|
+
#include <string>
|
|
8
|
+
#include "defs.h"
|
|
9
|
+
|
|
10
|
+
namespace node::quic {
|
|
11
|
+
|
|
12
|
+
// CIDS are used to identify endpoints participating in a QUIC session.
|
|
13
|
+
// Once created, CID instances are immutable.
|
|
14
|
+
//
|
|
15
|
+
// CIDs contain between 1 to 20 bytes. Most typically they are selected
|
|
16
|
+
// randomly but there is a spec for creating "routable" CIDs that encode
|
|
17
|
+
// a specific structure that is meaningful only to the side that creates
|
|
18
|
+
// the CID. For most purposes, CIDs should be treated as opaque tokens.
|
|
19
|
+
//
|
|
20
|
+
// Each peer in a QUIC session generates one or more CIDs that the *other*
|
|
21
|
+
// peer will use to identify the session. When a QUIC client initiates a
|
|
22
|
+
// brand new session, it will initially generates a CID of its own (its
|
|
23
|
+
// source CID) and a random placeholder CID for the server (the original
|
|
24
|
+
// destination CID). When the server receives the initial packet, it will
|
|
25
|
+
// generate its own source CID and use the clients source CID as the
|
|
26
|
+
// server's destination CID.
|
|
27
|
+
//
|
|
28
|
+
// Client Server
|
|
29
|
+
// -------------------------------------------
|
|
30
|
+
// Source CID <====> Destination CID
|
|
31
|
+
// Destination CID <====> Source CID
|
|
32
|
+
//
|
|
33
|
+
// While the connection is being established, it is possible for either
|
|
34
|
+
// peer to generate additional CIDs that are also associated with the
|
|
35
|
+
// connection.
|
|
36
|
+
class CID final : public MemoryRetainer {
|
|
37
|
+
public:
|
|
38
|
+
static constexpr size_t kMinLength = NGTCP2_MIN_CIDLEN;
|
|
39
|
+
static constexpr size_t kMaxLength = NGTCP2_MAX_CIDLEN;
|
|
40
|
+
|
|
41
|
+
// Copy the given ngtcp2_cid.
|
|
42
|
+
explicit CID(const ngtcp2_cid& cid);
|
|
43
|
+
|
|
44
|
+
// Copy the given buffer as a CID. The len must be within
|
|
45
|
+
// kMinLength and kMaxLength.
|
|
46
|
+
explicit CID(const uint8_t* data, size_t len);
|
|
47
|
+
|
|
48
|
+
// Wrap the given ngtcp2_cid. The CID does not take ownership
|
|
49
|
+
// of the underlying ngtcp2_cid.
|
|
50
|
+
explicit CID(const ngtcp2_cid* cid);
|
|
51
|
+
|
|
52
|
+
CID(const CID& other);
|
|
53
|
+
CID& operator=(const CID& other);
|
|
54
|
+
CID(CID&&) = delete;
|
|
55
|
+
|
|
56
|
+
struct Hash final {
|
|
57
|
+
size_t operator()(const CID& cid) const;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
bool operator==(const CID& other) const noexcept;
|
|
61
|
+
bool operator!=(const CID& other) const noexcept;
|
|
62
|
+
|
|
63
|
+
operator const uint8_t*() const;
|
|
64
|
+
operator const ngtcp2_cid&() const;
|
|
65
|
+
operator const ngtcp2_cid*() const;
|
|
66
|
+
|
|
67
|
+
// True if the CID length is at least kMinLength;
|
|
68
|
+
operator bool() const;
|
|
69
|
+
size_t length() const;
|
|
70
|
+
|
|
71
|
+
std::string ToString() const;
|
|
72
|
+
|
|
73
|
+
SET_NO_MEMORY_INFO()
|
|
74
|
+
SET_MEMORY_INFO_NAME(CID)
|
|
75
|
+
SET_SELF_SIZE(CID)
|
|
76
|
+
|
|
77
|
+
template <typename T>
|
|
78
|
+
using Map = std::unordered_map<CID, T, CID::Hash>;
|
|
79
|
+
|
|
80
|
+
// A CID::Factory, as the name suggests, is used to create new CIDs.
|
|
81
|
+
// Per https://datatracker.ietf.org/doc/draft-ietf-quic-load-balancers/, QUIC
|
|
82
|
+
// implementations MAY use the Connection ID associated with a QUIC session
|
|
83
|
+
// as a routing mechanism, with each CID instance securely encoding the
|
|
84
|
+
// routing information. By default, our implementation creates CIDs randomly
|
|
85
|
+
// but will allow user code to provide their own CID::Factory implementation.
|
|
86
|
+
class Factory;
|
|
87
|
+
|
|
88
|
+
static CID kInvalid;
|
|
89
|
+
|
|
90
|
+
// The default constructor creates an empty, zero-length CID.
|
|
91
|
+
// Zero-length CIDs are not usable. We use them as a placeholder
|
|
92
|
+
// for a missing or empty CID value. This is public only because
|
|
93
|
+
// it is required for the CID::Map implementation. It should not
|
|
94
|
+
// be used. Use kInvalid instead.
|
|
95
|
+
CID();
|
|
96
|
+
|
|
97
|
+
private:
|
|
98
|
+
ngtcp2_cid cid_;
|
|
99
|
+
const ngtcp2_cid* ptr_;
|
|
100
|
+
|
|
101
|
+
friend struct Hash;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
class CID::Factory {
|
|
105
|
+
public:
|
|
106
|
+
virtual ~Factory() = default;
|
|
107
|
+
|
|
108
|
+
// Generate a new CID. The length_hint must be between CID::kMinLength
|
|
109
|
+
// and CID::kMaxLength. The implementation can choose to ignore the length.
|
|
110
|
+
virtual CID Generate(size_t length_hint = CID::kMaxLength) const = 0;
|
|
111
|
+
|
|
112
|
+
// Generate a new CID into the given ngtcp2_cid. This variation of
|
|
113
|
+
// Generate should be used far less commonly.
|
|
114
|
+
virtual CID GenerateInto(ngtcp2_cid* cid,
|
|
115
|
+
size_t length_hint = CID::kMaxLength) const = 0;
|
|
116
|
+
|
|
117
|
+
// The default random CID generator instance.
|
|
118
|
+
static const Factory& random();
|
|
119
|
+
|
|
120
|
+
// TODO(@jasnell): This will soon also include additional implementations
|
|
121
|
+
// of CID::Factory that implement the QUIC Load Balancers spec.
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
} // namespace node::quic
|
|
125
|
+
|
|
126
|
+
#endif // HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC
|
|
127
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// This is an auto generated file, please do not edit.
|
|
2
|
+
// Refer to tools/dep_updaters/update-cjs-module-lexer.sh
|
|
3
|
+
#ifndef SRC_CJS_MODULE_LEXER_VERSION_H_
|
|
4
|
+
#define SRC_CJS_MODULE_LEXER_VERSION_H_
|
|
5
|
+
#define CJS_MODULE_LEXER_VERSION "2.1.0"
|
|
6
|
+
#endif // SRC_CJS_MODULE_LEXER_VERSION_H_
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#ifndef SRC_CLEANUP_QUEUE_INL_H_
|
|
2
|
+
#define SRC_CLEANUP_QUEUE_INL_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include "cleanup_queue.h"
|
|
7
|
+
#include "util.h"
|
|
8
|
+
|
|
9
|
+
namespace node {
|
|
10
|
+
|
|
11
|
+
inline size_t CleanupQueue::SelfSize() const {
|
|
12
|
+
return sizeof(CleanupQueue) +
|
|
13
|
+
cleanup_hooks_.size() * sizeof(CleanupHookCallback);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
bool CleanupQueue::empty() const {
|
|
17
|
+
return cleanup_hooks_.empty();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
void CleanupQueue::Add(Callback cb, void* arg) {
|
|
21
|
+
auto insertion_info =
|
|
22
|
+
cleanup_hooks_.emplace(cb, arg, cleanup_hook_counter_++);
|
|
23
|
+
// Make sure there was no existing element with these values.
|
|
24
|
+
CHECK_EQ(insertion_info.second, true);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
void CleanupQueue::Remove(Callback cb, void* arg) {
|
|
28
|
+
CleanupHookCallback search{cb, arg, 0};
|
|
29
|
+
cleanup_hooks_.erase(search);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
} // namespace node
|
|
33
|
+
|
|
34
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
35
|
+
|
|
36
|
+
#endif // SRC_CLEANUP_QUEUE_INL_H_
|