pnpm 7.0.1 → 7.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/node_modules/.modules.yaml +2 -2
- package/dist/node_modules/.pnpm/lock.yaml +17 -8
- package/dist/node_modules/glob/common.js +2 -0
- package/dist/node_modules/glob/glob.js +4 -1
- package/dist/node_modules/glob/package.json +5 -2
- package/dist/node_modules/glob/sync.js +6 -3
- package/dist/node_modules/ip/lib/ip.js +106 -95
- package/dist/node_modules/ip/package.json +10 -6
- package/dist/pnpm.cjs +525 -251
- package/dist/pnpx.cjs +525 -251
- package/package.json +19 -20
- package/dist/node_modules/ip/.jscsrc +0 -46
|
@@ -7,11 +7,11 @@ included:
|
|
|
7
7
|
injectedDeps: {}
|
|
8
8
|
layoutVersion: 5
|
|
9
9
|
nodeLinker: hoisted
|
|
10
|
-
packageManager: pnpm@7.
|
|
10
|
+
packageManager: pnpm@7.1.1
|
|
11
11
|
pendingBuilds:
|
|
12
12
|
- /node-gyp/8.4.1
|
|
13
13
|
- /encoding/0.1.13
|
|
14
|
-
prunedAt:
|
|
14
|
+
prunedAt: Thu, 19 May 2022 01:33:24 GMT
|
|
15
15
|
publicHoistPattern:
|
|
16
16
|
- '*eslint*'
|
|
17
17
|
- '*prettier*'
|
|
@@ -113,7 +113,7 @@ packages:
|
|
|
113
113
|
'@npmcli/move-file': 1.1.2
|
|
114
114
|
chownr: 2.0.0
|
|
115
115
|
fs-minipass: 2.1.0
|
|
116
|
-
glob: 7.2.
|
|
116
|
+
glob: 7.2.3
|
|
117
117
|
infer-owner: 1.0.4
|
|
118
118
|
lru-cache: 6.0.0
|
|
119
119
|
minipass: 3.1.6
|
|
@@ -127,6 +127,8 @@ packages:
|
|
|
127
127
|
ssri: 8.0.1
|
|
128
128
|
tar: 6.1.11
|
|
129
129
|
unique-filename: 1.1.1
|
|
130
|
+
transitivePeerDependencies:
|
|
131
|
+
- bluebird
|
|
130
132
|
dev: false
|
|
131
133
|
optional: true
|
|
132
134
|
|
|
@@ -234,8 +236,8 @@ packages:
|
|
|
234
236
|
dev: false
|
|
235
237
|
optional: true
|
|
236
238
|
|
|
237
|
-
/glob/7.2.
|
|
238
|
-
resolution: {integrity: sha512-
|
|
239
|
+
/glob/7.2.3:
|
|
240
|
+
resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==}
|
|
239
241
|
dependencies:
|
|
240
242
|
fs.realpath: 1.0.0
|
|
241
243
|
inflight: 1.0.6
|
|
@@ -329,8 +331,8 @@ packages:
|
|
|
329
331
|
dev: false
|
|
330
332
|
optional: true
|
|
331
333
|
|
|
332
|
-
/ip/1.1.
|
|
333
|
-
resolution: {integrity:
|
|
334
|
+
/ip/1.1.8:
|
|
335
|
+
resolution: {integrity: sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg==}
|
|
334
336
|
dev: false
|
|
335
337
|
optional: true
|
|
336
338
|
|
|
@@ -379,6 +381,7 @@ packages:
|
|
|
379
381
|
socks-proxy-agent: 6.2.0
|
|
380
382
|
ssri: 8.0.1
|
|
381
383
|
transitivePeerDependencies:
|
|
384
|
+
- bluebird
|
|
382
385
|
- supports-color
|
|
383
386
|
dev: false
|
|
384
387
|
optional: true
|
|
@@ -481,7 +484,7 @@ packages:
|
|
|
481
484
|
requiresBuild: true
|
|
482
485
|
dependencies:
|
|
483
486
|
env-paths: 2.2.1
|
|
484
|
-
glob: 7.2.
|
|
487
|
+
glob: 7.2.3
|
|
485
488
|
graceful-fs: 4.2.10
|
|
486
489
|
make-fetch-happen: 9.1.0
|
|
487
490
|
nopt: 5.0.0
|
|
@@ -491,6 +494,7 @@ packages:
|
|
|
491
494
|
tar: 6.1.11
|
|
492
495
|
which: 2.0.2
|
|
493
496
|
transitivePeerDependencies:
|
|
497
|
+
- bluebird
|
|
494
498
|
- supports-color
|
|
495
499
|
dev: false
|
|
496
500
|
optional: true
|
|
@@ -538,6 +542,11 @@ packages:
|
|
|
538
542
|
|
|
539
543
|
/promise-inflight/1.0.1:
|
|
540
544
|
resolution: {integrity: sha1-mEcocL8igTL8vdhoEputEsPAKeM=}
|
|
545
|
+
peerDependencies:
|
|
546
|
+
bluebird: '*'
|
|
547
|
+
peerDependenciesMeta:
|
|
548
|
+
bluebird:
|
|
549
|
+
optional: true
|
|
541
550
|
dev: false
|
|
542
551
|
optional: true
|
|
543
552
|
|
|
@@ -570,7 +579,7 @@ packages:
|
|
|
570
579
|
resolution: {integrity: sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==}
|
|
571
580
|
hasBin: true
|
|
572
581
|
dependencies:
|
|
573
|
-
glob: 7.2.
|
|
582
|
+
glob: 7.2.3
|
|
574
583
|
dev: false
|
|
575
584
|
optional: true
|
|
576
585
|
|
|
@@ -625,7 +634,7 @@ packages:
|
|
|
625
634
|
resolution: {integrity: sha512-zDZhHhZRY9PxRruRMR7kMhnf3I8hDs4S3f9RecfnGxvcBHQcKcIH/oUcEWffsfl1XxdYlA7nnlGbbTvPz9D8gA==}
|
|
626
635
|
engines: {node: '>= 10.13.0', npm: '>= 3.0.0'}
|
|
627
636
|
dependencies:
|
|
628
|
-
ip: 1.1.
|
|
637
|
+
ip: 1.1.8
|
|
629
638
|
smart-buffer: 4.2.0
|
|
630
639
|
dev: false
|
|
631
640
|
optional: true
|
|
@@ -110,6 +110,8 @@ function setopts (self, pattern, options) {
|
|
|
110
110
|
// Note that they are not supported in Glob itself anyway.
|
|
111
111
|
options.nonegate = true
|
|
112
112
|
options.nocomment = true
|
|
113
|
+
// always treat \ in patterns as escapes, not path separators
|
|
114
|
+
options.allowWindowsEscape = false
|
|
113
115
|
|
|
114
116
|
self.minimatch = new Minimatch(pattern, options)
|
|
115
117
|
self.options = self.minimatch.options
|
|
@@ -342,7 +342,10 @@ Glob.prototype._process = function (pattern, index, inGlobStar, cb) {
|
|
|
342
342
|
var read
|
|
343
343
|
if (prefix === null)
|
|
344
344
|
read = '.'
|
|
345
|
-
else if (isAbsolute(prefix) ||
|
|
345
|
+
else if (isAbsolute(prefix) ||
|
|
346
|
+
isAbsolute(pattern.map(function (p) {
|
|
347
|
+
return typeof p === 'string' ? p : '[*]'
|
|
348
|
+
}).join('/'))) {
|
|
346
349
|
if (!prefix || !isAbsolute(prefix))
|
|
347
350
|
prefix = '/' + prefix
|
|
348
351
|
read = prefix
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
|
|
3
3
|
"name": "glob",
|
|
4
4
|
"description": "a little globber",
|
|
5
|
-
"version": "7.2.
|
|
5
|
+
"version": "7.2.3",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"tag": "v7-legacy"
|
|
8
|
+
},
|
|
6
9
|
"repository": {
|
|
7
10
|
"type": "git",
|
|
8
11
|
"url": "git://github.com/isaacs/node-glob.git"
|
|
@@ -20,7 +23,7 @@
|
|
|
20
23
|
"fs.realpath": "^1.0.0",
|
|
21
24
|
"inflight": "^1.0.4",
|
|
22
25
|
"inherits": "2",
|
|
23
|
-
"minimatch": "^3.
|
|
26
|
+
"minimatch": "^3.1.1",
|
|
24
27
|
"once": "^1.3.0",
|
|
25
28
|
"path-is-absolute": "^1.0.0"
|
|
26
29
|
},
|
|
@@ -48,7 +48,7 @@ function GlobSync (pattern, options) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
GlobSync.prototype._finish = function () {
|
|
51
|
-
assert(this instanceof GlobSync)
|
|
51
|
+
assert.ok(this instanceof GlobSync)
|
|
52
52
|
if (this.realpath) {
|
|
53
53
|
var self = this
|
|
54
54
|
this.matches.forEach(function (matchset, index) {
|
|
@@ -72,7 +72,7 @@ GlobSync.prototype._finish = function () {
|
|
|
72
72
|
|
|
73
73
|
|
|
74
74
|
GlobSync.prototype._process = function (pattern, index, inGlobStar) {
|
|
75
|
-
assert(this instanceof GlobSync)
|
|
75
|
+
assert.ok(this instanceof GlobSync)
|
|
76
76
|
|
|
77
77
|
// Get the first [n] parts of pattern that are all strings.
|
|
78
78
|
var n = 0
|
|
@@ -109,7 +109,10 @@ GlobSync.prototype._process = function (pattern, index, inGlobStar) {
|
|
|
109
109
|
var read
|
|
110
110
|
if (prefix === null)
|
|
111
111
|
read = '.'
|
|
112
|
-
else if (isAbsolute(prefix) ||
|
|
112
|
+
else if (isAbsolute(prefix) ||
|
|
113
|
+
isAbsolute(pattern.map(function (p) {
|
|
114
|
+
return typeof p === 'string' ? p : '[*]'
|
|
115
|
+
}).join('/'))) {
|
|
113
116
|
if (!prefix || !isAbsolute(prefix))
|
|
114
117
|
prefix = '/' + prefix
|
|
115
118
|
read = prefix
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
1
|
var ip = exports;
|
|
4
|
-
var Buffer = require('buffer')
|
|
2
|
+
var { Buffer } = require('buffer');
|
|
5
3
|
var os = require('os');
|
|
6
4
|
|
|
7
|
-
ip.toBuffer = function(ip, buff, offset) {
|
|
5
|
+
ip.toBuffer = function (ip, buff, offset) {
|
|
8
6
|
offset = ~~offset;
|
|
9
7
|
|
|
10
8
|
var result;
|
|
11
9
|
|
|
12
10
|
if (this.isV4Format(ip)) {
|
|
13
11
|
result = buff || new Buffer(offset + 4);
|
|
14
|
-
ip.split(/\./g).map(
|
|
12
|
+
ip.split(/\./g).map((byte) => {
|
|
15
13
|
result[offset++] = parseInt(byte, 10) & 0xff;
|
|
16
14
|
});
|
|
17
15
|
} else if (this.isV6Format(ip)) {
|
|
@@ -38,7 +36,7 @@ ip.toBuffer = function(ip, buff, offset) {
|
|
|
38
36
|
while (sections.length < 8) sections.push('0');
|
|
39
37
|
} else if (sections.length < 8) {
|
|
40
38
|
for (i = 0; i < sections.length && sections[i] !== ''; i++);
|
|
41
|
-
var argv = [
|
|
39
|
+
var argv = [i, 1];
|
|
42
40
|
for (i = 9 - sections.length; i > 0; i--) {
|
|
43
41
|
argv.push('0');
|
|
44
42
|
}
|
|
@@ -54,26 +52,27 @@ ip.toBuffer = function(ip, buff, offset) {
|
|
|
54
52
|
}
|
|
55
53
|
|
|
56
54
|
if (!result) {
|
|
57
|
-
throw Error(
|
|
55
|
+
throw Error(`Invalid ip address: ${ip}`);
|
|
58
56
|
}
|
|
59
57
|
|
|
60
58
|
return result;
|
|
61
59
|
};
|
|
62
60
|
|
|
63
|
-
ip.toString = function(buff, offset, length) {
|
|
61
|
+
ip.toString = function (buff, offset, length) {
|
|
64
62
|
offset = ~~offset;
|
|
65
63
|
length = length || (buff.length - offset);
|
|
66
64
|
|
|
67
65
|
var result = [];
|
|
66
|
+
var i;
|
|
68
67
|
if (length === 4) {
|
|
69
68
|
// IPv4
|
|
70
|
-
for (
|
|
69
|
+
for (i = 0; i < length; i++) {
|
|
71
70
|
result.push(buff[offset + i]);
|
|
72
71
|
}
|
|
73
72
|
result = result.join('.');
|
|
74
73
|
} else if (length === 16) {
|
|
75
74
|
// IPv6
|
|
76
|
-
for (
|
|
75
|
+
for (i = 0; i < length; i += 2) {
|
|
77
76
|
result.push(buff.readUInt16BE(offset + i).toString(16));
|
|
78
77
|
}
|
|
79
78
|
result = result.join(':');
|
|
@@ -85,21 +84,27 @@ ip.toString = function(buff, offset, length) {
|
|
|
85
84
|
};
|
|
86
85
|
|
|
87
86
|
var ipv4Regex = /^(\d{1,3}\.){3,3}\d{1,3}$/;
|
|
88
|
-
var ipv6Regex =
|
|
89
|
-
/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i;
|
|
87
|
+
var ipv6Regex = /^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i;
|
|
90
88
|
|
|
91
|
-
ip.isV4Format = function(ip) {
|
|
89
|
+
ip.isV4Format = function (ip) {
|
|
92
90
|
return ipv4Regex.test(ip);
|
|
93
91
|
};
|
|
94
92
|
|
|
95
|
-
ip.isV6Format = function(ip) {
|
|
93
|
+
ip.isV6Format = function (ip) {
|
|
96
94
|
return ipv6Regex.test(ip);
|
|
97
95
|
};
|
|
96
|
+
|
|
98
97
|
function _normalizeFamily(family) {
|
|
98
|
+
if (family === 4) {
|
|
99
|
+
return 'ipv4';
|
|
100
|
+
}
|
|
101
|
+
if (family === 6) {
|
|
102
|
+
return 'ipv6';
|
|
103
|
+
}
|
|
99
104
|
return family ? family.toLowerCase() : 'ipv4';
|
|
100
105
|
}
|
|
101
106
|
|
|
102
|
-
ip.fromPrefixLen = function(prefixlen, family) {
|
|
107
|
+
ip.fromPrefixLen = function (prefixlen, family) {
|
|
103
108
|
if (prefixlen > 32) {
|
|
104
109
|
family = 'ipv6';
|
|
105
110
|
} else {
|
|
@@ -125,14 +130,14 @@ ip.fromPrefixLen = function(prefixlen, family) {
|
|
|
125
130
|
return ip.toString(buff);
|
|
126
131
|
};
|
|
127
132
|
|
|
128
|
-
ip.mask = function(addr, mask) {
|
|
133
|
+
ip.mask = function (addr, mask) {
|
|
129
134
|
addr = ip.toBuffer(addr);
|
|
130
135
|
mask = ip.toBuffer(mask);
|
|
131
136
|
|
|
132
137
|
var result = new Buffer(Math.max(addr.length, mask.length));
|
|
133
138
|
|
|
134
|
-
var i = 0;
|
|
135
139
|
// Same protocol - do bitwise and
|
|
140
|
+
var i;
|
|
136
141
|
if (addr.length === mask.length) {
|
|
137
142
|
for (i = 0; i < addr.length; i++) {
|
|
138
143
|
result[i] = addr[i] & mask[i];
|
|
@@ -141,11 +146,11 @@ ip.mask = function(addr, mask) {
|
|
|
141
146
|
// IPv6 address and IPv4 mask
|
|
142
147
|
// (Mask low bits)
|
|
143
148
|
for (i = 0; i < mask.length; i++) {
|
|
144
|
-
result[i] = addr[addr.length - 4
|
|
149
|
+
result[i] = addr[addr.length - 4 + i] & mask[i];
|
|
145
150
|
}
|
|
146
151
|
} else {
|
|
147
152
|
// IPv6 mask and IPv4 addr
|
|
148
|
-
for (
|
|
153
|
+
for (i = 0; i < result.length - 6; i++) {
|
|
149
154
|
result[i] = 0;
|
|
150
155
|
}
|
|
151
156
|
|
|
@@ -155,27 +160,29 @@ ip.mask = function(addr, mask) {
|
|
|
155
160
|
for (i = 0; i < addr.length; i++) {
|
|
156
161
|
result[i + 12] = addr[i] & mask[i + 12];
|
|
157
162
|
}
|
|
158
|
-
i
|
|
163
|
+
i += 12;
|
|
159
164
|
}
|
|
160
|
-
for (; i < result.length; i++)
|
|
165
|
+
for (; i < result.length; i++) {
|
|
161
166
|
result[i] = 0;
|
|
167
|
+
}
|
|
162
168
|
|
|
163
169
|
return ip.toString(result);
|
|
164
170
|
};
|
|
165
171
|
|
|
166
|
-
ip.cidr = function(cidrString) {
|
|
172
|
+
ip.cidr = function (cidrString) {
|
|
167
173
|
var cidrParts = cidrString.split('/');
|
|
168
174
|
|
|
169
175
|
var addr = cidrParts[0];
|
|
170
|
-
if (cidrParts.length !== 2)
|
|
171
|
-
throw new Error(
|
|
176
|
+
if (cidrParts.length !== 2) {
|
|
177
|
+
throw new Error(`invalid CIDR subnet: ${addr}`);
|
|
178
|
+
}
|
|
172
179
|
|
|
173
180
|
var mask = ip.fromPrefixLen(parseInt(cidrParts[1], 10));
|
|
174
181
|
|
|
175
182
|
return ip.mask(addr, mask);
|
|
176
183
|
};
|
|
177
184
|
|
|
178
|
-
ip.subnet = function(addr, mask) {
|
|
185
|
+
ip.subnet = function (addr, mask) {
|
|
179
186
|
var networkAddress = ip.toLong(ip.mask(addr, mask));
|
|
180
187
|
|
|
181
188
|
// Calculate the mask's length.
|
|
@@ -198,37 +205,38 @@ ip.subnet = function(addr, mask) {
|
|
|
198
205
|
|
|
199
206
|
return {
|
|
200
207
|
networkAddress: ip.fromLong(networkAddress),
|
|
201
|
-
firstAddress: numberOfAddresses <= 2
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
lastAddress: numberOfAddresses <= 2
|
|
205
|
-
|
|
206
|
-
|
|
208
|
+
firstAddress: numberOfAddresses <= 2
|
|
209
|
+
? ip.fromLong(networkAddress)
|
|
210
|
+
: ip.fromLong(networkAddress + 1),
|
|
211
|
+
lastAddress: numberOfAddresses <= 2
|
|
212
|
+
? ip.fromLong(networkAddress + numberOfAddresses - 1)
|
|
213
|
+
: ip.fromLong(networkAddress + numberOfAddresses - 2),
|
|
207
214
|
broadcastAddress: ip.fromLong(networkAddress + numberOfAddresses - 1),
|
|
208
215
|
subnetMask: mask,
|
|
209
216
|
subnetMaskLength: maskLength,
|
|
210
|
-
numHosts: numberOfAddresses <= 2
|
|
211
|
-
|
|
217
|
+
numHosts: numberOfAddresses <= 2
|
|
218
|
+
? numberOfAddresses : numberOfAddresses - 2,
|
|
212
219
|
length: numberOfAddresses,
|
|
213
|
-
contains
|
|
220
|
+
contains(other) {
|
|
214
221
|
return networkAddress === ip.toLong(ip.mask(other, mask));
|
|
215
|
-
}
|
|
222
|
+
},
|
|
216
223
|
};
|
|
217
224
|
};
|
|
218
225
|
|
|
219
|
-
ip.cidrSubnet = function(cidrString) {
|
|
226
|
+
ip.cidrSubnet = function (cidrString) {
|
|
220
227
|
var cidrParts = cidrString.split('/');
|
|
221
228
|
|
|
222
229
|
var addr = cidrParts[0];
|
|
223
|
-
if (cidrParts.length !== 2)
|
|
224
|
-
throw new Error(
|
|
230
|
+
if (cidrParts.length !== 2) {
|
|
231
|
+
throw new Error(`invalid CIDR subnet: ${addr}`);
|
|
232
|
+
}
|
|
225
233
|
|
|
226
234
|
var mask = ip.fromPrefixLen(parseInt(cidrParts[1], 10));
|
|
227
235
|
|
|
228
236
|
return ip.subnet(addr, mask);
|
|
229
237
|
};
|
|
230
238
|
|
|
231
|
-
ip.not = function(addr) {
|
|
239
|
+
ip.not = function (addr) {
|
|
232
240
|
var buff = ip.toBuffer(addr);
|
|
233
241
|
for (var i = 0; i < buff.length; i++) {
|
|
234
242
|
buff[i] = 0xff ^ buff[i];
|
|
@@ -236,42 +244,45 @@ ip.not = function(addr) {
|
|
|
236
244
|
return ip.toString(buff);
|
|
237
245
|
};
|
|
238
246
|
|
|
239
|
-
ip.or = function(a, b) {
|
|
247
|
+
ip.or = function (a, b) {
|
|
248
|
+
var i;
|
|
249
|
+
|
|
240
250
|
a = ip.toBuffer(a);
|
|
241
251
|
b = ip.toBuffer(b);
|
|
242
252
|
|
|
243
253
|
// same protocol
|
|
244
254
|
if (a.length === b.length) {
|
|
245
|
-
for (
|
|
255
|
+
for (i = 0; i < a.length; ++i) {
|
|
246
256
|
a[i] |= b[i];
|
|
247
257
|
}
|
|
248
258
|
return ip.toString(a);
|
|
249
259
|
|
|
250
260
|
// mixed protocols
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
var offset = buff.length - other.length;
|
|
260
|
-
for (var i = offset; i < buff.length; ++i) {
|
|
261
|
-
buff[i] |= other[i - offset];
|
|
262
|
-
}
|
|
261
|
+
}
|
|
262
|
+
var buff = a;
|
|
263
|
+
var other = b;
|
|
264
|
+
if (b.length > a.length) {
|
|
265
|
+
buff = b;
|
|
266
|
+
other = a;
|
|
267
|
+
}
|
|
263
268
|
|
|
264
|
-
|
|
269
|
+
var offset = buff.length - other.length;
|
|
270
|
+
for (i = offset; i < buff.length; ++i) {
|
|
271
|
+
buff[i] |= other[i - offset];
|
|
265
272
|
}
|
|
273
|
+
|
|
274
|
+
return ip.toString(buff);
|
|
266
275
|
};
|
|
267
276
|
|
|
268
|
-
ip.isEqual = function(a, b) {
|
|
277
|
+
ip.isEqual = function (a, b) {
|
|
278
|
+
var i;
|
|
279
|
+
|
|
269
280
|
a = ip.toBuffer(a);
|
|
270
281
|
b = ip.toBuffer(b);
|
|
271
282
|
|
|
272
283
|
// Same protocol
|
|
273
284
|
if (a.length === b.length) {
|
|
274
|
-
for (
|
|
285
|
+
for (i = 0; i < a.length; i++) {
|
|
275
286
|
if (a[i] !== b[i]) return false;
|
|
276
287
|
}
|
|
277
288
|
return true;
|
|
@@ -285,47 +296,47 @@ ip.isEqual = function(a, b) {
|
|
|
285
296
|
}
|
|
286
297
|
|
|
287
298
|
// a - IPv4, b - IPv6
|
|
288
|
-
for (
|
|
299
|
+
for (i = 0; i < 10; i++) {
|
|
289
300
|
if (b[i] !== 0) return false;
|
|
290
301
|
}
|
|
291
302
|
|
|
292
303
|
var word = b.readUInt16BE(10);
|
|
293
304
|
if (word !== 0 && word !== 0xffff) return false;
|
|
294
305
|
|
|
295
|
-
for (
|
|
306
|
+
for (i = 0; i < 4; i++) {
|
|
296
307
|
if (a[i] !== b[i + 12]) return false;
|
|
297
308
|
}
|
|
298
309
|
|
|
299
310
|
return true;
|
|
300
311
|
};
|
|
301
312
|
|
|
302
|
-
ip.isPrivate = function(addr) {
|
|
313
|
+
ip.isPrivate = function (addr) {
|
|
303
314
|
return /^(::f{4}:)?10\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i
|
|
304
|
-
|
|
305
|
-
/^(::f{4}:)?192\.168\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr)
|
|
306
|
-
/^(::f{4}:)?172\.(1[6-9]|2\d|30|31)\.([0-9]{1,3})\.([0-9]{1,3})$/i
|
|
307
|
-
.test(addr)
|
|
308
|
-
/^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr)
|
|
309
|
-
/^(::f{4}:)?169\.254\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr)
|
|
310
|
-
/^f[cd][0-9a-f]{2}:/i.test(addr)
|
|
311
|
-
/^fe80:/i.test(addr)
|
|
312
|
-
/^::1$/.test(addr)
|
|
313
|
-
/^::$/.test(addr);
|
|
315
|
+
.test(addr)
|
|
316
|
+
|| /^(::f{4}:)?192\.168\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr)
|
|
317
|
+
|| /^(::f{4}:)?172\.(1[6-9]|2\d|30|31)\.([0-9]{1,3})\.([0-9]{1,3})$/i
|
|
318
|
+
.test(addr)
|
|
319
|
+
|| /^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr)
|
|
320
|
+
|| /^(::f{4}:)?169\.254\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr)
|
|
321
|
+
|| /^f[cd][0-9a-f]{2}:/i.test(addr)
|
|
322
|
+
|| /^fe80:/i.test(addr)
|
|
323
|
+
|| /^::1$/.test(addr)
|
|
324
|
+
|| /^::$/.test(addr);
|
|
314
325
|
};
|
|
315
326
|
|
|
316
|
-
ip.isPublic = function(addr) {
|
|
327
|
+
ip.isPublic = function (addr) {
|
|
317
328
|
return !ip.isPrivate(addr);
|
|
318
329
|
};
|
|
319
330
|
|
|
320
|
-
ip.isLoopback = function(addr) {
|
|
331
|
+
ip.isLoopback = function (addr) {
|
|
321
332
|
return /^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/
|
|
322
|
-
|
|
323
|
-
/^fe80::1$/.test(addr)
|
|
324
|
-
/^::1$/.test(addr)
|
|
325
|
-
/^::$/.test(addr);
|
|
333
|
+
.test(addr)
|
|
334
|
+
|| /^fe80::1$/.test(addr)
|
|
335
|
+
|| /^::1$/.test(addr)
|
|
336
|
+
|| /^::$/.test(addr);
|
|
326
337
|
};
|
|
327
338
|
|
|
328
|
-
ip.loopback = function(family) {
|
|
339
|
+
ip.loopback = function (family) {
|
|
329
340
|
//
|
|
330
341
|
// Default to `ipv4`
|
|
331
342
|
//
|
|
@@ -353,9 +364,8 @@ ip.loopback = function(family) {
|
|
|
353
364
|
// * 'private': the first private ip address of family.
|
|
354
365
|
// * undefined: First address with `ipv4` or loopback address `127.0.0.1`.
|
|
355
366
|
//
|
|
356
|
-
ip.address = function(name, family) {
|
|
367
|
+
ip.address = function (name, family) {
|
|
357
368
|
var interfaces = os.networkInterfaces();
|
|
358
|
-
var all;
|
|
359
369
|
|
|
360
370
|
//
|
|
361
371
|
// Default to `ipv4`
|
|
@@ -367,30 +377,31 @@ ip.address = function(name, family) {
|
|
|
367
377
|
// return the address.
|
|
368
378
|
//
|
|
369
379
|
if (name && name !== 'private' && name !== 'public') {
|
|
370
|
-
var res = interfaces[name].filter(
|
|
371
|
-
var itemFamily = details.family
|
|
380
|
+
var res = interfaces[name].filter((details) => {
|
|
381
|
+
var itemFamily = _normalizeFamily(details.family);
|
|
372
382
|
return itemFamily === family;
|
|
373
383
|
});
|
|
374
|
-
if (res.length === 0)
|
|
384
|
+
if (res.length === 0) {
|
|
375
385
|
return undefined;
|
|
386
|
+
}
|
|
376
387
|
return res[0].address;
|
|
377
388
|
}
|
|
378
389
|
|
|
379
|
-
var all = Object.keys(interfaces).map(
|
|
390
|
+
var all = Object.keys(interfaces).map((nic) => {
|
|
380
391
|
//
|
|
381
392
|
// Note: name will only be `public` or `private`
|
|
382
393
|
// when this is called.
|
|
383
394
|
//
|
|
384
|
-
var addresses = interfaces[nic].filter(
|
|
385
|
-
details.family = details.family
|
|
395
|
+
var addresses = interfaces[nic].filter((details) => {
|
|
396
|
+
details.family = _normalizeFamily(details.family);
|
|
386
397
|
if (details.family !== family || ip.isLoopback(details.address)) {
|
|
387
398
|
return false;
|
|
388
|
-
}
|
|
399
|
+
} if (!name) {
|
|
389
400
|
return true;
|
|
390
401
|
}
|
|
391
402
|
|
|
392
|
-
return name === 'public' ? ip.isPrivate(details.address)
|
|
393
|
-
|
|
403
|
+
return name === 'public' ? ip.isPrivate(details.address)
|
|
404
|
+
: ip.isPublic(details.address);
|
|
394
405
|
});
|
|
395
406
|
|
|
396
407
|
return addresses.length ? addresses[0].address : undefined;
|
|
@@ -399,18 +410,18 @@ ip.address = function(name, family) {
|
|
|
399
410
|
return !all.length ? ip.loopback(family) : all[0];
|
|
400
411
|
};
|
|
401
412
|
|
|
402
|
-
ip.toLong = function(ip) {
|
|
413
|
+
ip.toLong = function (ip) {
|
|
403
414
|
var ipl = 0;
|
|
404
|
-
ip.split('.').forEach(
|
|
415
|
+
ip.split('.').forEach((octet) => {
|
|
405
416
|
ipl <<= 8;
|
|
406
417
|
ipl += parseInt(octet);
|
|
407
418
|
});
|
|
408
|
-
return(ipl >>> 0);
|
|
419
|
+
return (ipl >>> 0);
|
|
409
420
|
};
|
|
410
421
|
|
|
411
|
-
ip.fromLong = function(ipl) {
|
|
412
|
-
return (
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
422
|
+
ip.fromLong = function (ipl) {
|
|
423
|
+
return (`${ipl >>> 24}.${
|
|
424
|
+
ipl >> 16 & 255}.${
|
|
425
|
+
ipl >> 8 & 255}.${
|
|
426
|
+
ipl & 255}`);
|
|
416
427
|
};
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ip",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.8",
|
|
4
4
|
"author": "Fedor Indutny <fedor@indutny.com>",
|
|
5
5
|
"homepage": "https://github.com/indutny/node-ip",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "http://github.com/indutny/node-ip.git"
|
|
9
9
|
},
|
|
10
|
+
"files": [
|
|
11
|
+
"lib",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
10
14
|
"main": "lib/ip",
|
|
11
15
|
"devDependencies": {
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"mocha": "~1.3.2"
|
|
16
|
+
"eslint": "^8.15.0",
|
|
17
|
+
"mocha": "^10.0.0"
|
|
15
18
|
},
|
|
16
19
|
"scripts": {
|
|
17
|
-
"
|
|
18
|
-
"
|
|
20
|
+
"lint": "eslint lib/*.js test/*.js",
|
|
21
|
+
"test": "npm run lint && mocha --reporter spec test/*-test.js",
|
|
22
|
+
"fix": "npm run lint -- --fix"
|
|
19
23
|
},
|
|
20
24
|
"license": "MIT"
|
|
21
25
|
}
|