net-address 0.1.1 → 0.1.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/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +312 -269
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +312 -269
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,395 +1,438 @@
|
|
|
1
1
|
import { IOption, IResult } from "@luolapeikko/result-option";
|
|
2
|
-
|
|
3
2
|
//#region src/Ipv6Addr.d.ts
|
|
4
3
|
/**
|
|
5
|
-
* Represents an IPv6 address.
|
|
6
|
-
* @example
|
|
7
|
-
* const addr1 = Ipv6Addr.from('2001:db8::1').unwrap();
|
|
8
|
-
* const addr2 = new Ipv6Addr([0x2001, 0xdb8, 0, 0, 0, 0, 0, 1]);
|
|
9
|
-
* const addr3 = new Ipv6Addr(0x20010db8000000000000000000000001n);
|
|
10
|
-
* @since v0.0.1
|
|
11
|
-
*/
|
|
4
|
+
* Represents an IPv6 address.
|
|
5
|
+
* @example
|
|
6
|
+
* const addr1 = Ipv6Addr.from('2001:db8::1').unwrap();
|
|
7
|
+
* const addr2 = new Ipv6Addr([0x2001, 0xdb8, 0, 0, 0, 0, 0, 1]);
|
|
8
|
+
* const addr3 = new Ipv6Addr(0x20010db8000000000000000000000001n);
|
|
9
|
+
* @since v0.0.1
|
|
10
|
+
*/
|
|
12
11
|
declare class Ipv6Addr {
|
|
13
12
|
#private;
|
|
14
13
|
private static regex;
|
|
15
14
|
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
* Creates an IPv6 address from text.
|
|
16
|
+
* @returns A successful result with an IPv6 address, or an error when the input is invalid.
|
|
17
|
+
* @example
|
|
18
|
+
* const addr = Ipv6Addr.from('2001:db8::1').unwrap();
|
|
19
|
+
* @since v0.0.1
|
|
20
|
+
*/
|
|
22
21
|
static from(value: string): IResult<Ipv6Addr, TypeError | RangeError>;
|
|
23
22
|
/**
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
* Creates an IPv6 address from a 16-byte buffer.
|
|
24
|
+
* @returns A successful result with an IPv6 address, or an error when the buffer cannot be read.
|
|
25
|
+
* @since v0.0.1
|
|
26
|
+
*/
|
|
28
27
|
static fromBuffer(buffer: ArrayBuffer, littleEndian?: boolean): IResult<Ipv6Addr>;
|
|
29
28
|
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
* The number of bits in an IPv6 address.
|
|
30
|
+
* @since v0.0.1
|
|
31
|
+
*/
|
|
33
32
|
static readonly BITS = 128;
|
|
34
33
|
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
* The loopback address (`::1`).
|
|
35
|
+
* @since v0.0.1
|
|
36
|
+
*/
|
|
38
37
|
static readonly LOCALHOST: Ipv6Addr;
|
|
39
38
|
/**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
* The unspecified address (`::`).
|
|
40
|
+
* @since v0.0.1
|
|
41
|
+
*/
|
|
43
42
|
static readonly UNSPECIFIED: Ipv6Addr;
|
|
44
43
|
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
* The address family identifier for IPv6 addresses.
|
|
45
|
+
* @since v0.0.1
|
|
46
|
+
*/
|
|
48
47
|
readonly family = "ipv6";
|
|
49
48
|
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
* Gets the raw bigint representation of the IPv6 address.
|
|
50
|
+
*/
|
|
51
|
+
get value(): bigint;
|
|
52
|
+
/**
|
|
53
|
+
* Creates a new IPv6 address instance.
|
|
54
|
+
* @param value - A bigint representing the IPv6 address or an array of 8 numbers representing the segments of the address.
|
|
55
|
+
* @throws {RangeError} If the segments array does not have exactly 8 elements or if any segment is out of range.
|
|
56
|
+
* @throws {TypeError} If the input is neither a bigint nor an array of 8 numbers.
|
|
57
|
+
*/
|
|
55
58
|
constructor(value: bigint);
|
|
56
59
|
constructor(segments: [number, number, number, number, number, number, number, number]);
|
|
57
60
|
/**
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
* Checks whether this address is in the benchmarking range.
|
|
62
|
+
* @see https://tools.ietf.org/html/rfc5180 and https://www.rfc-editor.org/errata_search.php?eid=1752
|
|
63
|
+
* @returns `true` when the address is in `2001:2::/48`, otherwise `false`.
|
|
64
|
+
* @since v0.0.1
|
|
65
|
+
*/
|
|
63
66
|
isBenchmarking(): boolean;
|
|
64
67
|
/**
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
* Checks whether this address is in a documentation-only range.
|
|
69
|
+
* @see https://tools.ietf.org/html/rfc3849 and https://tools.ietf.org/html/rfc9637
|
|
70
|
+
* @returns `true` for `2001:db8::/32` or `3fff::/20`, otherwise `false`.
|
|
71
|
+
* @since v0.0.1
|
|
72
|
+
*/
|
|
70
73
|
isDocumentation(): boolean;
|
|
71
74
|
/**
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
* Checks whether this address is the loopback address.
|
|
76
|
+
* @see https://tools.ietf.org/html/rfc4291#section-2.5.3
|
|
77
|
+
* @returns `true` when the address is `::1`, otherwise `false`.
|
|
78
|
+
* @since v0.0.1
|
|
79
|
+
*/
|
|
77
80
|
isLoopback(): boolean;
|
|
78
81
|
/**
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
* Checks whether this address is the unspecified address.
|
|
83
|
+
* @see https://tools.ietf.org/html/rfc4291
|
|
84
|
+
* @returns `true` when the address is `::`, otherwise `false`.
|
|
85
|
+
* @since v0.0.1
|
|
86
|
+
*/
|
|
84
87
|
isUnspecified(): boolean;
|
|
85
88
|
/**
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
* Checks whether this address is a multicast address.
|
|
90
|
+
* @see https://tools.ietf.org/html/rfc4291
|
|
91
|
+
* @returns `true` when the address is in `ff00::/8`, otherwise `false`.
|
|
92
|
+
* @since v0.0.1
|
|
93
|
+
*/
|
|
91
94
|
isMulticast(): boolean;
|
|
92
95
|
/**
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
* Checks whether this address is a multicast interface-local address.
|
|
97
|
+
* @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
|
|
98
|
+
* @returns `true` when the address is in `ff01::/16`, otherwise `false`.
|
|
99
|
+
* @since v0.0.2
|
|
100
|
+
*/
|
|
98
101
|
isMulticastInterfaceLocal(): boolean;
|
|
99
102
|
/**
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
* Checks whether this address is a multicast link-local address.
|
|
104
|
+
* @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
|
|
105
|
+
* @returns `true` when the address is in `ff02::/16`, otherwise `false`.
|
|
106
|
+
* @since v0.0.2
|
|
107
|
+
*/
|
|
105
108
|
isMulticastLinkLocal(): boolean;
|
|
106
109
|
/**
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
* Checks whether this address is a multicast realm-local address.
|
|
111
|
+
* @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
|
|
112
|
+
* @returns `true` when the address is in `ff03::/16`, otherwise `false`.
|
|
113
|
+
* @since v0.0.2
|
|
114
|
+
*/
|
|
112
115
|
isMulticastRealmLocal(): boolean;
|
|
113
116
|
/**
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
* Checks whether this address is a multicast admin-local address.
|
|
118
|
+
* @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
|
|
119
|
+
* @returns `true` when the address is in `ff04::/16`, otherwise `false`.
|
|
120
|
+
* @since v0.0.2
|
|
121
|
+
*/
|
|
119
122
|
isMulticastAdminLocal(): boolean;
|
|
120
123
|
/**
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
* Checks whether this address is a multicast site-local address.
|
|
125
|
+
* @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
|
|
126
|
+
* @returns `true` when the address is in `ff05::/16`, otherwise `false`.
|
|
127
|
+
* @since v0.0.2
|
|
128
|
+
*/
|
|
126
129
|
isMulticastSiteLocal(): boolean;
|
|
127
130
|
/**
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
* Checks whether this address is a multicast organization-local address.
|
|
132
|
+
* @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
|
|
133
|
+
* @returns `true` when the address is in `ff08::/16`, otherwise `false`.
|
|
134
|
+
* @since v0.0.2
|
|
135
|
+
*/
|
|
133
136
|
isMulticastOrganizationLocal(): boolean;
|
|
134
137
|
/**
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
* Checks whether this address is a multicast global address.
|
|
139
|
+
* @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
|
|
140
|
+
* @returns `true` when the address is in `ff0e::/16`, otherwise `false`.
|
|
141
|
+
* @since v0.0.2
|
|
142
|
+
*/
|
|
140
143
|
isMulticastGlobal(): boolean;
|
|
141
144
|
/**
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
145
|
+
* Checks whether this address is an IPv4-mapped IPv6 address.
|
|
146
|
+
* @returns `true` when the address is in `::ffff:0:0/96`, otherwise `false`.
|
|
147
|
+
* @since v0.0.1
|
|
148
|
+
*/
|
|
146
149
|
isIpv4Mapped(): boolean;
|
|
147
150
|
/**
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
151
|
+
* Checks whether this address is a unicast address.
|
|
152
|
+
* @see https://tools.ietf.org/html/rfc4291
|
|
153
|
+
* @returns `true` when the address is not multicast, otherwise `false`.
|
|
154
|
+
* @since v0.0.1
|
|
155
|
+
*/
|
|
153
156
|
isUnicast(): boolean;
|
|
154
157
|
/**
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
* Checks whether this address is a link-local unicast address.
|
|
159
|
+
* @see https://tools.ietf.org/html/rfc4291
|
|
160
|
+
* @returns `true` when the address is in `fe80::/10`, otherwise `false`.
|
|
161
|
+
* @since v0.0.1
|
|
162
|
+
*/
|
|
160
163
|
isUnicastLinkLocal(): boolean;
|
|
161
164
|
/**
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
* Checks whether this address is a global unicast address.
|
|
166
|
+
* @see https://tools.ietf.org/html/rfc4291#section-2.5.7
|
|
167
|
+
* @returns `true` when the address is unicast and not loopback, link-local, private, unspecified, or documentation.
|
|
168
|
+
* @since v0.0.1
|
|
169
|
+
*/
|
|
167
170
|
isUnicastGlobal(): boolean;
|
|
168
171
|
/**
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
172
|
+
* Checks whether this address appears globally reachable.
|
|
173
|
+
* @see https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml
|
|
174
|
+
* @returns `true` when the address is not in known non-global special ranges.
|
|
175
|
+
* @since v0.0.1
|
|
176
|
+
*/
|
|
174
177
|
isGlobal(): boolean;
|
|
175
178
|
/**
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
* Checks whether this address is in the unique-local range.
|
|
180
|
+
* @see https://tools.ietf.org/html/rfc4193
|
|
181
|
+
* @returns `true` when the address is in `fc00::/7`, otherwise `false`.
|
|
182
|
+
* @since v0.0.1
|
|
183
|
+
*/
|
|
181
184
|
isUniqueLocal(): boolean;
|
|
182
185
|
/**
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
186
|
+
* Converts this address to IPv4 when compatible or mapped.
|
|
187
|
+
* @returns An IPv4 address for `::a.b.c.d` or `::ffff:a.b.c.d`; otherwise `None`.
|
|
188
|
+
* @since v0.0.1
|
|
189
|
+
*/
|
|
187
190
|
toIpv4(): IOption<Ipv4Addr>;
|
|
188
191
|
/**
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
192
|
+
* Converts this address to IPv4 only when it is IPv4-mapped.
|
|
193
|
+
* @returns An IPv4 address for `::ffff:a.b.c.d`; otherwise `None`.
|
|
194
|
+
* @since v0.0.1
|
|
195
|
+
*/
|
|
193
196
|
toIpv4Mapped(): IOption<Ipv4Addr>;
|
|
194
197
|
/**
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
198
|
+
* Formats this address as a compressed IPv6 string.
|
|
199
|
+
* @returns The shortest standard IPv6 text form.
|
|
200
|
+
* @since v0.0.1
|
|
201
|
+
*/
|
|
199
202
|
toString(): string;
|
|
200
203
|
/**
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
204
|
+
* Encodes this address to a 16-byte buffer.
|
|
205
|
+
* @param littleEndian Whether to use little-endian byte order. Defaults to `false`.
|
|
206
|
+
* @returns An `ArrayBuffer` containing the IPv6 integer value.
|
|
207
|
+
* @since v0.0.1
|
|
208
|
+
*/
|
|
206
209
|
toBuffer(littleEndian?: boolean): ArrayBuffer;
|
|
207
210
|
/**
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
211
|
+
* Compares this IPv6 address with another for equality.
|
|
212
|
+
* @param other instance of another IPv6 address to compare with.
|
|
213
|
+
* @returns `true` if both addresses are equal, otherwise `false`.
|
|
214
|
+
* @since v0.1.0
|
|
215
|
+
*/
|
|
213
216
|
equals(other: Ipv6Addr | Ipv4Addr | object): boolean;
|
|
214
217
|
}
|
|
215
218
|
//#endregion
|
|
216
219
|
//#region src/Ipv4Addr.d.ts
|
|
217
220
|
/**
|
|
218
|
-
* Represents an IPv4 address.
|
|
219
|
-
* @example
|
|
220
|
-
* const addr1 = Ipv4Addr.from('192.168.0.1').unwrap();
|
|
221
|
-
* const addr2 = new Ipv4Addr(192, 168, 0, 1);
|
|
222
|
-
* const addr3 = new Ipv4Addr(0xc0a80001);
|
|
223
|
-
* @since v0.0.1
|
|
224
|
-
*/
|
|
221
|
+
* Represents an IPv4 address.
|
|
222
|
+
* @example
|
|
223
|
+
* const addr1 = Ipv4Addr.from('192.168.0.1').unwrap();
|
|
224
|
+
* const addr2 = new Ipv4Addr(192, 168, 0, 1);
|
|
225
|
+
* const addr3 = new Ipv4Addr(0xc0a80001);
|
|
226
|
+
* @since v0.0.1
|
|
227
|
+
*/
|
|
225
228
|
declare class Ipv4Addr {
|
|
226
229
|
#private;
|
|
227
230
|
/**
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
231
|
+
* Creates an IPv4 address from dotted-decimal text.
|
|
232
|
+
* @returns A successful {@link IResult} with an IPv4 address, or an error when the input is invalid.
|
|
233
|
+
* @since v0.0.1
|
|
234
|
+
*/
|
|
232
235
|
static from(value: string): IResult<Ipv4Addr, TypeError>;
|
|
233
236
|
/**
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
237
|
+
* Creates an IPv4 address from a 4-byte buffer.
|
|
238
|
+
* @returns A successful {@link IResult} with an IPv4 address, or an error when the buffer cannot be read.
|
|
239
|
+
* @since v0.0.1
|
|
240
|
+
*/
|
|
238
241
|
static fromBuffer(buffer: ArrayBuffer, littleEndian?: boolean): IResult<Ipv4Addr>;
|
|
239
242
|
/**
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
+
* The number of bits in an IPv4 address.
|
|
244
|
+
* @since v0.0.1
|
|
245
|
+
*/
|
|
243
246
|
static readonly BITS = 32;
|
|
244
247
|
/**
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
+
* The broadcast address `255.255.255.255`.
|
|
249
|
+
* @since v0.0.1
|
|
250
|
+
*/
|
|
248
251
|
static readonly BROADCAST: Ipv4Addr;
|
|
249
252
|
/**
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
+
* The localhost address `127.0.0.1`.
|
|
254
|
+
* @since v0.0.1
|
|
255
|
+
*/
|
|
253
256
|
static readonly LOCALHOST: Ipv4Addr;
|
|
254
257
|
/**
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
+
* The unspecified address `0.0.0.0`.
|
|
259
|
+
* @since v0.0.1
|
|
260
|
+
*/
|
|
258
261
|
static readonly UNSPECIFIED: Ipv4Addr;
|
|
259
262
|
/**
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
+
* The address family identifier for IPv4 addresses.
|
|
264
|
+
* @since v0.0.1
|
|
265
|
+
*/
|
|
263
266
|
readonly family = "ipv4";
|
|
264
267
|
/**
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
268
|
+
* Gets the raw integer representation of the IPv4 address.
|
|
269
|
+
*/
|
|
270
|
+
get value(): number;
|
|
271
|
+
/**
|
|
272
|
+
* Creates a new IPv4 address from four octets.
|
|
273
|
+
* @param num1 The first octet.
|
|
274
|
+
* @param num2 The second octet.
|
|
275
|
+
* @param num3 The third octet.
|
|
276
|
+
* @param num4 The fourth octet.
|
|
277
|
+
* @throws {RangeError} If the integer values are not in the range of 0 to 255 for each octet.
|
|
278
|
+
* @throws {TypeError} If the input is not a number.
|
|
279
|
+
* @example
|
|
280
|
+
* new Ipv4Addr(192, 168, 0, 1) // creates the address `192.168.0.1`
|
|
281
|
+
*/
|
|
275
282
|
constructor(num1: number, num2: number, num3: number, num4: number);
|
|
276
283
|
/**
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
+
* Creates a new IPv4 address from an integer value.
|
|
285
|
+
* @param integerValue The integer representation of the IPv4 address.
|
|
286
|
+
* @throws {RangeError} If the integer value is not in the range of 0 to 0xffffffff.
|
|
287
|
+
* @throws {TypeError} If the input is not a number.
|
|
288
|
+
* @example
|
|
289
|
+
* new Ipv4Addr(0xc0a80001) // creates the address `192.168.0.1` from the integer value `0xc0a80001`
|
|
290
|
+
*/
|
|
284
291
|
constructor(integerValue: number);
|
|
285
292
|
/**
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
293
|
+
* Checks whether this address is the broadcast address.
|
|
294
|
+
* @see https://datatracker.ietf.org/doc/html/rfc919#section-7
|
|
295
|
+
* @returns `true` when the address is `255.255.255.255`, otherwise `false`.
|
|
296
|
+
* @since v0.0.1
|
|
297
|
+
*/
|
|
291
298
|
isBroadcast(): boolean;
|
|
292
299
|
/**
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
300
|
+
* Checks whether this address is in a documentation-only range.
|
|
301
|
+
* @see https://datatracker.ietf.org/doc/html/rfc5737
|
|
302
|
+
* @returns `true` for `192.0.2.0/24`, `198.51.100.0/24`, or `203.0.113.0/24`; otherwise `false`.
|
|
303
|
+
* @since v0.0.1
|
|
304
|
+
*/
|
|
298
305
|
isDocumentation(): boolean;
|
|
299
306
|
/**
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
307
|
+
* Checks whether this address is in the benchmarking range.
|
|
308
|
+
* @see https://datatracker.ietf.org/doc/html/rfc2544
|
|
309
|
+
* @returns `true` when the address is in `198.18.0.0/15`, otherwise `false`.
|
|
310
|
+
* @since v0.0.1
|
|
311
|
+
*/
|
|
305
312
|
isBenchmarking(): boolean;
|
|
306
313
|
/**
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
314
|
+
* Checks whether this address is globally reachable.
|
|
315
|
+
* @see https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml
|
|
316
|
+
* @returns `true` when the address is not in any special non-global range.
|
|
317
|
+
* @since v0.0.1
|
|
318
|
+
*/
|
|
312
319
|
isGlobal(): boolean;
|
|
313
320
|
/**
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
321
|
+
* Checks whether this address is link-local.
|
|
322
|
+
* @see https://datatracker.ietf.org/doc/html/rfc3927
|
|
323
|
+
* @returns `true` when the address is in `169.254.0.0/16`, otherwise `false`.
|
|
324
|
+
* @since v0.0.1
|
|
325
|
+
*/
|
|
319
326
|
isLinkLocal(): boolean;
|
|
320
327
|
/**
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
328
|
+
* Checks whether this address is a loopback address.
|
|
329
|
+
* @see https://datatracker.ietf.org/doc/html/rfc1122
|
|
330
|
+
* @returns `true` when the address is in `127.0.0.0/8`, otherwise `false`.
|
|
331
|
+
* @since v0.0.1
|
|
332
|
+
*/
|
|
326
333
|
isLoopback(): boolean;
|
|
327
334
|
/**
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
335
|
+
* Checks whether this address is a multicast address.
|
|
336
|
+
* @see https://datatracker.ietf.org/doc/html/rfc5771
|
|
337
|
+
* @returns `true` when the address is in `224.0.0.0/4`, otherwise `false`.
|
|
338
|
+
* @since v0.0.1
|
|
339
|
+
*/
|
|
333
340
|
isMulticast(): boolean;
|
|
334
341
|
/**
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
342
|
+
* Checks whether this address is in a private-use range.
|
|
343
|
+
* @see https://datatracker.ietf.org/doc/html/rfc1918
|
|
344
|
+
* @returns `true` for `10.0.0.0/8`, `172.16.0.0/12`, or `192.168.0.0/16`; otherwise `false`.
|
|
345
|
+
* @since v0.0.1
|
|
346
|
+
*/
|
|
340
347
|
isPrivate(): boolean;
|
|
341
348
|
/**
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
349
|
+
* Checks whether this address is in the reserved range.
|
|
350
|
+
* @see https://datatracker.ietf.org/doc/html/rfc1112
|
|
351
|
+
* @returns `true` when the address is in `240.0.0.0/4` except the broadcast address.
|
|
352
|
+
* @since v0.0.1
|
|
353
|
+
*/
|
|
347
354
|
isReserved(): boolean;
|
|
348
355
|
/**
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
356
|
+
* Checks whether this address is in the shared Carrier-Grade NAT range.
|
|
357
|
+
* @see https://datatracker.ietf.org/doc/html/rfc6598
|
|
358
|
+
* @returns `true` when the address is in `100.64.0.0/10`, otherwise `false`.
|
|
359
|
+
* @since v0.0.1
|
|
360
|
+
*/
|
|
354
361
|
isShared(): boolean;
|
|
355
362
|
/**
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
363
|
+
* Checks whether this address is the unspecified address.
|
|
364
|
+
* @returns `true` when the address is `0.0.0.0`, otherwise `false`.
|
|
365
|
+
* @since v0.0.1
|
|
366
|
+
*/
|
|
360
367
|
isUnspecified(): boolean;
|
|
361
368
|
/**
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
369
|
+
* Converts this address to an IPv4-compatible IPv6 address.
|
|
370
|
+
* @returns An IPv6 address in the form `::a.b.c.d`.
|
|
371
|
+
* @since v0.0.1
|
|
372
|
+
*/
|
|
366
373
|
toIpv6(): Ipv6Addr;
|
|
367
374
|
/**
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
375
|
+
* Converts this address to an IPv4-mapped IPv6 address.
|
|
376
|
+
* @returns An IPv6 address in the form `::ffff:a.b.c.d`.
|
|
377
|
+
* @since v0.0.1
|
|
378
|
+
*/
|
|
372
379
|
toIpv6Mapped(): Ipv6Addr;
|
|
373
380
|
/**
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
381
|
+
* Formats this address as dotted-decimal text.
|
|
382
|
+
* @returns The IPv4 string representation, such as `192.168.0.1`.
|
|
383
|
+
* @since v0.0.1
|
|
384
|
+
*/
|
|
378
385
|
toString(): string;
|
|
379
386
|
/**
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
387
|
+
* Encodes this address to a 4-byte buffer.
|
|
388
|
+
* @returns An `ArrayBuffer` containing the IPv4 integer value.
|
|
389
|
+
* @since v0.0.1
|
|
390
|
+
*/
|
|
384
391
|
toBuffer(littleEndian?: boolean): ArrayBuffer;
|
|
385
392
|
/**
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
393
|
+
* Compares this IPv4 address with another for equality.
|
|
394
|
+
* @param other instance of another IPv4 address to compare with.
|
|
395
|
+
* @returns `true` if both addresses are equal, otherwise `false`.
|
|
396
|
+
* @since v0.1.0
|
|
397
|
+
*/
|
|
391
398
|
equals(other: Ipv4Addr | Ipv6Addr | object): boolean;
|
|
392
399
|
}
|
|
393
400
|
//#endregion
|
|
394
|
-
|
|
401
|
+
//#region src/Ipv4Net.d.ts
|
|
402
|
+
/**
|
|
403
|
+
* Represents an IPv4 network.
|
|
404
|
+
* @example
|
|
405
|
+
* const addr = Ipv4Addr.from('192.168.0.1').unwrap();
|
|
406
|
+
* const network = Ipv4Net.fromAddr(addr, 24);
|
|
407
|
+
* @since v0.1.2
|
|
408
|
+
*/
|
|
409
|
+
declare class Ipv4Net {
|
|
410
|
+
#private;
|
|
411
|
+
readonly address: Ipv4Addr;
|
|
412
|
+
readonly size: number;
|
|
413
|
+
private constructor();
|
|
414
|
+
static fromAddr(address: Ipv4Addr, size: number): Ipv4Net;
|
|
415
|
+
static from(value: string): Ipv4Net;
|
|
416
|
+
isInRange(address: Ipv4Addr): boolean;
|
|
417
|
+
}
|
|
418
|
+
//#endregion
|
|
419
|
+
//#region src/Ipv6Net.d.ts
|
|
420
|
+
/**
|
|
421
|
+
* Represents an IPv6 network.
|
|
422
|
+
* @example
|
|
423
|
+
* const addr = Ipv6Addr.from('2001:db8::1').unwrap();
|
|
424
|
+
* const network = Ipv6Net.fromAddr(addr, 64);
|
|
425
|
+
* @since v0.1.2
|
|
426
|
+
*/
|
|
427
|
+
declare class Ipv6Net {
|
|
428
|
+
#private;
|
|
429
|
+
readonly address: Ipv6Addr;
|
|
430
|
+
readonly size: number;
|
|
431
|
+
private constructor();
|
|
432
|
+
static fromAddr(address: Ipv6Addr, size: number): Ipv6Net;
|
|
433
|
+
static from(value: string): Ipv6Net;
|
|
434
|
+
isInRange(address: Ipv6Addr): boolean;
|
|
435
|
+
}
|
|
436
|
+
//#endregion
|
|
437
|
+
export { Ipv4Addr, Ipv4Net, Ipv6Addr, Ipv6Net };
|
|
395
438
|
//# sourceMappingURL=index.d.cts.map
|