ip-utilties 3.1.1 → 3.1.3
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/package.json +3 -3
- package/src/ip.mjs +26 -2
- package/types/ip.d.mts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ip-utilties",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"ava": "^8.0.1",
|
|
44
|
-
"browser-ava": "^2.3.
|
|
44
|
+
"browser-ava": "^2.3.64",
|
|
45
45
|
"c8": "^11.0.0",
|
|
46
46
|
"documentation": "^14.0.3",
|
|
47
47
|
"semantic-release": "^25.0.5",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
"engines": {
|
|
56
|
-
"node": ">=26.
|
|
56
|
+
"node": ">=26.4.0"
|
|
57
57
|
},
|
|
58
58
|
"repository": {
|
|
59
59
|
"type": "git",
|
package/src/ip.mjs
CHANGED
|
@@ -290,7 +290,8 @@ export function formatCIDR(address, prefixLength) {
|
|
|
290
290
|
}
|
|
291
291
|
|
|
292
292
|
export function normalizeIP(address) {
|
|
293
|
-
|
|
293
|
+
const f = _family(address);
|
|
294
|
+
return f && _decode(f, _encode(f, address));
|
|
294
295
|
}
|
|
295
296
|
|
|
296
297
|
export function reverseArpa(address) {
|
|
@@ -330,7 +331,11 @@ export function isLocalhost(address) {
|
|
|
330
331
|
|
|
331
332
|
export function isLinkLocal(address) {
|
|
332
333
|
const eaddr = encodeIP(address);
|
|
333
|
-
|
|
334
|
+
if (eaddr) {
|
|
335
|
+
return eaddr[0] === 0xfe80 || (eaddr[0] === 169 && eaddr[1] === 254);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
return false;
|
|
334
339
|
}
|
|
335
340
|
|
|
336
341
|
export function isUniqueLocal(address) {
|
|
@@ -342,6 +347,25 @@ export function hasWellKnownSubnet(address) {
|
|
|
342
347
|
return isLocalhost(address) || isLinkLocal(address) || isUniqueLocal(address);
|
|
343
348
|
}
|
|
344
349
|
|
|
350
|
+
/*
|
|
351
|
+
prefix global subnet interface
|
|
352
|
+
|
|
353
|
+
ff01:: ff02:: 1
|
|
354
|
+
ff05:: 2 3
|
|
355
|
+
|
|
356
|
+
https://en.wikipedia.org/wiki/Link-local_address
|
|
357
|
+
fe80:: 64 link local
|
|
358
|
+
169.254. /16 link local
|
|
359
|
+
|
|
360
|
+
https://en.wikipedia.org/wiki/Unique_local_address
|
|
361
|
+
fc00:: 64 unique local
|
|
362
|
+
fd00:: 64 unique local
|
|
363
|
+
|
|
364
|
+
::1 128. local host
|
|
365
|
+
127 8 local host
|
|
366
|
+
172
|
|
367
|
+
*/
|
|
368
|
+
|
|
345
369
|
/*
|
|
346
370
|
* https://www.iana.org/assignments/ipv6-multicast-addresses/ipv6-multicast-addresses.xhtml
|
|
347
371
|
*/
|
package/types/ip.d.mts
CHANGED
|
@@ -38,7 +38,7 @@ export function normalizeCIDR(address: any): {
|
|
|
38
38
|
cidr: string;
|
|
39
39
|
};
|
|
40
40
|
export function formatCIDR(address: any, prefixLength: any): any;
|
|
41
|
-
export function normalizeIP(address: any): string;
|
|
41
|
+
export function normalizeIP(address: any): string | undefined;
|
|
42
42
|
export function reverseArpa(address: any): string;
|
|
43
43
|
export function isLocalhost(address: any): boolean;
|
|
44
44
|
export function isLinkLocal(address: any): boolean;
|