net-address 0.1.0 → 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 +315 -262
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +315 -262
- 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,385 +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
|
-
|
|
22
|
-
static from(value: string): IResult<Ipv6Addr>;
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
+
*/
|
|
21
|
+
static from(value: string): IResult<Ipv6Addr, TypeError | RangeError>;
|
|
22
|
+
/**
|
|
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";
|
|
48
|
+
/**
|
|
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
|
+
*/
|
|
49
58
|
constructor(value: bigint);
|
|
50
59
|
constructor(segments: [number, number, number, number, number, number, number, number]);
|
|
51
60
|
/**
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
+
*/
|
|
57
66
|
isBenchmarking(): boolean;
|
|
58
67
|
/**
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
+
*/
|
|
64
73
|
isDocumentation(): boolean;
|
|
65
74
|
/**
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
+
*/
|
|
71
80
|
isLoopback(): boolean;
|
|
72
81
|
/**
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
+
*/
|
|
78
87
|
isUnspecified(): boolean;
|
|
79
88
|
/**
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
+
*/
|
|
85
94
|
isMulticast(): boolean;
|
|
86
95
|
/**
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
+
*/
|
|
92
101
|
isMulticastInterfaceLocal(): boolean;
|
|
93
102
|
/**
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
+
*/
|
|
99
108
|
isMulticastLinkLocal(): boolean;
|
|
100
109
|
/**
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
+
*/
|
|
106
115
|
isMulticastRealmLocal(): boolean;
|
|
107
116
|
/**
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
+
*/
|
|
113
122
|
isMulticastAdminLocal(): boolean;
|
|
114
123
|
/**
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
+
*/
|
|
120
129
|
isMulticastSiteLocal(): boolean;
|
|
121
130
|
/**
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
+
*/
|
|
127
136
|
isMulticastOrganizationLocal(): boolean;
|
|
128
137
|
/**
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
+
*/
|
|
134
143
|
isMulticastGlobal(): boolean;
|
|
135
144
|
/**
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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
|
+
*/
|
|
140
149
|
isIpv4Mapped(): boolean;
|
|
141
150
|
/**
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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
|
+
*/
|
|
147
156
|
isUnicast(): boolean;
|
|
148
157
|
/**
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
+
*/
|
|
154
163
|
isUnicastLinkLocal(): boolean;
|
|
155
164
|
/**
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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
|
+
*/
|
|
161
170
|
isUnicastGlobal(): boolean;
|
|
162
171
|
/**
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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
|
+
*/
|
|
168
177
|
isGlobal(): boolean;
|
|
169
178
|
/**
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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
|
+
*/
|
|
175
184
|
isUniqueLocal(): boolean;
|
|
176
185
|
/**
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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
|
+
*/
|
|
181
190
|
toIpv4(): IOption<Ipv4Addr>;
|
|
182
191
|
/**
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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
|
+
*/
|
|
187
196
|
toIpv4Mapped(): IOption<Ipv4Addr>;
|
|
188
197
|
/**
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
198
|
+
* Formats this address as a compressed IPv6 string.
|
|
199
|
+
* @returns The shortest standard IPv6 text form.
|
|
200
|
+
* @since v0.0.1
|
|
201
|
+
*/
|
|
193
202
|
toString(): string;
|
|
194
203
|
/**
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
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
|
+
*/
|
|
200
209
|
toBuffer(littleEndian?: boolean): ArrayBuffer;
|
|
201
210
|
/**
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
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
|
+
*/
|
|
207
216
|
equals(other: Ipv6Addr | Ipv4Addr | object): boolean;
|
|
208
217
|
}
|
|
209
218
|
//#endregion
|
|
210
219
|
//#region src/Ipv4Addr.d.ts
|
|
211
220
|
/**
|
|
212
|
-
* Represents an IPv4 address.
|
|
213
|
-
* @example
|
|
214
|
-
* const addr1 = Ipv4Addr.from('192.168.0.1').unwrap();
|
|
215
|
-
* const addr2 = new Ipv4Addr(192, 168, 0, 1);
|
|
216
|
-
* const addr3 = new Ipv4Addr(0xc0a80001);
|
|
217
|
-
* @since v0.0.1
|
|
218
|
-
*/
|
|
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
|
+
*/
|
|
219
228
|
declare class Ipv4Addr {
|
|
220
229
|
#private;
|
|
221
230
|
/**
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
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
|
+
*/
|
|
226
235
|
static from(value: string): IResult<Ipv4Addr, TypeError>;
|
|
227
236
|
/**
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
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
|
+
*/
|
|
232
241
|
static fromBuffer(buffer: ArrayBuffer, littleEndian?: boolean): IResult<Ipv4Addr>;
|
|
233
242
|
/**
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
243
|
+
* The number of bits in an IPv4 address.
|
|
244
|
+
* @since v0.0.1
|
|
245
|
+
*/
|
|
237
246
|
static readonly BITS = 32;
|
|
238
247
|
/**
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
248
|
+
* The broadcast address `255.255.255.255`.
|
|
249
|
+
* @since v0.0.1
|
|
250
|
+
*/
|
|
242
251
|
static readonly BROADCAST: Ipv4Addr;
|
|
243
252
|
/**
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
253
|
+
* The localhost address `127.0.0.1`.
|
|
254
|
+
* @since v0.0.1
|
|
255
|
+
*/
|
|
247
256
|
static readonly LOCALHOST: Ipv4Addr;
|
|
248
257
|
/**
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
258
|
+
* The unspecified address `0.0.0.0`.
|
|
259
|
+
* @since v0.0.1
|
|
260
|
+
*/
|
|
252
261
|
static readonly UNSPECIFIED: Ipv4Addr;
|
|
253
262
|
/**
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
263
|
+
* The address family identifier for IPv4 addresses.
|
|
264
|
+
* @since v0.0.1
|
|
265
|
+
*/
|
|
257
266
|
readonly family = "ipv4";
|
|
258
267
|
/**
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
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
|
+
*/
|
|
267
282
|
constructor(num1: number, num2: number, num3: number, num4: number);
|
|
268
283
|
/**
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
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
|
+
*/
|
|
274
291
|
constructor(integerValue: number);
|
|
275
292
|
/**
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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
|
+
*/
|
|
281
298
|
isBroadcast(): boolean;
|
|
282
299
|
/**
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
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
|
+
*/
|
|
288
305
|
isDocumentation(): boolean;
|
|
289
306
|
/**
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
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
|
+
*/
|
|
295
312
|
isBenchmarking(): boolean;
|
|
296
313
|
/**
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
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
|
+
*/
|
|
302
319
|
isGlobal(): boolean;
|
|
303
320
|
/**
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
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
|
+
*/
|
|
309
326
|
isLinkLocal(): boolean;
|
|
310
327
|
/**
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
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
|
+
*/
|
|
316
333
|
isLoopback(): boolean;
|
|
317
334
|
/**
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
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
|
+
*/
|
|
323
340
|
isMulticast(): boolean;
|
|
324
341
|
/**
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
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
|
+
*/
|
|
330
347
|
isPrivate(): boolean;
|
|
331
348
|
/**
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
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
|
+
*/
|
|
337
354
|
isReserved(): boolean;
|
|
338
355
|
/**
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
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
|
+
*/
|
|
344
361
|
isShared(): boolean;
|
|
345
362
|
/**
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
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
|
+
*/
|
|
350
367
|
isUnspecified(): boolean;
|
|
351
368
|
/**
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
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
|
+
*/
|
|
356
373
|
toIpv6(): Ipv6Addr;
|
|
357
374
|
/**
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
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
|
+
*/
|
|
362
379
|
toIpv6Mapped(): Ipv6Addr;
|
|
363
380
|
/**
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
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
|
+
*/
|
|
368
385
|
toString(): string;
|
|
369
386
|
/**
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
387
|
+
* Encodes this address to a 4-byte buffer.
|
|
388
|
+
* @returns An `ArrayBuffer` containing the IPv4 integer value.
|
|
389
|
+
* @since v0.0.1
|
|
390
|
+
*/
|
|
374
391
|
toBuffer(littleEndian?: boolean): ArrayBuffer;
|
|
375
392
|
/**
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
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
|
+
*/
|
|
381
398
|
equals(other: Ipv4Addr | Ipv6Addr | object): boolean;
|
|
382
399
|
}
|
|
383
400
|
//#endregion
|
|
384
|
-
|
|
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 };
|
|
385
438
|
//# sourceMappingURL=index.d.cts.map
|