ip-utilties 3.6.1 → 3.6.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.
Files changed (3) hide show
  1. package/README.md +3 -0
  2. package/package.json +4 -3
  3. package/src/ip.mjs +6 -10
package/README.md CHANGED
@@ -11,6 +11,9 @@
11
11
 
12
12
  ip-v4/v6 utility functions
13
13
 
14
+ - encoding / decoding
15
+ - well known subnets
16
+
14
17
  ## Three different representations
15
18
 
16
19
  ```javascript
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ip-utilties",
3
- "version": "3.6.1",
3
+ "version": "3.6.2",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -13,6 +13,7 @@
13
13
  },
14
14
  "description": "ip v4/v6 utility functions",
15
15
  "keywords": [
16
+ "address",
16
17
  "cidr",
17
18
  "ip",
18
19
  "ipv4",
@@ -41,10 +42,10 @@
41
42
  },
42
43
  "devDependencies": {
43
44
  "ava": "^8.0.1",
44
- "browser-ava": "^2.3.66",
45
+ "browser-ava": "^2.3.67",
45
46
  "c8": "^11.0.0",
46
47
  "documentation": "^14.0.3",
47
- "semantic-release": "^25.0.6",
48
+ "semantic-release": "^25.0.7",
48
49
  "typescript": "^7.0.2"
49
50
  },
50
51
  "overrides": {
package/src/ip.mjs CHANGED
@@ -23,7 +23,7 @@ const ipv4 = {
23
23
 
24
24
  // https://www.geeksforgeeks.org/computer-networks/subnet-cheat-sheet/
25
25
  wellKnownAddresses: [
26
- [new Uint8Array([169, 254, 0, 0]), 16], // Link-local address (Autoconfiguration)
26
+ [new Uint8Array([169, 254, 0, 0]), 16, true], // Link-local address (Autoconfiguration)
27
27
 
28
28
  [new Uint8Array([0, 0, 0, 0]), 8], // This network
29
29
  [new Uint8Array([10, 0, 0, 0]), 8], // Private network (RFC 1918)
@@ -62,7 +62,11 @@ const ipv6 = {
62
62
  base: 16,
63
63
  localHost: new Uint16Array([0, 0, 0, 0, 0, 0, 0, 1]),
64
64
  localHostPrefixLenth: 128,
65
- wellKnownAddresses: [[new Uint16Array([0xfe80, 0, 0, 0, 0, 0, 0, 0]), 64]]
65
+ wellKnownAddresses: [
66
+ [new Uint16Array([0xfe80, 0, 0, 0, 0, 0, 0, 0]), 64, true],
67
+ [new Uint16Array([0xfd00, 0, 0, 0, 0, 0, 0, 0]), 8, false, true],
68
+ [new Uint16Array([0, 0, 0, 0, 0, 0, 0, 1]), 128, false, true]
69
+ ]
66
70
  };
67
71
 
68
72
  const families = [ipv4, ipv6];
@@ -417,14 +421,6 @@ export function wellKnownSubnet(address) {
417
421
  export function _wellKnownSubnet(family, address) {
418
422
  const encoded = _encode(family, address);
419
423
 
420
- if (_equal(family.localHost, encoded)) {
421
- return [family.localHost, family.localHostPrefixLenth];
422
- }
423
-
424
- if (_isUniqueLocal(encoded)) {
425
- return [encoded[0], 64];
426
- }
427
-
428
424
  for (const c of family.wellKnownAddresses) {
429
425
  const pl = c[1];
430
426
  if (pl > 0 && _prefix(family, c[0], pl) === _prefix(family, encoded, pl)) {