@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,193 @@
|
|
|
1
|
+
#ifndef SRC_DEBUG_UTILS_H_
|
|
2
|
+
#define SRC_DEBUG_UTILS_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include "async_wrap.h"
|
|
7
|
+
#include "util.h"
|
|
8
|
+
|
|
9
|
+
#include <algorithm>
|
|
10
|
+
#include <sstream>
|
|
11
|
+
#include <string>
|
|
12
|
+
|
|
13
|
+
// Use FORCE_INLINE on functions that have a debug-category-enabled check first
|
|
14
|
+
// and then ideally only a single function call following it, to maintain
|
|
15
|
+
// performance for the common case (no debugging used).
|
|
16
|
+
#ifdef __GNUC__
|
|
17
|
+
#define FORCE_INLINE __attribute__((always_inline))
|
|
18
|
+
#define COLD_NOINLINE __attribute__((cold, noinline))
|
|
19
|
+
#else
|
|
20
|
+
#define FORCE_INLINE
|
|
21
|
+
#define COLD_NOINLINE
|
|
22
|
+
#endif
|
|
23
|
+
|
|
24
|
+
namespace node {
|
|
25
|
+
class Environment;
|
|
26
|
+
|
|
27
|
+
template <typename T>
|
|
28
|
+
inline std::string ToString(const T& value);
|
|
29
|
+
|
|
30
|
+
// C++-style variant of sprintf()/fprintf() that:
|
|
31
|
+
// - Returns an std::string
|
|
32
|
+
// - Handles \0 bytes correctly
|
|
33
|
+
// - Supports %p and %s. %d, %i and %u are aliases for %s.
|
|
34
|
+
// - Accepts any class that has a ToString() method for stringification.
|
|
35
|
+
template <typename... Args>
|
|
36
|
+
inline std::string SPrintF(const char* format, Args&&... args);
|
|
37
|
+
template <typename... Args>
|
|
38
|
+
inline void FPrintF(FILE* file, const char* format, Args&&... args);
|
|
39
|
+
void NODE_EXTERN_PRIVATE FWrite(FILE* file, const std::string& str);
|
|
40
|
+
|
|
41
|
+
// Listing the AsyncWrap provider types first enables us to cast directly
|
|
42
|
+
// from a provider type to a debug category.
|
|
43
|
+
#define DEBUG_CATEGORY_NAMES(V) \
|
|
44
|
+
NODE_ASYNC_PROVIDER_TYPES(V) \
|
|
45
|
+
V(COMPILE_CACHE) \
|
|
46
|
+
V(DIAGNOSTICS) \
|
|
47
|
+
V(HUGEPAGES) \
|
|
48
|
+
V(INSPECTOR_SERVER) \
|
|
49
|
+
V(INSPECTOR_CLIENT) \
|
|
50
|
+
V(INSPECTOR_PROFILER) \
|
|
51
|
+
V(CODE_CACHE) \
|
|
52
|
+
V(NGTCP2_DEBUG) \
|
|
53
|
+
V(SEA) \
|
|
54
|
+
V(WASI) \
|
|
55
|
+
V(MODULE) \
|
|
56
|
+
V(MKSNAPSHOT) \
|
|
57
|
+
V(SNAPSHOT_SERDES) \
|
|
58
|
+
V(PERMISSION_MODEL) \
|
|
59
|
+
V(PLATFORM_MINIMAL) \
|
|
60
|
+
V(PLATFORM_VERBOSE) \
|
|
61
|
+
V(QUIC)
|
|
62
|
+
|
|
63
|
+
enum class DebugCategory : unsigned int {
|
|
64
|
+
#define V(name) name,
|
|
65
|
+
DEBUG_CATEGORY_NAMES(V)
|
|
66
|
+
#undef V
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
#define V(name) +1
|
|
70
|
+
constexpr unsigned int kDebugCategoryCount = DEBUG_CATEGORY_NAMES(V);
|
|
71
|
+
#undef V
|
|
72
|
+
|
|
73
|
+
class NODE_EXTERN_PRIVATE EnabledDebugList {
|
|
74
|
+
public:
|
|
75
|
+
bool FORCE_INLINE enabled(DebugCategory category) const {
|
|
76
|
+
DCHECK_LT(static_cast<unsigned int>(category), kDebugCategoryCount);
|
|
77
|
+
return enabled_[static_cast<unsigned int>(category)];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Uses NODE_DEBUG_NATIVE to initialize the categories. env->env_vars()
|
|
81
|
+
// is parsed if it is not a nullptr, otherwise the system environment
|
|
82
|
+
// variables are parsed.
|
|
83
|
+
void Parse(Environment* env);
|
|
84
|
+
|
|
85
|
+
private:
|
|
86
|
+
// Enable all categories matching cats.
|
|
87
|
+
void Parse(const std::string& cats);
|
|
88
|
+
void set_enabled(DebugCategory category) {
|
|
89
|
+
DCHECK_LT(static_cast<unsigned int>(category), kDebugCategoryCount);
|
|
90
|
+
enabled_[static_cast<int>(category)] = true;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
bool enabled_[kDebugCategoryCount] = {false};
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
template <typename... Args>
|
|
97
|
+
inline void FORCE_INLINE Debug(EnabledDebugList* list,
|
|
98
|
+
DebugCategory cat,
|
|
99
|
+
const char* format,
|
|
100
|
+
Args&&... args);
|
|
101
|
+
|
|
102
|
+
inline void FORCE_INLINE Debug(EnabledDebugList* list,
|
|
103
|
+
DebugCategory cat,
|
|
104
|
+
const char* message);
|
|
105
|
+
|
|
106
|
+
template <typename... Args>
|
|
107
|
+
inline void FORCE_INLINE
|
|
108
|
+
Debug(Environment* env, DebugCategory cat, const char* format, Args&&... args);
|
|
109
|
+
|
|
110
|
+
inline void FORCE_INLINE Debug(Environment* env,
|
|
111
|
+
DebugCategory cat,
|
|
112
|
+
const char* message);
|
|
113
|
+
|
|
114
|
+
template <typename... Args>
|
|
115
|
+
inline void Debug(Environment* env,
|
|
116
|
+
DebugCategory cat,
|
|
117
|
+
const std::string& format,
|
|
118
|
+
Args&&... args);
|
|
119
|
+
|
|
120
|
+
// Used internally by the 'real' Debug(AsyncWrap*, ...) functions below, so that
|
|
121
|
+
// the FORCE_INLINE flag on them doesn't apply to the contents of this function
|
|
122
|
+
// as well.
|
|
123
|
+
// We apply COLD_NOINLINE to tell the compiler that it's not worth optimizing
|
|
124
|
+
// this function for speed and it should rather focus on keeping it out of
|
|
125
|
+
// hot code paths. In particular, we want to keep the string concatenating code
|
|
126
|
+
// out of the function containing the original `Debug()` call.
|
|
127
|
+
template <typename... Args>
|
|
128
|
+
void COLD_NOINLINE UnconditionalAsyncWrapDebug(AsyncWrap* async_wrap,
|
|
129
|
+
const char* format,
|
|
130
|
+
Args&&... args);
|
|
131
|
+
|
|
132
|
+
template <typename... Args>
|
|
133
|
+
inline void FORCE_INLINE Debug(AsyncWrap* async_wrap,
|
|
134
|
+
const char* format,
|
|
135
|
+
Args&&... args);
|
|
136
|
+
|
|
137
|
+
template <typename... Args>
|
|
138
|
+
inline void FORCE_INLINE Debug(AsyncWrap* async_wrap,
|
|
139
|
+
const std::string& format,
|
|
140
|
+
Args&&... args);
|
|
141
|
+
|
|
142
|
+
// Debug helper for inspecting the currently running `node` executable.
|
|
143
|
+
class NativeSymbolDebuggingContext {
|
|
144
|
+
public:
|
|
145
|
+
static std::unique_ptr<NativeSymbolDebuggingContext> New();
|
|
146
|
+
|
|
147
|
+
class SymbolInfo {
|
|
148
|
+
public:
|
|
149
|
+
std::string name;
|
|
150
|
+
std::string filename;
|
|
151
|
+
size_t line = 0;
|
|
152
|
+
size_t dis = 0;
|
|
153
|
+
|
|
154
|
+
std::string Display() const;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
NativeSymbolDebuggingContext() = default;
|
|
158
|
+
virtual ~NativeSymbolDebuggingContext() = default;
|
|
159
|
+
|
|
160
|
+
virtual SymbolInfo LookupSymbol(void* address) { return {}; }
|
|
161
|
+
virtual bool IsMapped(void* address) { return false; }
|
|
162
|
+
virtual int GetStackTrace(void** frames, int count) { return 0; }
|
|
163
|
+
|
|
164
|
+
NativeSymbolDebuggingContext(const NativeSymbolDebuggingContext&) = delete;
|
|
165
|
+
NativeSymbolDebuggingContext(NativeSymbolDebuggingContext&&) = delete;
|
|
166
|
+
NativeSymbolDebuggingContext operator=(NativeSymbolDebuggingContext&)
|
|
167
|
+
= delete;
|
|
168
|
+
NativeSymbolDebuggingContext operator=(NativeSymbolDebuggingContext&&)
|
|
169
|
+
= delete;
|
|
170
|
+
static std::vector<std::string> GetLoadedLibraries();
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
// Variant of `uv_loop_close` that tries to be as helpful as possible
|
|
174
|
+
// about giving information on currently existing handles, if there are any,
|
|
175
|
+
// but still aborts the process.
|
|
176
|
+
void CheckedUvLoopClose(uv_loop_t* loop);
|
|
177
|
+
void PrintLibuvHandleInformation(uv_loop_t* loop, FILE* stream);
|
|
178
|
+
|
|
179
|
+
namespace per_process {
|
|
180
|
+
extern NODE_EXTERN_PRIVATE EnabledDebugList enabled_debug_list;
|
|
181
|
+
|
|
182
|
+
template <typename... Args>
|
|
183
|
+
inline void FORCE_INLINE Debug(DebugCategory cat,
|
|
184
|
+
const char* format,
|
|
185
|
+
Args&&... args);
|
|
186
|
+
|
|
187
|
+
inline void FORCE_INLINE Debug(DebugCategory cat, const char* message);
|
|
188
|
+
} // namespace per_process
|
|
189
|
+
} // namespace node
|
|
190
|
+
|
|
191
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
192
|
+
|
|
193
|
+
#endif // SRC_DEBUG_UTILS_H_
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <aliased_struct.h>
|
|
4
|
+
#include <env.h>
|
|
5
|
+
#include <nghttp3/nghttp3.h>
|
|
6
|
+
#include <ngtcp2/ngtcp2.h>
|
|
7
|
+
#include <node_errors.h>
|
|
8
|
+
#include <uv.h>
|
|
9
|
+
#include <v8.h>
|
|
10
|
+
#include <limits>
|
|
11
|
+
|
|
12
|
+
namespace node::quic {
|
|
13
|
+
|
|
14
|
+
#define NGTCP2_SUCCESS 0
|
|
15
|
+
#define NGTCP2_ERR(V) (V != NGTCP2_SUCCESS)
|
|
16
|
+
#define NGTCP2_OK(V) (V == NGTCP2_SUCCESS)
|
|
17
|
+
|
|
18
|
+
#define IF_QUIC_DEBUG(env) \
|
|
19
|
+
if (env->enabled_debug_list()->enabled(DebugCategory::QUIC)) [[unlikely]]
|
|
20
|
+
|
|
21
|
+
#define DISALLOW_COPY(Name) \
|
|
22
|
+
Name(const Name&) = delete; \
|
|
23
|
+
Name& operator=(const Name&) = delete;
|
|
24
|
+
|
|
25
|
+
#define DISALLOW_MOVE(Name) \
|
|
26
|
+
Name(Name&&) = delete; \
|
|
27
|
+
Name& operator=(Name&&) = delete;
|
|
28
|
+
|
|
29
|
+
#define DISALLOW_COPY_AND_MOVE(Name) \
|
|
30
|
+
DISALLOW_COPY(Name) \
|
|
31
|
+
DISALLOW_MOVE(Name)
|
|
32
|
+
|
|
33
|
+
template <typename Opt, std::string Opt::*member>
|
|
34
|
+
bool SetOption(Environment* env,
|
|
35
|
+
Opt* options,
|
|
36
|
+
const v8::Local<v8::Object>& object,
|
|
37
|
+
const v8::Local<v8::String>& name) {
|
|
38
|
+
v8::Local<v8::Value> value;
|
|
39
|
+
if (!object->Get(env->context(), name).ToLocal(&value)) return false;
|
|
40
|
+
if (!value->IsUndefined()) {
|
|
41
|
+
Utf8Value utf8(env->isolate(), value);
|
|
42
|
+
options->*member = *utf8;
|
|
43
|
+
}
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
template <typename Opt, bool Opt::*member>
|
|
48
|
+
bool SetOption(Environment* env,
|
|
49
|
+
Opt* options,
|
|
50
|
+
const v8::Local<v8::Object>& object,
|
|
51
|
+
const v8::Local<v8::String>& name) {
|
|
52
|
+
v8::Local<v8::Value> value;
|
|
53
|
+
if (!object->Get(env->context(), name).ToLocal(&value)) return false;
|
|
54
|
+
if (!value->IsUndefined()) {
|
|
55
|
+
options->*member = value->BooleanValue(env->isolate());
|
|
56
|
+
}
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
template <typename Opt, uint32_t Opt::*member>
|
|
61
|
+
bool SetOption(Environment* env,
|
|
62
|
+
Opt* options,
|
|
63
|
+
const v8::Local<v8::Object>& object,
|
|
64
|
+
const v8::Local<v8::String>& name) {
|
|
65
|
+
v8::Local<v8::Value> value;
|
|
66
|
+
if (!object->Get(env->context(), name).ToLocal(&value)) return false;
|
|
67
|
+
if (!value->IsUndefined()) {
|
|
68
|
+
if (!value->IsUint32()) {
|
|
69
|
+
Utf8Value nameStr(env->isolate(), name);
|
|
70
|
+
THROW_ERR_INVALID_ARG_VALUE(
|
|
71
|
+
env, "The %s option must be an uint32", *nameStr);
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
v8::Local<v8::Uint32> num;
|
|
75
|
+
if (!value->ToUint32(env->context()).ToLocal(&num)) {
|
|
76
|
+
Utf8Value nameStr(env->isolate(), name);
|
|
77
|
+
THROW_ERR_INVALID_ARG_VALUE(
|
|
78
|
+
env, "The %s option must be an uint32", *nameStr);
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
options->*member = num->Value();
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
template <typename Opt, uint64_t Opt::*member>
|
|
87
|
+
bool SetOption(Environment* env,
|
|
88
|
+
Opt* options,
|
|
89
|
+
const v8::Local<v8::Object>& object,
|
|
90
|
+
const v8::Local<v8::String>& name) {
|
|
91
|
+
v8::Local<v8::Value> value;
|
|
92
|
+
if (!object->Get(env->context(), name).ToLocal(&value)) return false;
|
|
93
|
+
|
|
94
|
+
if (!value->IsUndefined()) {
|
|
95
|
+
if (!value->IsBigInt() && !value->IsNumber()) {
|
|
96
|
+
Utf8Value nameStr(env->isolate(), name);
|
|
97
|
+
THROW_ERR_INVALID_ARG_VALUE(
|
|
98
|
+
env, "option %s must be a bigint or number", *nameStr);
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
DCHECK_IMPLIES(!value->IsBigInt(), value->IsNumber());
|
|
102
|
+
|
|
103
|
+
uint64_t val = 0;
|
|
104
|
+
if (value->IsBigInt()) {
|
|
105
|
+
bool lossless = true;
|
|
106
|
+
val = value.As<v8::BigInt>()->Uint64Value(&lossless);
|
|
107
|
+
if (!lossless) {
|
|
108
|
+
Utf8Value label(env->isolate(), name);
|
|
109
|
+
THROW_ERR_INVALID_ARG_VALUE(env, "option %s is out of range", *label);
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
double dbl = value.As<v8::Number>()->Value();
|
|
114
|
+
if (dbl < 0) {
|
|
115
|
+
Utf8Value label(env->isolate(), name);
|
|
116
|
+
THROW_ERR_INVALID_ARG_VALUE(env, "option %s is out of range", *label);
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
val = static_cast<uint64_t>(dbl);
|
|
120
|
+
}
|
|
121
|
+
options->*member = val;
|
|
122
|
+
}
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Utilities used to update the stats for Endpoint, Session, and Stream
|
|
127
|
+
// objects. The stats themselves are maintained in an AliasedStruct within
|
|
128
|
+
// each of the relevant classes.
|
|
129
|
+
|
|
130
|
+
template <typename Stats, uint64_t Stats::*member>
|
|
131
|
+
void IncrementStat(Stats* stats, uint64_t amt = 1) {
|
|
132
|
+
stats->*member += amt;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
template <typename Stats, uint64_t Stats::*member>
|
|
136
|
+
void RecordTimestampStat(Stats* stats) {
|
|
137
|
+
stats->*member = uv_hrtime();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
template <typename Stats, uint64_t Stats::*member>
|
|
141
|
+
void SetStat(Stats* stats, uint64_t val) {
|
|
142
|
+
stats->*member = val;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
template <typename Stats, uint64_t Stats::*member>
|
|
146
|
+
uint64_t GetStat(Stats* stats) {
|
|
147
|
+
return stats->*member;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
#define STAT_INCREMENT(Type, name) \
|
|
151
|
+
IncrementStat<Type, &Type::name>(stats_.Data());
|
|
152
|
+
#define STAT_INCREMENT_N(Type, name, amt) \
|
|
153
|
+
IncrementStat<Type, &Type::name>(stats_.Data(), amt);
|
|
154
|
+
#define STAT_RECORD_TIMESTAMP(Type, name) \
|
|
155
|
+
RecordTimestampStat<Type, &Type::name>(stats_.Data());
|
|
156
|
+
#define STAT_SET(Type, name, val) SetStat<Type, &Type::name>(stats_.Data(), val)
|
|
157
|
+
#define STAT_GET(Type, name) GetStat<Type, &Type::name>(stats_.Data())
|
|
158
|
+
#define STAT_FIELD(_, name) uint64_t name;
|
|
159
|
+
#define STAT_STRUCT(klass, name) \
|
|
160
|
+
struct klass::Stats final { \
|
|
161
|
+
name##_STATS(STAT_FIELD) \
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
#define JS_METHOD(name) \
|
|
165
|
+
static void name(const v8::FunctionCallbackInfo<v8::Value>& args)
|
|
166
|
+
|
|
167
|
+
enum class Side : uint8_t {
|
|
168
|
+
CLIENT,
|
|
169
|
+
SERVER,
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
enum class EndpointLabel : uint8_t {
|
|
173
|
+
LOCAL,
|
|
174
|
+
REMOTE,
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
enum class Direction : uint8_t {
|
|
178
|
+
BIDIRECTIONAL,
|
|
179
|
+
UNIDIRECTIONAL,
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
enum class HeadersKind : uint8_t {
|
|
183
|
+
HINTS,
|
|
184
|
+
INITIAL,
|
|
185
|
+
TRAILING,
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
enum class HeadersFlags : uint8_t {
|
|
189
|
+
NONE,
|
|
190
|
+
TERMINAL,
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
enum class StreamPriority : uint8_t {
|
|
194
|
+
DEFAULT = NGHTTP3_DEFAULT_URGENCY,
|
|
195
|
+
LOW = NGHTTP3_URGENCY_LOW,
|
|
196
|
+
HIGH = NGHTTP3_URGENCY_HIGH,
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
enum class StreamPriorityFlags : uint8_t {
|
|
200
|
+
NONE,
|
|
201
|
+
NON_INCREMENTAL,
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
enum class PathValidationResult : uint8_t {
|
|
205
|
+
SUCCESS = NGTCP2_PATH_VALIDATION_RESULT_SUCCESS,
|
|
206
|
+
FAILURE = NGTCP2_PATH_VALIDATION_RESULT_FAILURE,
|
|
207
|
+
ABORTED = NGTCP2_PATH_VALIDATION_RESULT_ABORTED,
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
enum class DatagramStatus : uint8_t {
|
|
211
|
+
ACKNOWLEDGED,
|
|
212
|
+
LOST,
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
#define CC_ALGOS(V) \
|
|
216
|
+
V(RENO, reno) \
|
|
217
|
+
V(CUBIC, cubic) \
|
|
218
|
+
V(BBR, bbr)
|
|
219
|
+
|
|
220
|
+
#define V(name, _) static constexpr auto CC_ALGO_##name = NGTCP2_CC_ALGO_##name;
|
|
221
|
+
CC_ALGOS(V)
|
|
222
|
+
#undef V
|
|
223
|
+
|
|
224
|
+
constexpr uint64_t NGTCP2_APP_NOERROR = 65280;
|
|
225
|
+
constexpr size_t kDefaultMaxPacketLength = NGTCP2_MAX_UDP_PAYLOAD_SIZE;
|
|
226
|
+
constexpr size_t kMaxSizeT = std::numeric_limits<size_t>::max();
|
|
227
|
+
constexpr uint64_t kMaxSafeJsInteger = 9007199254740991;
|
|
228
|
+
constexpr auto kSocketAddressInfoTimeout = 60 * NGTCP2_SECONDS;
|
|
229
|
+
constexpr size_t kMaxVectorCount = 16;
|
|
230
|
+
|
|
231
|
+
using error_code = uint64_t;
|
|
232
|
+
|
|
233
|
+
class DebugIndentScope {
|
|
234
|
+
public:
|
|
235
|
+
inline DebugIndentScope() { ++indent_; }
|
|
236
|
+
DISALLOW_COPY_AND_MOVE(DebugIndentScope)
|
|
237
|
+
inline ~DebugIndentScope() { --indent_; }
|
|
238
|
+
inline std::string Prefix() const {
|
|
239
|
+
std::string res("\n");
|
|
240
|
+
res.append(indent_, '\t');
|
|
241
|
+
return res;
|
|
242
|
+
}
|
|
243
|
+
inline std::string Close() const {
|
|
244
|
+
std::string res("\n");
|
|
245
|
+
res.append(indent_ - 1, '\t');
|
|
246
|
+
res += "}";
|
|
247
|
+
return res;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
private:
|
|
251
|
+
static int indent_;
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
} // namespace node::quic
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#ifndef SRC_DIAGNOSTICFILENAME_INL_H_
|
|
2
|
+
#define SRC_DIAGNOSTICFILENAME_INL_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include "node_internals.h"
|
|
7
|
+
namespace node {
|
|
8
|
+
|
|
9
|
+
class Environment;
|
|
10
|
+
|
|
11
|
+
inline DiagnosticFilename::DiagnosticFilename(
|
|
12
|
+
Environment* env,
|
|
13
|
+
const char* prefix,
|
|
14
|
+
const char* ext) :
|
|
15
|
+
filename_(MakeFilename(env->thread_id(), prefix, ext)) {
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
inline DiagnosticFilename::DiagnosticFilename(
|
|
19
|
+
uint64_t thread_id,
|
|
20
|
+
const char* prefix,
|
|
21
|
+
const char* ext) :
|
|
22
|
+
filename_(MakeFilename(thread_id, prefix, ext)) {
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
inline const char* DiagnosticFilename::operator*() const {
|
|
26
|
+
return filename_.c_str();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
} // namespace node
|
|
30
|
+
|
|
31
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
32
|
+
|
|
33
|
+
#endif // SRC_DIAGNOSTICFILENAME_INL_H_
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#ifndef SRC_EMBEDDED_DATA_H_
|
|
2
|
+
#define SRC_EMBEDDED_DATA_H_
|
|
3
|
+
|
|
4
|
+
#include <cinttypes>
|
|
5
|
+
#include <string>
|
|
6
|
+
|
|
7
|
+
// This file must not depend on node.h or other code that depends on
|
|
8
|
+
// the full Node.js implementation because it is used during the
|
|
9
|
+
// compilation of the Node.js implementation itself (especially js2c).
|
|
10
|
+
|
|
11
|
+
namespace node {
|
|
12
|
+
|
|
13
|
+
const std::string& GetOctalCode(uint8_t index);
|
|
14
|
+
|
|
15
|
+
} // namespace node
|
|
16
|
+
|
|
17
|
+
#endif // SRC_EMBEDDED_DATA_H_
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#ifndef SRC_ENCODING_BINDING_H_
|
|
2
|
+
#define SRC_ENCODING_BINDING_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include <cinttypes>
|
|
7
|
+
#include "aliased_buffer.h"
|
|
8
|
+
#include "node_snapshotable.h"
|
|
9
|
+
#include "v8-fast-api-calls.h"
|
|
10
|
+
|
|
11
|
+
namespace node {
|
|
12
|
+
class ExternalReferenceRegistry;
|
|
13
|
+
|
|
14
|
+
namespace encoding_binding {
|
|
15
|
+
class BindingData : public SnapshotableObject {
|
|
16
|
+
public:
|
|
17
|
+
struct InternalFieldInfo : public node::InternalFieldInfoBase {
|
|
18
|
+
AliasedBufferIndex encode_into_results_buffer;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
BindingData(Realm* realm,
|
|
22
|
+
v8::Local<v8::Object> obj,
|
|
23
|
+
InternalFieldInfo* info = nullptr);
|
|
24
|
+
SERIALIZABLE_OBJECT_METHODS()
|
|
25
|
+
SET_BINDING_ID(encoding_binding_data)
|
|
26
|
+
|
|
27
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
28
|
+
SET_SELF_SIZE(BindingData)
|
|
29
|
+
SET_MEMORY_INFO_NAME(BindingData)
|
|
30
|
+
|
|
31
|
+
static void EncodeInto(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
32
|
+
static void EncodeUtf8String(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
33
|
+
static void DecodeUTF8(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
34
|
+
static void DecodeLatin1(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
35
|
+
|
|
36
|
+
static void ToASCII(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
37
|
+
static void ToUnicode(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
38
|
+
|
|
39
|
+
static void CreatePerIsolateProperties(IsolateData* isolate_data,
|
|
40
|
+
v8::Local<v8::ObjectTemplate> target);
|
|
41
|
+
static void CreatePerContextProperties(v8::Local<v8::Object> target,
|
|
42
|
+
v8::Local<v8::Value> unused,
|
|
43
|
+
v8::Local<v8::Context> context,
|
|
44
|
+
void* priv);
|
|
45
|
+
static void RegisterTimerExternalReferences(
|
|
46
|
+
ExternalReferenceRegistry* registry);
|
|
47
|
+
|
|
48
|
+
private:
|
|
49
|
+
static constexpr size_t kEncodeIntoResultsLength = 2;
|
|
50
|
+
AliasedUint32Array encode_into_results_buffer_;
|
|
51
|
+
InternalFieldInfo* internal_field_info_ = nullptr;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
} // namespace encoding_binding
|
|
55
|
+
|
|
56
|
+
} // namespace node
|
|
57
|
+
|
|
58
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
59
|
+
|
|
60
|
+
#endif // SRC_ENCODING_BINDING_H_
|