cidr-tools 5.0.7 → 5.0.9
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/README.md +1 -1
- package/index.js +6 -6
- package/package.json +6 -7
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ exclude(['::1/127'], ['::1/128']) //=> ['::/128']
|
|
|
18
18
|
expand(['2001:db8::/126']) //=> ['2001:db8::', '2001:db8::1', '2001:db8::2', '2001:db8::3']
|
|
19
19
|
overlap('1.0.0.0/24', '1.0.0.128/25') //=> true
|
|
20
20
|
contains(["1.0.0.0/24", "2.0.0.0/24"], "1.0.0.1") //=> true
|
|
21
|
-
normalize('
|
|
21
|
+
normalize('::ffff/64') //=> '::/64'
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
## API
|
package/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import IPCIDR from "ip-cidr";
|
|
2
2
|
import ipRegex from "ip-regex";
|
|
3
3
|
import isCidr from "is-cidr";
|
|
4
|
-
import ipv6Normalize from "ipv6-normalize";
|
|
5
4
|
import naturalCompare from "string-natural-compare";
|
|
6
|
-
import {stringifyIp} from "ip-bigint";
|
|
5
|
+
import {parseIp, stringifyIp} from "ip-bigint";
|
|
7
6
|
import {BigInteger} from "jsbn";
|
|
8
7
|
|
|
9
8
|
const bits = {
|
|
@@ -12,6 +11,7 @@ const bits = {
|
|
|
12
11
|
};
|
|
13
12
|
|
|
14
13
|
const bigint = numberstring => new BigInteger(numberstring);
|
|
14
|
+
const normalizeIp = str => stringifyIp(parseIp(str));
|
|
15
15
|
const uniq = arr => [...new Set(arr)];
|
|
16
16
|
|
|
17
17
|
const zero = bigint("0");
|
|
@@ -31,7 +31,7 @@ function doNormalize(cidr) {
|
|
|
31
31
|
if (cidrVersion) {
|
|
32
32
|
// set network address to first address
|
|
33
33
|
let start = (new IPCIDR(cidr)).start();
|
|
34
|
-
if (cidrVersion === 6) start =
|
|
34
|
+
if (cidrVersion === 6) start = normalizeIp(start);
|
|
35
35
|
if (start) {
|
|
36
36
|
return `${start}${cidr.match(/\/.+/)}`.toLowerCase();
|
|
37
37
|
}
|
|
@@ -39,10 +39,10 @@ function doNormalize(cidr) {
|
|
|
39
39
|
|
|
40
40
|
// single ip
|
|
41
41
|
const parsed = parse(cidr);
|
|
42
|
-
if (parsed
|
|
42
|
+
if (parsed?.address?.v4) {
|
|
43
43
|
return cidr;
|
|
44
|
-
} else if (parsed
|
|
45
|
-
return
|
|
44
|
+
} else if (parsed?.address?.v4 === false) {
|
|
45
|
+
return normalizeIp(cidr);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
throw new Error(`Invalid network: ${cidr}`);
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cidr-tools",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.9",
|
|
4
4
|
"author": "silverwind <me@silverwind.io>",
|
|
5
5
|
"description": "Tools to work with IPv4 and IPv6 CIDR network lists",
|
|
6
6
|
"repository": "silverwind/cidr-tools",
|
|
7
7
|
"license": "BSD-2-Clause",
|
|
8
8
|
"type": "module",
|
|
9
|
-
"
|
|
9
|
+
"exports": "./index.js",
|
|
10
10
|
"sideEffects": false,
|
|
11
11
|
"engines": {
|
|
12
12
|
"node": ">=14"
|
|
@@ -29,11 +29,10 @@
|
|
|
29
29
|
],
|
|
30
30
|
"types": "./index.d.ts",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"ip-bigint": "5.0.
|
|
32
|
+
"ip-bigint": "5.0.3",
|
|
33
33
|
"ip-cidr": "3.0.10",
|
|
34
34
|
"ip-regex": "5.0.0",
|
|
35
|
-
"
|
|
36
|
-
"is-cidr": "5.0.1",
|
|
35
|
+
"is-cidr": "5.0.2",
|
|
37
36
|
"jsbn": "^1.1.0",
|
|
38
37
|
"string-natural-compare": "3.0.1"
|
|
39
38
|
},
|
|
@@ -41,7 +40,7 @@
|
|
|
41
40
|
"eslint": "8.23.1",
|
|
42
41
|
"eslint-config-silverwind": "54.0.2",
|
|
43
42
|
"jest": "29.0.3",
|
|
44
|
-
"updates": "13.1.
|
|
45
|
-
"versions": "9.3.
|
|
43
|
+
"updates": "13.1.7",
|
|
44
|
+
"versions": "9.3.2"
|
|
46
45
|
}
|
|
47
46
|
}
|