@libp2p/utils 6.2.1-f2f9008b8 → 6.2.1-f8da60e73
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link-local-ip.d.ts","sourceRoot":"","sources":["../../src/link-local-ip.ts"],"names":[],"mappings":"AAEA,wBAAgB,aAAa,CAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAUlD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { isIPv4, isIPv6 } from '@chainsafe/is-ip';
|
|
2
|
+
export function isLinkLocalIp(ip) {
|
|
3
|
+
if (isIPv4(ip)) {
|
|
4
|
+
return ip.startsWith('169.254.');
|
|
5
|
+
}
|
|
6
|
+
if (isIPv6(ip)) {
|
|
7
|
+
return ip.toLowerCase().startsWith('fe80');
|
|
8
|
+
}
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=link-local-ip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link-local-ip.js","sourceRoot":"","sources":["../../src/link-local-ip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEjD,MAAM,UAAU,aAAa,CAAE,EAAU;IACvC,IAAI,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;QACf,OAAO,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAA;IAClC,CAAC;IAED,IAAI,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;QACf,OAAO,EAAE,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;IAC5C,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/utils",
|
|
3
|
-
"version": "6.2.1-
|
|
3
|
+
"version": "6.2.1-f8da60e73",
|
|
4
4
|
"description": "Package to aggregate shared logic and dependencies for the libp2p ecosystem",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/utils#readme",
|
|
@@ -84,6 +84,10 @@
|
|
|
84
84
|
"types": "./dist/src/is-promise.d.ts",
|
|
85
85
|
"import": "./dist/src/is-promise.js"
|
|
86
86
|
},
|
|
87
|
+
"./link-local-ip": {
|
|
88
|
+
"types": "./dist/src/link-local-ip.d.ts",
|
|
89
|
+
"import": "./dist/src/link-local-ip.js"
|
|
90
|
+
},
|
|
87
91
|
"./moving-average": {
|
|
88
92
|
"types": "./dist/src/moving-average.d.ts",
|
|
89
93
|
"import": "./dist/src/moving-average.js"
|
|
@@ -160,9 +164,9 @@
|
|
|
160
164
|
},
|
|
161
165
|
"dependencies": {
|
|
162
166
|
"@chainsafe/is-ip": "^2.0.2",
|
|
163
|
-
"@libp2p/crypto": "5.0.7-
|
|
164
|
-
"@libp2p/interface": "2.2.1-
|
|
165
|
-
"@libp2p/logger": "5.1.4-
|
|
167
|
+
"@libp2p/crypto": "5.0.7-f8da60e73",
|
|
168
|
+
"@libp2p/interface": "2.2.1-f8da60e73",
|
|
169
|
+
"@libp2p/logger": "5.1.4-f8da60e73",
|
|
166
170
|
"@multiformats/multiaddr": "^12.3.3",
|
|
167
171
|
"@sindresorhus/fnv1a": "^3.1.0",
|
|
168
172
|
"@types/murmurhash3js-revisited": "^3.0.3",
|
|
@@ -183,7 +187,7 @@
|
|
|
183
187
|
"uint8arrays": "^5.1.0"
|
|
184
188
|
},
|
|
185
189
|
"devDependencies": {
|
|
186
|
-
"@libp2p/peer-id": "5.0.8-
|
|
190
|
+
"@libp2p/peer-id": "5.0.8-f8da60e73",
|
|
187
191
|
"@types/netmask": "^2.0.5",
|
|
188
192
|
"aegir": "^45.0.5",
|
|
189
193
|
"benchmark": "^2.1.4",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { isIPv4, isIPv6 } from '@chainsafe/is-ip'
|
|
2
|
+
|
|
3
|
+
export function isLinkLocalIp (ip: string): boolean {
|
|
4
|
+
if (isIPv4(ip)) {
|
|
5
|
+
return ip.startsWith('169.254.')
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (isIPv6(ip)) {
|
|
9
|
+
return ip.toLowerCase().startsWith('fe80')
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return false
|
|
13
|
+
}
|