@mark1russell7/netdiag 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +244 -2
- package/build/address.d.ts +56 -0
- package/build/address.d.ts.map +1 -0
- package/build/address.js +172 -0
- package/build/address.js.map +1 -0
- package/build/diagnosis-a4hRzFxp.js +922 -0
- package/build/diagnosis-a4hRzFxp.js.map +1 -0
- package/build/diagnosis.d.ts +8 -0
- package/build/diagnosis.js +1 -0
- package/build/index-K2dGiYxW.d.ts +259 -0
- package/build/index-K2dGiYxW.d.ts.map +1 -0
- package/build/index.d.ts +392 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +1359 -0
- package/build/index.js.map +1 -0
- package/build/kinds-CQv769lK.js +341 -0
- package/build/kinds-CQv769lK.js.map +1 -0
- package/build/kinds-_NShfZpU.d.ts +377 -0
- package/build/kinds-_NShfZpU.d.ts.map +1 -0
- package/build/layer-BNg0VYuK.d.ts +22 -0
- package/build/layer-BNg0VYuK.d.ts.map +1 -0
- package/build/tools.d.ts +206 -0
- package/build/tools.d.ts.map +1 -0
- package/build/tools.js +896 -0
- package/build/tools.js.map +1 -0
- package/package.json +81 -3
- package/src/address/index.ts +155 -0
- package/src/diagnosis/catalog.ts +357 -0
- package/src/diagnosis/index.ts +47 -0
- package/src/diagnosis/model.ts +322 -0
- package/src/diagnosis/score.ts +160 -0
- package/src/fact.ts +87 -0
- package/src/index.ts +68 -0
- package/src/kinds.ts +460 -0
- package/src/layer.ts +31 -0
- package/src/probe.ts +61 -0
- package/src/probes/native.ts +354 -0
- package/src/probes/socket.ts +520 -0
- package/src/readers.ts +367 -0
- package/src/run.ts +163 -0
- package/src/scope.ts +152 -0
- package/src/target.ts +116 -0
- package/src/tools/common.ts +47 -0
- package/src/tools/host.ts +91 -0
- package/src/tools/index.ts +38 -0
- package/src/tools/licenses.ts +37 -0
- package/src/tools/mtr.ts +156 -0
- package/src/tools/ping.ts +231 -0
- package/src/tools/traceroute.ts +313 -0
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
import { i as layerRank, n as Layer, r as isLayer, t as LAYERS } from "./layer-BNg0VYuK.js";
|
|
2
|
+
import { $ as HostKind, A as TRACE_OUTCOMES, B as ProbeContext, C as PathTrace, D as TCP_CONNECT, E as ReportHop, F as TraceHop, G as FactSource, H as defineProbe, I as TraceOutcome, J as ValueOf, K as FactTime, L as Trust, M as TcpConnect, N as TlsCertificate, O as TLS_HANDSHAKE, P as TlsHandshake, Q as observe, R as Availability, S as PathReport, T as RecordType, U as Fact, V as ProbeMode, W as FactKind, X as factsOf, Y as defineFactKind, Z as isFactOf, _ as ICMP_ECHO, a as DNS_ANSWER, at as sameTarget, b as PATH_REPORT, c as DnsOutcome, d as HANDSHAKE_OUTCOMES, et as Target, f as HTTP_OUTCOMES, g as HttpResponse, h as HttpOutcome, i as ConnectOutcome, it as parseTarget, j as TRUSTS, k as TOOL_KINDS, l as ECHO_OUTCOMES, m as HandshakeOutcome, n as CONNECT_OUTCOMES, nt as formatTarget, o as DNS_OUTCOMES, ot as target, p as HTTP_RESPONSE, q as Observation, r as CertProblem, rt as hostKind, s as DnsAnswer, t as CERT_PROBLEMS, tt as canonicalHost, u as EchoOutcome, v as IcmpEcho, w as RECORD_TYPES, x as PATH_TRACE, y as NATIVE_KINDS, z as Probe } from "./kinds-_NShfZpU.js";
|
|
3
|
+
import { ADDRESS_CLASSES, AddressClass, AddressFamily, Cidr, CidrSet, addressClass, addressFamily, addressKind, canonicalAddress, cidrContains, cidrSet, formatCidr, parseCidr } from "./address.js";
|
|
4
|
+
import { A as Part, B as predictive, C as Expectation, D as Hypothesis, E as Feature, F as UNKNOWN, I as compileCatalog, L as diagnose, M as Reach, N as STRENGTHS, O as NONE, P as Strength, R as expand, S as Evidence, T as Fault, _ as CatalogSpec, a as LabRecord, b as Diagnosis, c as LabVerdict, d as scoreLab, f as STANDARD_CATALOG, g as Catalog, h as STANDARD_FEATURES, i as LabGate, j as Prediction, k as PARTS, l as labGate, m as STANDARD_FAULTS, n as LabBars, o as LabScore, p as STANDARD_CATALOG_SPEC, r as LabCause, s as LabStatus, t as LAB_RECORD_FORMAT, u as labRecordOf, v as Cause, w as FLOOR, x as Distribution, y as Contribution, z as explain } from "./index-K2dGiYxW.js";
|
|
5
|
+
import { Socket, TcpNetConnectOpts } from "node:net";
|
|
6
|
+
import { Result } from "@mark1russell7/optional";
|
|
7
|
+
import { Clock } from "@mark1russell7/algebra/clock";
|
|
8
|
+
/**
|
|
9
|
+
* The basis of a grant: why a target is in the scope.
|
|
10
|
+
*
|
|
11
|
+
* - `named`: the user named the target for this diagnosis.
|
|
12
|
+
* - `owned`: the user declares that the user owns the network or the host.
|
|
13
|
+
* - `configured`: the configuration of the computer of the user names it, for example the gateway or the DNS resolver.
|
|
14
|
+
* - `resolved`: a DNS answer for a granted name gave this address.
|
|
15
|
+
*/
|
|
16
|
+
type GrantBasis = "named" | "owned" | "configured" | "resolved";
|
|
17
|
+
/**
|
|
18
|
+
* A grant puts targets in the scope.
|
|
19
|
+
*
|
|
20
|
+
* A `host` grant puts a DNS name in the scope, and with `subdomains` each name under it. A `range` grant puts the
|
|
21
|
+
* addresses of a CIDR range in the scope, for example `192.0.2.0/24` or `2001:db8::/32`.
|
|
22
|
+
*/
|
|
23
|
+
type Grant = HostGrant | RangeGrant;
|
|
24
|
+
/** A grant of a DNS name, and with `subdomains` of each name under it. */
|
|
25
|
+
interface HostGrant {
|
|
26
|
+
readonly kind: "host";
|
|
27
|
+
readonly host: string;
|
|
28
|
+
readonly subdomains?: boolean | undefined;
|
|
29
|
+
readonly basis: GrantBasis;
|
|
30
|
+
readonly note?: string | undefined;
|
|
31
|
+
}
|
|
32
|
+
/** A grant of the addresses of a CIDR range, for example `192.0.2.0/24` or `2001:db8::/32`. */
|
|
33
|
+
interface RangeGrant {
|
|
34
|
+
readonly kind: "range";
|
|
35
|
+
readonly cidr: string;
|
|
36
|
+
readonly basis: GrantBasis;
|
|
37
|
+
readonly note?: string | undefined;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The scope of a diagnosis: the grants, and the largest number of ports for each host.
|
|
41
|
+
*
|
|
42
|
+
* An active probe sends packets only to a peer in the scope. The limit of ports stops a port scan: netdiag does no
|
|
43
|
+
* vulnerability scan.
|
|
44
|
+
*/
|
|
45
|
+
interface Scope {
|
|
46
|
+
readonly grants: readonly Grant[];
|
|
47
|
+
readonly maxPortsPerHost: number;
|
|
48
|
+
}
|
|
49
|
+
/** The default limit of the different ports of one host in one runner. */
|
|
50
|
+
export declare const DEFAULT_MAX_PORTS_PER_HOST = 8;
|
|
51
|
+
/** The decision of the scope for one peer of an active probe. A refusal has the reason in plain words. */
|
|
52
|
+
type ScopeDecision = {
|
|
53
|
+
readonly allowed: true;
|
|
54
|
+
readonly grant: Grant;
|
|
55
|
+
} | {
|
|
56
|
+
readonly allowed: false;
|
|
57
|
+
readonly reason: string;
|
|
58
|
+
};
|
|
59
|
+
/** The ports that a runner sent packets to, for each host. */
|
|
60
|
+
type PortLedger = ReadonlyMap<string, ReadonlySet<number>>;
|
|
61
|
+
/** This function gives the problems of a grant, or an empty list for a correct grant. */
|
|
62
|
+
export declare function grantProblems(grant: Grant): string[];
|
|
63
|
+
/**
|
|
64
|
+
* This function makes a scope from grants. It refuses a grant with a problem, so a typing error cannot widen the scope.
|
|
65
|
+
*
|
|
66
|
+
* The default limit of ports is `DEFAULT_MAX_PORTS_PER_HOST`.
|
|
67
|
+
*/
|
|
68
|
+
export declare function scopeOf(grants: readonly Grant[], options?: {
|
|
69
|
+
readonly maxPortsPerHost?: number;
|
|
70
|
+
}): Result<Scope, string[]>;
|
|
71
|
+
/**
|
|
72
|
+
* This function gives the grant for a target that the user names. A name gets a host grant. An IP address gets a
|
|
73
|
+
* range grant of one address.
|
|
74
|
+
*/
|
|
75
|
+
export declare function namedGrant(t: Target, note?: string): Grant;
|
|
76
|
+
/** This function gives the grant of one address that a DNS answer for a granted name gave. */
|
|
77
|
+
export declare function resolvedGrant(name: string, address: string, factId?: string): RangeGrant;
|
|
78
|
+
/** This function gives a scope with more grants. The limit of ports does not change. */
|
|
79
|
+
export declare function widen(scope: Scope, grants: readonly Grant[]): Result<Scope, string[]>;
|
|
80
|
+
/**
|
|
81
|
+
* This function decides if an active probe can send packets to a peer.
|
|
82
|
+
*
|
|
83
|
+
* The peer must match a grant of the scope. A new port of a host must also stay in the limit of ports for each host.
|
|
84
|
+
* The ledger has the ports that the runner sent packets to before.
|
|
85
|
+
*/
|
|
86
|
+
export declare function decideScope(scope: Scope, peer: Target, ledger?: PortLedger): ScopeDecision;
|
|
87
|
+
/**
|
|
88
|
+
* The outcome of one run of a probe.
|
|
89
|
+
*
|
|
90
|
+
* - `done`: the probe did its work. The facts include each network failure that it saw.
|
|
91
|
+
* - `refused`: a peer is not in the scope, so the probe did not start.
|
|
92
|
+
* - `unavailable`: the probe cannot operate on this computer.
|
|
93
|
+
* - `failed`: the probe or its parser has a fault. The raw output is present when the run ended.
|
|
94
|
+
* - `aborted`: the signal stopped the run.
|
|
95
|
+
*/
|
|
96
|
+
type ProbeOutcome<R> = {
|
|
97
|
+
readonly status: "done";
|
|
98
|
+
readonly time: FactTime;
|
|
99
|
+
readonly raw: R;
|
|
100
|
+
readonly facts: readonly Fact[];
|
|
101
|
+
} | {
|
|
102
|
+
readonly status: "refused";
|
|
103
|
+
readonly peer: Target;
|
|
104
|
+
readonly reason: string;
|
|
105
|
+
} | {
|
|
106
|
+
readonly status: "unavailable";
|
|
107
|
+
readonly reason: string;
|
|
108
|
+
} | {
|
|
109
|
+
readonly status: "failed";
|
|
110
|
+
readonly stage: "probe" | "run" | "parse";
|
|
111
|
+
readonly error: string;
|
|
112
|
+
readonly raw?: R | undefined;
|
|
113
|
+
} | {
|
|
114
|
+
readonly status: "aborted";
|
|
115
|
+
readonly reason: string;
|
|
116
|
+
};
|
|
117
|
+
/** The wall-clock time of one monotonic time of the runner. */
|
|
118
|
+
interface ClockOrigin {
|
|
119
|
+
readonly wall: string;
|
|
120
|
+
readonly monotonic: number;
|
|
121
|
+
}
|
|
122
|
+
/** The options of a runner. */
|
|
123
|
+
interface RunnerOptions {
|
|
124
|
+
readonly scope: Scope;
|
|
125
|
+
readonly clock: Clock;
|
|
126
|
+
/** The wall-clock time of the start, as an ISO 8601 text. The default is the time of the computer. */
|
|
127
|
+
readonly wall?: string | undefined;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* A runner starts probes in one scope, and keeps the facts of the diagnosis.
|
|
131
|
+
*
|
|
132
|
+
* It gives each fact an id in sequence. It keeps the ledger of the ports of each host, for the limit of ports of the scope.
|
|
133
|
+
*/
|
|
134
|
+
interface Runner {
|
|
135
|
+
readonly origin: ClockOrigin;
|
|
136
|
+
scope(): Scope;
|
|
137
|
+
facts(): readonly Fact[];
|
|
138
|
+
/** This method adds grants to the scope, for example the addresses of a granted name. */
|
|
139
|
+
grant(grants: readonly Grant[]): void;
|
|
140
|
+
run<I, R>(probe: Probe<I, R>, input: I, signal?: AbortSignal): Promise<ProbeOutcome<R>>;
|
|
141
|
+
}
|
|
142
|
+
/** This function makes a runner. */
|
|
143
|
+
export declare function createRunner(options: RunnerOptions): Runner;
|
|
144
|
+
/** The function that opens a TCP socket. A test can give a function that gives a socket with no connection. */
|
|
145
|
+
type Dial = (options: TcpNetConnectOpts) => Socket;
|
|
146
|
+
/** The options of the native probes that connect. */
|
|
147
|
+
interface ConnectOptions {
|
|
148
|
+
/** The function that opens a TCP socket. The default is `connect` of `node:net`. */
|
|
149
|
+
readonly dial?: Dial | undefined;
|
|
150
|
+
}
|
|
151
|
+
/** The time limit of a probe run, when its input gives none: 5 seconds. */
|
|
152
|
+
export declare const DEFAULT_TIMEOUT_MS = 5e3;
|
|
153
|
+
/** This function maps an error code of a TCP connect to its outcome. */
|
|
154
|
+
export declare function connectOutcome(code: string | undefined): ConnectOutcome;
|
|
155
|
+
/** This function maps an error of a TLS handshake to its outcome. */
|
|
156
|
+
export declare function handshakeOutcome(thrown: unknown, expired: boolean): HandshakeOutcome;
|
|
157
|
+
/** This function maps the authorization error of a TLS socket to the problem of the certificate. */
|
|
158
|
+
export declare function certProblem(code: string): CertProblem;
|
|
159
|
+
/** The TCP phase of a probe run. The times are readings of the clock of the runner. */
|
|
160
|
+
interface TcpPhase {
|
|
161
|
+
readonly address: string;
|
|
162
|
+
readonly port: number;
|
|
163
|
+
readonly family: 4 | 6;
|
|
164
|
+
readonly start: number;
|
|
165
|
+
readonly end: number;
|
|
166
|
+
readonly outcome: ConnectOutcome;
|
|
167
|
+
readonly code?: string | undefined;
|
|
168
|
+
}
|
|
169
|
+
/** The TLS phase of a probe run. */
|
|
170
|
+
interface TlsPhase {
|
|
171
|
+
readonly servername?: string | undefined;
|
|
172
|
+
readonly start: number;
|
|
173
|
+
readonly end: number;
|
|
174
|
+
readonly outcome: HandshakeOutcome;
|
|
175
|
+
readonly protocol?: string | undefined;
|
|
176
|
+
readonly cipher?: string | undefined;
|
|
177
|
+
readonly alpn?: string | undefined;
|
|
178
|
+
readonly code?: string | undefined;
|
|
179
|
+
readonly certificate?: TlsCertificate | undefined;
|
|
180
|
+
}
|
|
181
|
+
/** The fields of a response head that an HTTP fact keeps. */
|
|
182
|
+
export declare const KEPT_FIELDS: readonly string[];
|
|
183
|
+
/** The HTTP phase of a probe run. */
|
|
184
|
+
interface HttpPhase {
|
|
185
|
+
readonly method: "GET" | "HEAD";
|
|
186
|
+
readonly host: string;
|
|
187
|
+
readonly path: string;
|
|
188
|
+
readonly start: number;
|
|
189
|
+
/** The time of the head of the response. */
|
|
190
|
+
readonly head?: number | undefined;
|
|
191
|
+
readonly end: number;
|
|
192
|
+
readonly outcome: HttpOutcome;
|
|
193
|
+
readonly status?: number | undefined;
|
|
194
|
+
readonly version?: string | undefined;
|
|
195
|
+
readonly fields: Readonly<Record<string, string>>;
|
|
196
|
+
readonly bytes: number;
|
|
197
|
+
readonly truncated: boolean;
|
|
198
|
+
readonly code?: string | undefined;
|
|
199
|
+
}
|
|
200
|
+
/** The input of the DNS probe: one query for the addresses of a name, to one resolver. */
|
|
201
|
+
interface DnsInput {
|
|
202
|
+
readonly name: string;
|
|
203
|
+
/** The record type. The default is `A`. */
|
|
204
|
+
readonly record?: RecordType | undefined;
|
|
205
|
+
/** The IP address of the resolver. */
|
|
206
|
+
readonly resolver: string;
|
|
207
|
+
/** The port of the resolver. The default is 53. */
|
|
208
|
+
readonly port?: number | undefined;
|
|
209
|
+
readonly timeoutMs?: number | undefined;
|
|
210
|
+
}
|
|
211
|
+
/** The raw output of the DNS probe. The times are readings of the clock of the runner. */
|
|
212
|
+
interface DnsRaw {
|
|
213
|
+
readonly name: string;
|
|
214
|
+
readonly record: RecordType;
|
|
215
|
+
readonly resolver: string;
|
|
216
|
+
readonly start: number;
|
|
217
|
+
readonly end: number;
|
|
218
|
+
readonly outcome: DnsOutcome;
|
|
219
|
+
readonly addresses: readonly string[];
|
|
220
|
+
readonly ttl?: number | undefined;
|
|
221
|
+
readonly code?: string | undefined;
|
|
222
|
+
}
|
|
223
|
+
/** This function maps an error code of a DNS query to its outcome. */
|
|
224
|
+
export declare function dnsOutcome(code: string | undefined): DnsOutcome;
|
|
225
|
+
/**
|
|
226
|
+
* The DNS probe sends one query for the addresses of a name to one resolver. Its peer is the resolver, not the name.
|
|
227
|
+
* The query uses no search domain.
|
|
228
|
+
*/
|
|
229
|
+
export declare const DNS_PROBE: Probe<DnsInput, DnsRaw>;
|
|
230
|
+
/** The input of the TCP probe: one connect to an IP address and a port. */
|
|
231
|
+
interface TcpInput {
|
|
232
|
+
readonly address: string;
|
|
233
|
+
readonly port: number;
|
|
234
|
+
readonly timeoutMs?: number | undefined;
|
|
235
|
+
}
|
|
236
|
+
/** The raw output of the TCP probe. */
|
|
237
|
+
interface TcpRaw {
|
|
238
|
+
readonly tcp: TcpPhase;
|
|
239
|
+
}
|
|
240
|
+
/** This function makes the TCP probe. It connects, and then it closes the connection. */
|
|
241
|
+
export declare function tcpProbe(options?: ConnectOptions): Probe<TcpInput, TcpRaw>;
|
|
242
|
+
/** The TCP probe with the `connect` of `node:net`. */
|
|
243
|
+
export declare const TCP_PROBE: Probe<TcpInput, TcpRaw>;
|
|
244
|
+
/** The input of the TLS probe: a TCP connect and a TLS handshake. */
|
|
245
|
+
interface TlsInput {
|
|
246
|
+
readonly address: string;
|
|
247
|
+
/** The port. The default is 443. */
|
|
248
|
+
readonly port?: number | undefined;
|
|
249
|
+
/** The name for SNI and for the check of the certificate. */
|
|
250
|
+
readonly servername?: string | undefined;
|
|
251
|
+
readonly alpn?: readonly string[] | undefined;
|
|
252
|
+
readonly timeoutMs?: number | undefined;
|
|
253
|
+
}
|
|
254
|
+
/** The raw output of the TLS probe. It has no TLS phase when the TCP connect failed. */
|
|
255
|
+
interface TlsRaw {
|
|
256
|
+
readonly tcp: TcpPhase;
|
|
257
|
+
readonly tls?: TlsPhase | undefined;
|
|
258
|
+
}
|
|
259
|
+
/** The options of the TLS and HTTP probes. */
|
|
260
|
+
interface TlsProbeOptions extends ConnectOptions {
|
|
261
|
+
/** More roots of trust, as PEM text: the roots that the user trusts, for example the root of a company. */
|
|
262
|
+
readonly roots?: readonly string[] | undefined;
|
|
263
|
+
/**
|
|
264
|
+
* More public roots, as PEM text. A chain that ends at one of them gets the trust `public`. A lab gives its own
|
|
265
|
+
* root here, so that its servers stand for servers on the internet.
|
|
266
|
+
*/
|
|
267
|
+
readonly publicRoots?: readonly string[] | undefined;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* This function makes the TLS probe. It measures the TCP connect and the TLS handshake apart. It examines the
|
|
271
|
+
* certificate, and it does not refuse a certificate that is not valid.
|
|
272
|
+
*/
|
|
273
|
+
export declare function tlsProbe(options?: TlsProbeOptions): Probe<TlsInput, TlsRaw>;
|
|
274
|
+
/** The TLS probe with the public roots and the roots of the computer. */
|
|
275
|
+
export declare const TLS_PROBE: Probe<TlsInput, TlsRaw>;
|
|
276
|
+
/** The input of the HTTP probe: one HTTP/1.1 request over TCP, or over TLS for `https`. */
|
|
277
|
+
interface HttpInput {
|
|
278
|
+
readonly address: string;
|
|
279
|
+
readonly scheme: "http" | "https";
|
|
280
|
+
/** The port. The default is 80 for `http` and 443 for `https`. */
|
|
281
|
+
readonly port?: number | undefined;
|
|
282
|
+
/** The name of the host for the `Host` field and for SNI. The default is the address. */
|
|
283
|
+
readonly host?: string | undefined;
|
|
284
|
+
/** The path of the request. The default is `/`. */
|
|
285
|
+
readonly path?: string | undefined;
|
|
286
|
+
/** The method. The default is `GET`. */
|
|
287
|
+
readonly method?: "GET" | "HEAD" | undefined;
|
|
288
|
+
readonly timeoutMs?: number | undefined;
|
|
289
|
+
/** The limit of the bytes of the body that the probe reads. The default is 65536. */
|
|
290
|
+
readonly maxBytes?: number | undefined;
|
|
291
|
+
}
|
|
292
|
+
/** The raw output of the HTTP probe. */
|
|
293
|
+
interface HttpRaw {
|
|
294
|
+
readonly scheme: "http" | "https";
|
|
295
|
+
readonly tcp: TcpPhase;
|
|
296
|
+
readonly tls?: TlsPhase | undefined;
|
|
297
|
+
readonly http?: HttpPhase | undefined;
|
|
298
|
+
}
|
|
299
|
+
/** The limit of the bytes of a body that the HTTP probe reads, when its input gives none: 64 KiB. */
|
|
300
|
+
export declare const DEFAULT_MAX_BYTES = 65536;
|
|
301
|
+
/**
|
|
302
|
+
* This function makes the HTTP probe. It sends one request, follows no redirect, and reads the body up to a limit. It
|
|
303
|
+
* gives the facts of each phase: TCP, TLS for `https`, and HTTP. For `https`, it sends the request only when the
|
|
304
|
+
* certificate passes its check.
|
|
305
|
+
*/
|
|
306
|
+
export declare function httpProbe(options?: TlsProbeOptions): Probe<HttpInput, HttpRaw>;
|
|
307
|
+
/** The HTTP probe with the public roots and the roots of the computer. */
|
|
308
|
+
export declare const HTTP_PROBE: Probe<HttpInput, HttpRaw>;
|
|
309
|
+
/** A fact that gave no evidence, with the reason in plain words. */
|
|
310
|
+
export interface Skipped {
|
|
311
|
+
readonly fact: string;
|
|
312
|
+
readonly reason: string;
|
|
313
|
+
}
|
|
314
|
+
/** The evidence of a list of facts, and the facts that gave no evidence. */
|
|
315
|
+
export interface Reading {
|
|
316
|
+
readonly evidence: readonly Evidence[];
|
|
317
|
+
readonly skipped: readonly Skipped[];
|
|
318
|
+
}
|
|
319
|
+
/** The options of `readEvidence`. */
|
|
320
|
+
export interface ReadOptions {
|
|
321
|
+
/** This function tells if a fact is about the target (`true`) or about a reference host (`false`). The default is `true`. */
|
|
322
|
+
readonly primary?: ((fact: Fact) => boolean) | undefined;
|
|
323
|
+
/**
|
|
324
|
+
* The IP address of the default gateway. The ICMP echo facts of this address give the feature `gateway.reply`. The
|
|
325
|
+
* ICMP echo facts of the other addresses give the feature `icmp.reply`.
|
|
326
|
+
*/
|
|
327
|
+
readonly gateway?: string | undefined;
|
|
328
|
+
}
|
|
329
|
+
/** A bin of a time or a ratio. A number below `below` gets `value`. The last bin has no limit. */
|
|
330
|
+
export interface Bin {
|
|
331
|
+
readonly below?: number | undefined;
|
|
332
|
+
readonly value: string;
|
|
333
|
+
}
|
|
334
|
+
/** The bins of the feature `tcp.time`, in milliseconds. A connect of 900 ms or more sent its SYN again. */
|
|
335
|
+
export declare const TCP_TIME_BINS: readonly Bin[];
|
|
336
|
+
/** The bins of the feature `tls.ratio`: the time of the TLS handshake divided by the time of the TCP connect. */
|
|
337
|
+
export declare const TLS_RATIO_BINS: readonly Bin[];
|
|
338
|
+
/** The bins of the feature `http.ttfb`: the time to the first byte divided by the time of the TCP connect. */
|
|
339
|
+
export declare const HTTP_TTFB_BINS: readonly Bin[];
|
|
340
|
+
/**
|
|
341
|
+
* The smallest time of a TCP connect in a ratio, in milliseconds. On a local link, a ratio with a smaller time measures
|
|
342
|
+
* only the cost of the cryptography.
|
|
343
|
+
*/
|
|
344
|
+
export declare const MIN_CONNECT_MS = 1;
|
|
345
|
+
/** The value of the feature `dns.answer` for each outcome of a DNS query. `nodata` tells that the name exists. */
|
|
346
|
+
export declare const DNS_ANSWER_VALUES: Readonly<Partial<Record<DnsOutcome, string>>>;
|
|
347
|
+
/** The value of the feature `tcp.connect` for each outcome of a TCP connect. */
|
|
348
|
+
export declare const TCP_CONNECT_VALUES: Readonly<Partial<Record<ConnectOutcome, string>>>;
|
|
349
|
+
/**
|
|
350
|
+
* The value of the feature `tls.handshake` for each outcome of a TLS handshake. The catalog has no value for `not-tls`
|
|
351
|
+
* and `closed` yet. The lab runs (ND-7) tell which faults cause them.
|
|
352
|
+
*/
|
|
353
|
+
export declare const TLS_HANDSHAKE_VALUES: Readonly<Partial<Record<HandshakeOutcome, string>>>;
|
|
354
|
+
/** The value of the feature `tls.trust` for each trust. A chain that ends at no root of the store has no public root. */
|
|
355
|
+
export declare const TLS_TRUST_VALUES: Readonly<Record<Trust, string>>;
|
|
356
|
+
/** The value of the feature `icmp.reply` for each outcome of the ICMP echo requests to an address. */
|
|
357
|
+
export declare const ICMP_REPLY_VALUES: Readonly<Partial<Record<EchoOutcome, string>>>;
|
|
358
|
+
/**
|
|
359
|
+
* The value of the feature `gateway.reply` for each outcome of the ICMP echo requests to the gateway. When this computer
|
|
360
|
+
* tells that the gateway is unreachable, the gateway gives no reply.
|
|
361
|
+
*/
|
|
362
|
+
export declare const GATEWAY_REPLY_VALUES: Readonly<Partial<Record<EchoOutcome, string>>>;
|
|
363
|
+
/**
|
|
364
|
+
* The bins of the feature `path.loss`, on the share of the echo requests with a reply. A share of 1 has no loss. A share
|
|
365
|
+
* of 0.95 or more has a loss of up to 5 %.
|
|
366
|
+
*/
|
|
367
|
+
export declare const PATH_LOSS_BINS: readonly Bin[];
|
|
368
|
+
/**
|
|
369
|
+
* The smallest number of echo requests that gives the feature `path.loss`. With 20 requests, one lost request is a loss
|
|
370
|
+
* of 5 %. With no reply, the feature `icmp.reply` tells the result, not `path.loss`.
|
|
371
|
+
*/
|
|
372
|
+
export declare const LOSS_MIN_SENT = 20;
|
|
373
|
+
/** The suffixes of the names of local networks and of the special-use names (RFC 6761, RFC 6762 and RFC 8375). */
|
|
374
|
+
export declare const LOCAL_SUFFIXES: readonly string[];
|
|
375
|
+
/** This function gives the value of the first bin that holds `x`. */
|
|
376
|
+
export declare function binOf(bins: readonly Bin[], x: number): string;
|
|
377
|
+
/** This function tells if a name is a local name: a name with one label, or a name with a local suffix. */
|
|
378
|
+
export declare function isLocalName(name: string): boolean;
|
|
379
|
+
/**
|
|
380
|
+
* This function changes facts into evidence for the model.
|
|
381
|
+
*
|
|
382
|
+
* - The reader gives one evidence for each feature, subject and role. When a subject has more facts, the last fact decides.
|
|
383
|
+
* - For `dns.answer`, one answer `ok` of a name and a resolver decides. For `dns.address`, one private address decides.
|
|
384
|
+
* - The order of the facts is the order of the runner. A ratio uses the last TCP connect before the handshake or the request.
|
|
385
|
+
* - An ICMP echo fact gives `gateway.reply` for the gateway, and `icmp.reply` for each other address.
|
|
386
|
+
* - An ICMP echo fact with replies to `LOSS_MIN_SENT` requests or more gives `path.loss`. A report of `mtr` gives it from
|
|
387
|
+
* the last hop, when the address answered there.
|
|
388
|
+
* - A trace of `traceroute` gives no evidence. The catalog has no feature for the hops of a path.
|
|
389
|
+
*/
|
|
390
|
+
export declare function readEvidence(facts: readonly Fact[], options?: ReadOptions): Reading;
|
|
391
|
+
export { ADDRESS_CLASSES, AddressClass, AddressFamily, type Availability, CERT_PROBLEMS, CONNECT_OUTCOMES, type Catalog, type CatalogSpec, type Cause, CertProblem, Cidr, CidrSet, type ClockOrigin, type ConnectOptions, ConnectOutcome, type Contribution, DNS_ANSWER, DNS_OUTCOMES, type Diagnosis, type Dial, type Distribution, DnsAnswer, type DnsInput, DnsOutcome, type DnsRaw, ECHO_OUTCOMES, EchoOutcome, type Evidence, type Expectation, FLOOR, type Fact, type FactKind, type FactSource, type FactTime, type Fault, type Feature, type Grant, type GrantBasis, HANDSHAKE_OUTCOMES, HTTP_OUTCOMES, HTTP_RESPONSE, HandshakeOutcome, type HostGrant, type HostKind, type HttpInput, HttpOutcome, type HttpPhase, type HttpRaw, HttpResponse, type Hypothesis, ICMP_ECHO, IcmpEcho, LAB_RECORD_FORMAT, LAYERS, type LabBars, type LabCause, type LabGate, type LabRecord, type LabScore, type LabStatus, type LabVerdict, type Layer, NATIVE_KINDS, NONE, type Observation, PARTS, PATH_REPORT, PATH_TRACE, type Part, PathReport, PathTrace, type PortLedger, type Prediction, type Probe, type ProbeContext, type ProbeMode, type ProbeOutcome, RECORD_TYPES, type RangeGrant, type Reach, RecordType, ReportHop, type Runner, type RunnerOptions, STANDARD_CATALOG, STANDARD_CATALOG_SPEC, STANDARD_FAULTS, STANDARD_FEATURES, STRENGTHS, type Scope, type ScopeDecision, type Strength, TCP_CONNECT, TLS_HANDSHAKE, TOOL_KINDS, TRACE_OUTCOMES, TRUSTS, type Target, TcpConnect, type TcpInput, type TcpPhase, type TcpRaw, TlsCertificate, TlsHandshake, type TlsInput, type TlsPhase, type TlsProbeOptions, type TlsRaw, TraceHop, TraceOutcome, Trust, UNKNOWN, type ValueOf, addressClass, addressFamily, addressKind, canonicalAddress, canonicalHost, cidrContains, cidrSet, compileCatalog, defineFactKind, defineProbe, diagnose, expand, explain, factsOf, formatCidr, formatTarget, hostKind, isFactOf, isLayer, labGate, labRecordOf, layerRank, observe, parseCidr, parseTarget, predictive, sameTarget, scoreLab, target };
|
|
392
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/scope.ts","../src/run.ts","../src/probes/socket.ts","../src/probes/native.ts","../src/readers.ts"],"mappings":";;;;;;;;;;;;;;;KAaY;;;;;;;KAQA,QAAQ,YAAY;;UAGf;WACN;WACA;WACA;WACA,OAAO;WACP;;;UAIM;WACN;WACA;WACA,OAAO;WACP;;;;;;;;UASM;WACN,iBAAiB;WACjB;;;qBAIE;;KAGD;WACG;WAAwB,OAAO;;WAC/B;WAAyB;;;KAG5B,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