@push.rocks/smartnetwork 4.10.0 → 5.0.0
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/.smartconfig.json +19 -8
- package/dist_rust/rustnetwork_linux_amd64_musl +0 -0
- package/dist_rust/rustnetwork_linux_amd64_musl.tsrust-build.json +14 -0
- package/dist_rust/rustnetwork_linux_arm64_musl +0 -0
- package/dist_rust/rustnetwork_linux_arm64_musl.tsrust-build.json +14 -0
- package/dist_ts/00_commitinfo_data.js +2 -2
- package/dist_ts/index.d.ts +1 -1
- package/dist_ts/smartnetwork.classes.domainintelligence.d.ts +10 -4
- package/dist_ts/smartnetwork.classes.domainintelligence.js +69 -39
- package/dist_ts/smartnetwork.classes.ipintelligence.d.ts +8 -2
- package/dist_ts/smartnetwork.classes.ipintelligence.js +67 -37
- package/dist_ts/smartnetwork.classes.rustbridge.d.ts +12 -8
- package/dist_ts/smartnetwork.classes.rustbridge.js +82 -32
- package/dist_ts/smartnetwork.classes.smartnetwork.d.ts +46 -8
- package/dist_ts/smartnetwork.classes.smartnetwork.js +165 -84
- package/native-notices/crates/aho-corasick-1.1.4/copying +3 -0
- package/native-notices/crates/aho-corasick-1.1.4/license-mit +21 -0
- package/native-notices/crates/aho-corasick-1.1.4/unlicense +24 -0
- package/native-notices/crates/anstream-1.0.0/license-apache +202 -0
- package/native-notices/crates/anstream-1.0.0/license-mit +19 -0
- package/native-notices/crates/anstyle-1.0.14/license-apache +202 -0
- package/native-notices/crates/anstyle-1.0.14/license-mit +19 -0
- package/native-notices/crates/anstyle-parse-1.0.0/license-apache +202 -0
- package/native-notices/crates/anstyle-parse-1.0.0/license-mit +19 -0
- package/native-notices/crates/anstyle-query-1.1.5/license-apache +202 -0
- package/native-notices/crates/anstyle-query-1.1.5/license-mit +19 -0
- package/native-notices/crates/bytes-1.11.1/license +25 -0
- package/native-notices/crates/cfg-if-1.0.4/license-apache +201 -0
- package/native-notices/crates/cfg-if-1.0.4/license-mit +25 -0
- package/native-notices/crates/clap-4.6.1/license-apache +202 -0
- package/native-notices/crates/clap-4.6.1/license-mit +19 -0
- package/native-notices/crates/clap_builder-4.6.0/license-apache +202 -0
- package/native-notices/crates/clap_builder-4.6.0/license-mit +19 -0
- package/native-notices/crates/clap_derive-4.6.1/license-apache +202 -0
- package/native-notices/crates/clap_derive-4.6.1/license-mit +19 -0
- package/native-notices/crates/clap_lex-1.1.0/license-apache +202 -0
- package/native-notices/crates/clap_lex-1.1.0/license-mit +19 -0
- package/native-notices/crates/colorchoice-1.0.5/license-apache +202 -0
- package/native-notices/crates/colorchoice-1.0.5/license-mit +19 -0
- package/native-notices/crates/errno-0.3.14/license-apache +201 -0
- package/native-notices/crates/errno-0.3.14/license-mit +25 -0
- package/native-notices/crates/getrandom-0.3.4/license-apache +201 -0
- package/native-notices/crates/getrandom-0.3.4/license-mit +26 -0
- package/native-notices/crates/glob-0.3.3/license-apache +201 -0
- package/native-notices/crates/glob-0.3.3/license-mit +25 -0
- package/native-notices/crates/heck-0.5.0/license-apache +201 -0
- package/native-notices/crates/heck-0.5.0/license-mit +25 -0
- package/native-notices/crates/hex-0.4.3/license-apache +202 -0
- package/native-notices/crates/hex-0.4.3/license-mit +20 -0
- package/native-notices/crates/is_terminal_polyfill-1.70.2/license-apache +202 -0
- package/native-notices/crates/is_terminal_polyfill-1.70.2/license-mit +19 -0
- package/native-notices/crates/itoa-1.0.18/license-apache +176 -0
- package/native-notices/crates/itoa-1.0.18/license-mit +23 -0
- package/native-notices/crates/lazy_static-1.5.0/license-apache +201 -0
- package/native-notices/crates/lazy_static-1.5.0/license-mit +25 -0
- package/native-notices/crates/libc-0.2.186/license-apache +176 -0
- package/native-notices/crates/libc-0.2.186/license-mit +25 -0
- package/native-notices/crates/lock_api-0.4.14/license-apache +201 -0
- package/native-notices/crates/lock_api-0.4.14/license-mit +25 -0
- package/native-notices/crates/log-0.4.29/license-apache +201 -0
- package/native-notices/crates/log-0.4.29/license-mit +25 -0
- package/native-notices/crates/matchers-0.2.0/license +19 -0
- package/native-notices/crates/memchr-2.8.0/copying +3 -0
- package/native-notices/crates/memchr-2.8.0/license-mit +21 -0
- package/native-notices/crates/memchr-2.8.0/unlicense +24 -0
- package/native-notices/crates/mio-1.2.0/license +19 -0
- package/native-notices/crates/no-std-net-0.6.0/license +21 -0
- package/native-notices/crates/nu-ansi-term-0.50.3/license +22 -0
- package/native-notices/crates/once_cell-1.21.4/license-apache +201 -0
- package/native-notices/crates/once_cell-1.21.4/license-mit +23 -0
- package/native-notices/crates/parking_lot-0.12.5/license-apache +201 -0
- package/native-notices/crates/parking_lot-0.12.5/license-mit +25 -0
- package/native-notices/crates/parking_lot_core-0.9.12/license-apache +201 -0
- package/native-notices/crates/parking_lot_core-0.9.12/license-mit +25 -0
- package/native-notices/crates/pin-project-lite-0.2.17/license-apache +177 -0
- package/native-notices/crates/pin-project-lite-0.2.17/license-mit +23 -0
- package/native-notices/crates/pnet_base-0.34.0/license-apache +201 -0
- package/native-notices/crates/pnet_base-0.34.0/license-mit +25 -0
- package/native-notices/crates/pnet_macros-0.34.0/license-apache +201 -0
- package/native-notices/crates/pnet_macros-0.34.0/license-mit +25 -0
- package/native-notices/crates/pnet_macros_support-0.34.0/license-apache +201 -0
- package/native-notices/crates/pnet_macros_support-0.34.0/license-mit +25 -0
- package/native-notices/crates/pnet_packet-0.34.0/license-apache +201 -0
- package/native-notices/crates/pnet_packet-0.34.0/license-mit +25 -0
- package/native-notices/crates/ppv-lite86-0.2.21/license-apache +201 -0
- package/native-notices/crates/ppv-lite86-0.2.21/license-mit +25 -0
- package/native-notices/crates/proc-macro2-1.0.106/license-apache +176 -0
- package/native-notices/crates/proc-macro2-1.0.106/license-mit +23 -0
- package/native-notices/crates/quote-1.0.45/license-apache +176 -0
- package/native-notices/crates/quote-1.0.45/license-mit +23 -0
- package/native-notices/crates/rand-0.9.4/copyright +12 -0
- package/native-notices/crates/rand-0.9.4/license-apache +176 -0
- package/native-notices/crates/rand-0.9.4/license-mit +26 -0
- package/native-notices/crates/rand_chacha-0.9.0/copyright +12 -0
- package/native-notices/crates/rand_chacha-0.9.0/license-apache +176 -0
- package/native-notices/crates/rand_chacha-0.9.0/license-mit +26 -0
- package/native-notices/crates/rand_core-0.9.5/copyright +12 -0
- package/native-notices/crates/rand_core-0.9.5/license-apache +187 -0
- package/native-notices/crates/rand_core-0.9.5/license-mit +26 -0
- package/native-notices/crates/regex-1.12.3/license-apache +201 -0
- package/native-notices/crates/regex-1.12.3/license-mit +25 -0
- package/native-notices/crates/regex-automata-0.4.14/license-apache +201 -0
- package/native-notices/crates/regex-automata-0.4.14/license-mit +25 -0
- package/native-notices/crates/regex-syntax-0.8.10/license-apache +201 -0
- package/native-notices/crates/regex-syntax-0.8.10/license-mit +25 -0
- package/native-notices/crates/scopeguard-1.2.0/license-apache +201 -0
- package/native-notices/crates/scopeguard-1.2.0/license-mit +25 -0
- package/native-notices/crates/serde-1.0.228/license-apache +176 -0
- package/native-notices/crates/serde-1.0.228/license-mit +23 -0
- package/native-notices/crates/serde_core-1.0.228/license-apache +176 -0
- package/native-notices/crates/serde_core-1.0.228/license-mit +23 -0
- package/native-notices/crates/serde_derive-1.0.228/license-apache +176 -0
- package/native-notices/crates/serde_derive-1.0.228/license-mit +23 -0
- package/native-notices/crates/serde_json-1.0.149/license-apache +176 -0
- package/native-notices/crates/serde_json-1.0.149/license-mit +23 -0
- package/native-notices/crates/sharded-slab-0.1.7/license +19 -0
- package/native-notices/crates/signal-hook-registry-1.4.8/license-apache +201 -0
- package/native-notices/crates/signal-hook-registry-1.4.8/license-mit +25 -0
- package/native-notices/crates/smallvec-1.15.1/license-apache +201 -0
- package/native-notices/crates/smallvec-1.15.1/license-mit +25 -0
- package/native-notices/crates/socket2-0.5.10/license-apache +201 -0
- package/native-notices/crates/socket2-0.5.10/license-mit +25 -0
- package/native-notices/crates/socket2-0.6.3/license-apache +201 -0
- package/native-notices/crates/socket2-0.6.3/license-mit +25 -0
- package/native-notices/crates/strsim-0.11.1/license +23 -0
- package/native-notices/crates/surge-ping-0.8.4/license +21 -0
- package/native-notices/crates/syn-2.0.117/license-apache +176 -0
- package/native-notices/crates/syn-2.0.117/license-mit +23 -0
- package/native-notices/crates/thiserror-1.0.69/license-apache +176 -0
- package/native-notices/crates/thiserror-1.0.69/license-mit +23 -0
- package/native-notices/crates/thiserror-impl-1.0.69/license-apache +176 -0
- package/native-notices/crates/thiserror-impl-1.0.69/license-mit +23 -0
- package/native-notices/crates/thread_local-1.1.9/license-apache +201 -0
- package/native-notices/crates/thread_local-1.1.9/license-mit +25 -0
- package/native-notices/crates/tokio-1.52.3/license +21 -0
- package/native-notices/crates/tokio-macros-2.7.0/license +22 -0
- package/native-notices/crates/tracing-0.1.44/license +25 -0
- package/native-notices/crates/tracing-attributes-0.1.31/license +25 -0
- package/native-notices/crates/tracing-core-0.1.36/license +25 -0
- package/native-notices/crates/tracing-log-0.2.0/license +25 -0
- package/native-notices/crates/tracing-subscriber-0.3.23/license +25 -0
- package/native-notices/crates/unicode-ident-1.0.24/license-apache +176 -0
- package/native-notices/crates/unicode-ident-1.0.24/license-mit +23 -0
- package/native-notices/crates/unicode-ident-1.0.24/license-unicode +39 -0
- package/native-notices/crates/utf8parse-0.2.2/license-apache +176 -0
- package/native-notices/crates/utf8parse-0.2.2/license-mit +25 -0
- package/native-notices/crates/zerocopy-0.8.48/license-apache +202 -0
- package/native-notices/crates/zerocopy-0.8.48/license-bsd +24 -0
- package/native-notices/crates/zerocopy-0.8.48/license-mit +26 -0
- package/native-notices/crates/zmij-1.0.21/license-mit +23 -0
- package/native-notices/manifest.json +1890 -0
- package/native-notices/readme.md +42 -0
- package/native-notices/runtime/gcc/gpl-3.0.txt +674 -0
- package/native-notices/runtime/gcc/runtime-library-exception-3.1.txt +73 -0
- package/native-notices/runtime/musl-1.2.5/copyright +193 -0
- package/native-notices/rust/compiler-builtins-license.txt +275 -0
- package/native-notices/rust/copyright-library.html +8266 -0
- package/native-notices/rust/crates/addr2line-0.25.1/license-apache +201 -0
- package/native-notices/rust/crates/addr2line-0.25.1/license-mit +25 -0
- package/native-notices/rust/crates/adler2-2.0.1/license-0bsd +12 -0
- package/native-notices/rust/crates/adler2-2.0.1/license-apache +201 -0
- package/native-notices/rust/crates/adler2-2.0.1/license-mit +23 -0
- package/native-notices/rust/crates/memchr-2.7.6/copying +3 -0
- package/native-notices/rust/crates/memchr-2.7.6/license-mit +21 -0
- package/native-notices/rust/crates/memchr-2.7.6/unlicense +24 -0
- package/native-notices/rust/crates/miniz_oxide-0.8.9/license +25 -0
- package/native-notices/rust/crates/miniz_oxide-0.8.9/license-apache.md +177 -0
- package/native-notices/rust/crates/miniz_oxide-0.8.9/license-mit.md +24 -0
- package/native-notices/rust/crates/miniz_oxide-0.8.9/license-zlib.md +14 -0
- package/native-notices/rust/crates/object-0.37.3/license-apache +201 -0
- package/native-notices/rust/crates/object-0.37.3/license-mit +25 -0
- package/native-notices/rust/licenses/apache-2.0.txt +73 -0
- package/native-notices/rust/licenses/bsd-2-clause.txt +9 -0
- package/native-notices/rust/licenses/cc-by-sa-4.0.txt +427 -0
- package/native-notices/rust/licenses/gcc-exception-3.1.txt +30 -0
- package/native-notices/rust/licenses/gpl-2.0-only.txt +133 -0
- package/native-notices/rust/licenses/gpl-3.0-or-later.txt +202 -0
- package/native-notices/rust/licenses/isc.txt +7 -0
- package/native-notices/rust/licenses/llvm-exception.txt +15 -0
- package/native-notices/rust/licenses/mit.txt +9 -0
- package/native-notices/rust/licenses/ncsa.txt +29 -0
- package/native-notices/rust/licenses/ofl-1.1.txt +43 -0
- package/native-notices/rust/licenses/unicode-3.0.txt +39 -0
- package/package.json +18 -9
- package/readme.md +56 -13
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/index.ts +1 -1
- package/ts/smartnetwork.classes.domainintelligence.ts +73 -40
- package/ts/smartnetwork.classes.ipintelligence.ts +71 -37
- package/ts/smartnetwork.classes.rustbridge.ts +83 -34
- package/ts/smartnetwork.classes.smartnetwork.ts +208 -89
- package/dist_rust/rustnetwork_linux_amd64 +0 -0
- package/dist_rust/rustnetwork_linux_arm64 +0 -0
- package/readme.hints.md +0 -106
- package/ts/tsconfig.json +0 -5
- /package/{license → license.md} +0 -0
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import * as plugins from './smartnetwork.plugins.js';
|
|
2
2
|
import * as path from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
/** Internal marker for an activation failure whose cleanup still needs an owner. */
|
|
5
|
+
export class RustNetworkBridgeActivationCleanupError extends AggregateError {
|
|
6
|
+
constructor(activationErrorArg, cleanupErrorArg) {
|
|
7
|
+
super([activationErrorArg, cleanupErrorArg], 'RustNetworkBridge activation failed and cleanup could not be confirmed');
|
|
8
|
+
this.name = 'RustNetworkBridgeActivationCleanupError';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The tsrust target of the shipped binary for this host: static musl builds for Linux amd64 and arm64
|
|
13
|
+
*/
|
|
14
|
+
function getDistRustTarget() {
|
|
12
15
|
const archMap = {
|
|
13
16
|
x64: 'amd64',
|
|
14
17
|
arm64: 'arm64',
|
|
15
18
|
};
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return `${p}_${a}`;
|
|
19
|
+
const arch = archMap[process.arch];
|
|
20
|
+
if (process.platform !== 'linux' || !arch) {
|
|
21
|
+
return null;
|
|
20
22
|
}
|
|
21
|
-
return
|
|
23
|
+
return `linux_${arch}_musl`;
|
|
22
24
|
}
|
|
23
25
|
/**
|
|
24
26
|
* Singleton bridge to the rustnetwork binary.
|
|
@@ -33,12 +35,15 @@ export class RustNetworkBridge {
|
|
|
33
35
|
return RustNetworkBridge.instance;
|
|
34
36
|
}
|
|
35
37
|
constructor() {
|
|
38
|
+
this.owners = new Set();
|
|
39
|
+
this.cleanupRequired = false;
|
|
40
|
+
this.lifecycleQueue = Promise.resolve();
|
|
36
41
|
const packageDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
37
|
-
const
|
|
42
|
+
const distRustTarget = getDistRustTarget();
|
|
38
43
|
const localPaths = [];
|
|
39
|
-
//
|
|
40
|
-
if (
|
|
41
|
-
localPaths.push(path.join(packageDir, 'dist_rust', `rustnetwork_${
|
|
44
|
+
// Shipped static binary for this host
|
|
45
|
+
if (distRustTarget) {
|
|
46
|
+
localPaths.push(path.join(packageDir, 'dist_rust', `rustnetwork_${distRustTarget}`));
|
|
42
47
|
}
|
|
43
48
|
// Native build without suffix
|
|
44
49
|
localPaths.push(path.join(packageDir, 'dist_rust', 'rustnetwork'));
|
|
@@ -54,26 +59,71 @@ export class RustNetworkBridge {
|
|
|
54
59
|
searchSystemPath: false,
|
|
55
60
|
});
|
|
56
61
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const ok = await this.bridge.spawn();
|
|
62
|
-
if (!ok) {
|
|
63
|
-
throw new Error('Failed to spawn rustnetwork binary');
|
|
64
|
-
}
|
|
62
|
+
enqueueLifecycle(operationArg) {
|
|
63
|
+
const result = this.lifecycleQueue.then(operationArg);
|
|
64
|
+
this.lifecycleQueue = result.catch(() => { });
|
|
65
|
+
return result;
|
|
65
66
|
}
|
|
66
67
|
/**
|
|
67
|
-
*
|
|
68
|
+
* Acquire the shared Rust binary and wait for it to be ready.
|
|
68
69
|
*/
|
|
69
|
-
|
|
70
|
-
this.
|
|
70
|
+
start(ownerArg = this) {
|
|
71
|
+
return this.enqueueLifecycle(async () => {
|
|
72
|
+
if (this.cleanupRequired) {
|
|
73
|
+
throw new Error('RustNetworkBridge cleanup must succeed before it can start again');
|
|
74
|
+
}
|
|
75
|
+
if (this.owners.size > 0 && !this.bridge.running) {
|
|
76
|
+
throw new Error('RustNetworkBridge stopped while it still had active owners');
|
|
77
|
+
}
|
|
78
|
+
if (this.owners.has(ownerArg))
|
|
79
|
+
return;
|
|
80
|
+
if (this.owners.size === 0) {
|
|
81
|
+
let activationError;
|
|
82
|
+
try {
|
|
83
|
+
const ok = await this.bridge.spawn();
|
|
84
|
+
if (ok) {
|
|
85
|
+
this.owners.add(ownerArg);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
activationError = new Error('Failed to spawn rustnetwork binary');
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
activationError = error;
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
await this.bridge.terminate();
|
|
95
|
+
}
|
|
96
|
+
catch (cleanupError) {
|
|
97
|
+
this.owners.add(ownerArg);
|
|
98
|
+
this.cleanupRequired = true;
|
|
99
|
+
throw new RustNetworkBridgeActivationCleanupError(activationError, cleanupError);
|
|
100
|
+
}
|
|
101
|
+
throw activationError;
|
|
102
|
+
}
|
|
103
|
+
this.owners.add(ownerArg);
|
|
104
|
+
});
|
|
71
105
|
}
|
|
72
106
|
/**
|
|
73
|
-
*
|
|
107
|
+
* Release one owner and terminate the Rust binary after the last release.
|
|
74
108
|
*/
|
|
75
|
-
|
|
76
|
-
|
|
109
|
+
stop(ownerArg = this) {
|
|
110
|
+
return this.enqueueLifecycle(async () => {
|
|
111
|
+
if (!this.owners.has(ownerArg))
|
|
112
|
+
return;
|
|
113
|
+
if (this.owners.size > 1) {
|
|
114
|
+
this.owners.delete(ownerArg);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
await this.bridge.terminate();
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
this.cleanupRequired = true;
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
this.cleanupRequired = false;
|
|
125
|
+
this.owners.delete(ownerArg);
|
|
126
|
+
});
|
|
77
127
|
}
|
|
78
128
|
// ===== Command wrappers =====
|
|
79
129
|
async ping(host, count, timeoutMs) {
|
|
@@ -95,4 +145,4 @@ export class RustNetworkBridge {
|
|
|
95
145
|
return this.bridge.sendCommand('healthPing', {});
|
|
96
146
|
}
|
|
97
147
|
}
|
|
98
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
148
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZXR3b3JrLmNsYXNzZXMucnVzdGJyaWRnZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bmV0d29yay5jbGFzc2VzLnJ1c3RicmlkZ2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLE9BQU8sTUFBTSwyQkFBMkIsQ0FBQztBQUNyRCxPQUFPLEtBQUssSUFBSSxNQUFNLFdBQVcsQ0FBQztBQUNsQyxPQUFPLEVBQUUsYUFBYSxFQUFFLE1BQU0sVUFBVSxDQUFDO0FBOEN6QyxvRkFBb0Y7QUFDcEYsTUFBTSxPQUFPLHVDQUF3QyxTQUFRLGNBQWM7SUFDekUsWUFBWSxrQkFBMkIsRUFBRSxlQUF3QjtRQUMvRCxLQUFLLENBQ0gsQ0FBQyxrQkFBa0IsRUFBRSxlQUFlLENBQUMsRUFDckMsd0VBQXdFLENBQ3pFLENBQUM7UUFDRixJQUFJLENBQUMsSUFBSSxHQUFHLHlDQUF5QyxDQUFDO0lBQ3hELENBQUM7Q0FDRjtBQUVEOztHQUVHO0FBQ0gsU0FBUyxpQkFBaUI7SUFDeEIsTUFBTSxPQUFPLEdBQTJCO1FBQ3RDLEdBQUcsRUFBRSxPQUFPO1FBQ1osS0FBSyxFQUFFLE9BQU87S0FDZixDQUFDO0lBQ0YsTUFBTSxJQUFJLEdBQUcsT0FBTyxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQztJQUNuQyxJQUFJLE9BQU8sQ0FBQyxRQUFRLEtBQUssT0FBTyxJQ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sQ0FBQyxDQUFDO0lBQ2hGLENBQUM7SUFFTSxLQUFLLENBQUMsVUFBVTtRQUNyQixPQUFPLElBQUksQ0FBQyxNQUFNLENBQUMsV0FBVyxDQUFDLFlBQVksRUFBRSxFQUEyQixDQUFDLENBQUM7SUFDNUUsQ0FBQyJ9
|
|
@@ -18,6 +18,35 @@ export interface Hop {
|
|
|
18
18
|
ip: string;
|
|
19
19
|
rtt: number | null;
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Options for the ping method
|
|
23
|
+
*/
|
|
24
|
+
export interface IPingOptions {
|
|
25
|
+
/** Time to wait for each echo reply in milliseconds. Default: 5000 */
|
|
26
|
+
timeout?: number;
|
|
27
|
+
/** Number of echo requests to send. Default: 1 */
|
|
28
|
+
count?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Result of the ping method. Round-trip times are in milliseconds and `null`
|
|
32
|
+
* where no reply arrived.
|
|
33
|
+
*/
|
|
34
|
+
export interface IPingResult {
|
|
35
|
+
host: string;
|
|
36
|
+
count: number;
|
|
37
|
+
/** True when at least one echo reply arrived */
|
|
38
|
+
alive: boolean;
|
|
39
|
+
/** Round-trip time of the first reply */
|
|
40
|
+
time: number | null;
|
|
41
|
+
/** Round-trip time per echo request */
|
|
42
|
+
times: (number | null)[];
|
|
43
|
+
min: number | null;
|
|
44
|
+
max: number | null;
|
|
45
|
+
avg: number | null;
|
|
46
|
+
stddev: number | null;
|
|
47
|
+
/** Lost echo requests in percent */
|
|
48
|
+
packetLoss: number;
|
|
49
|
+
}
|
|
21
50
|
/**
|
|
22
51
|
* Options for the findFreePort method
|
|
23
52
|
*/
|
|
@@ -41,7 +70,11 @@ export declare class SmartNetwork {
|
|
|
41
70
|
private options;
|
|
42
71
|
private cache;
|
|
43
72
|
private rustBridge;
|
|
44
|
-
private
|
|
73
|
+
private bridgeLifecycleState;
|
|
74
|
+
private bridgeLifecycleQueue;
|
|
75
|
+
private activeDnsOperations;
|
|
76
|
+
private dnsDrainPromise;
|
|
77
|
+
private resolveDnsDrain;
|
|
45
78
|
private ipIntelligence;
|
|
46
79
|
private domainIntelligence;
|
|
47
80
|
private dnsClient;
|
|
@@ -58,6 +91,9 @@ export declare class SmartNetwork {
|
|
|
58
91
|
* the event loop alive.
|
|
59
92
|
*/
|
|
60
93
|
stop(): Promise<void>;
|
|
94
|
+
private enqueueBridgeLifecycle;
|
|
95
|
+
private withDnsClient;
|
|
96
|
+
private waitForDnsOperations;
|
|
61
97
|
/**
|
|
62
98
|
* Ensure the Rust bridge is running before sending commands.
|
|
63
99
|
*/
|
|
@@ -66,7 +102,7 @@ export declare class SmartNetwork {
|
|
|
66
102
|
* Lazily create the shared Smartdns client. The Rust backend inside
|
|
67
103
|
* Smartdns is only spawned on first query that requires it (NS/MX/SOA
|
|
68
104
|
* with prefer-system strategy, or any query with doh/udp strategy).
|
|
69
|
-
* The client is
|
|
105
|
+
* The client is terminated by stop().
|
|
70
106
|
*/
|
|
71
107
|
private ensureDnsClient;
|
|
72
108
|
/**
|
|
@@ -93,12 +129,14 @@ export declare class SmartNetwork {
|
|
|
93
129
|
jitter: number;
|
|
94
130
|
}>;
|
|
95
131
|
/**
|
|
96
|
-
* Send ICMP
|
|
132
|
+
* Send ICMP echo requests to a host.
|
|
133
|
+
*
|
|
134
|
+
* A host that does not answer or cannot be resolved yields `alive: false`.
|
|
135
|
+
* Rejects with a `NetworkError` with code `EPERM` when the process may not
|
|
136
|
+
* open an ICMP socket (Linux needs `CAP_NET_RAW` or a `net.ipv4.ping_group_range`
|
|
137
|
+
* that includes the process group), because no probe was sent at all.
|
|
97
138
|
*/
|
|
98
|
-
ping(host: string, opts?:
|
|
99
|
-
timeout?: number;
|
|
100
|
-
count?: number;
|
|
101
|
-
}): Promise<any>;
|
|
139
|
+
ping(host: string, opts?: IPingOptions): Promise<IPingResult>;
|
|
102
140
|
/**
|
|
103
141
|
* Check if a local port is unused (both IPv4 and IPv6)
|
|
104
142
|
*/
|
|
@@ -137,7 +175,7 @@ export declare class SmartNetwork {
|
|
|
137
175
|
/**
|
|
138
176
|
* Resolve DNS records (A, AAAA, MX) via the shared smartdns client.
|
|
139
177
|
* The client is lifecycle-managed by start()/stop() — MX queries spawn
|
|
140
|
-
* the smartdns Rust bridge,
|
|
178
|
+
* the smartdns Rust bridge, whose termination is confirmed by stop().
|
|
141
179
|
*/
|
|
142
180
|
resolveDns(host: string): Promise<{
|
|
143
181
|
A: string[];
|