manner.js 1.0.3 → 1.0.5
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/coverage/clover.xml +59 -23
- package/coverage/coverage-final.json +3 -2
- package/coverage/lcov-report/class/MultiFetch.js.html +1 -1
- package/coverage/lcov-report/class/index.html +1 -1
- package/coverage/lcov-report/index.html +17 -17
- package/coverage/lcov-report/lib/byteArray.js.html +154 -0
- package/coverage/lcov-report/lib/formatHttpDate.js.html +1 -1
- package/coverage/lcov-report/lib/formatHttpKey.js.html +1 -1
- package/coverage/lcov-report/lib/getOwnIpAddresses.js.html +3 -3
- package/coverage/lcov-report/lib/index.html +40 -25
- package/coverage/lcov-report/lib/isIntranetIpv4Address.js.html +196 -0
- package/coverage/lcov-report/lib/isIpv6Address.js.html +45 -24
- package/coverage/lcov-report/lib/parseHttpDate.js.html +1 -1
- package/coverage/lcov.info +105 -37
- package/package.json +1 -1
- package/server/index.js +8 -3
- package/server/lib/byteArray.js +28 -0
- package/server/lib/getOwnIpAddresses.js +2 -2
- package/server/lib/isIntranetIpv4Address.js +44 -0
- package/server/lib/isIpv6Address.js +17 -10
- package/server/lib/isIpv4Address.js +0 -20
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.fromInt = fromInt;
|
|
7
|
+
exports.toInt = toInt;
|
|
8
|
+
const size = 256n;
|
|
9
|
+
function fromInt(n) {
|
|
10
|
+
n = BigInt(n);
|
|
11
|
+
const ans = [];
|
|
12
|
+
if (n > size - 1n) {
|
|
13
|
+
while (n > size) {
|
|
14
|
+
const q = n % size;
|
|
15
|
+
ans.push(Number(q));
|
|
16
|
+
n = n / size;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
ans.push(Number(n));
|
|
20
|
+
return ans;
|
|
21
|
+
}
|
|
22
|
+
function toInt(buf) {
|
|
23
|
+
let n = 0n;
|
|
24
|
+
for (let i = 0n; i < buf.length; i += 1n) {
|
|
25
|
+
n += BigInt(buf[i]) * size ** i;
|
|
26
|
+
}
|
|
27
|
+
return n;
|
|
28
|
+
}
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = getOwnIpAddresses;
|
|
7
7
|
var _os = _interopRequireDefault(require("os"));
|
|
8
|
-
var
|
|
8
|
+
var _isIntranetIpv4Address = _interopRequireDefault(require("./isIntranetIpv4Address"));
|
|
9
9
|
var _isIpv6Address = _interopRequireDefault(require("./isIpv6Address"));
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
11
|
function getOwnIpAddresses() {
|
|
@@ -46,7 +46,7 @@ function getOwnIpAddresses() {
|
|
|
46
46
|
const {
|
|
47
47
|
address
|
|
48
48
|
} = ip;
|
|
49
|
-
if ((0,
|
|
49
|
+
if ((0, _isIntranetIpv4Address.default)(address)) {
|
|
50
50
|
ipv4 = address;
|
|
51
51
|
}
|
|
52
52
|
break;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = isIntranetIpv4Address;
|
|
7
|
+
function isIntranetIpv4Address(address) {
|
|
8
|
+
let total = 0;
|
|
9
|
+
let sectionValue = 0;
|
|
10
|
+
;
|
|
11
|
+
let sectionCount = 0;
|
|
12
|
+
for (let i = 0; i <= address.length; i += 1) {
|
|
13
|
+
const char = address.charAt(i);
|
|
14
|
+
switch (char) {
|
|
15
|
+
case '':
|
|
16
|
+
case '.':
|
|
17
|
+
sectionCount += 1;
|
|
18
|
+
total *= 256;
|
|
19
|
+
total += sectionValue;
|
|
20
|
+
sectionValue = 0;
|
|
21
|
+
break;
|
|
22
|
+
default:
|
|
23
|
+
if (!(char >= '0' && char <= '9')) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
sectionValue *= 10;
|
|
27
|
+
sectionValue += parseInt(char);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (sectionCount !== 4) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
let ans = false;
|
|
34
|
+
if (total >= 167772160 && total <= 184549375) {
|
|
35
|
+
ans = true;
|
|
36
|
+
}
|
|
37
|
+
if (total >= 2886729728 && total <= 2887778303) {
|
|
38
|
+
ans = true;
|
|
39
|
+
}
|
|
40
|
+
if (total >= 3232235520 && total <= 3232301055) {
|
|
41
|
+
ans = true;
|
|
42
|
+
}
|
|
43
|
+
return ans;
|
|
44
|
+
}
|
|
@@ -5,16 +5,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = isIpv6Address;
|
|
7
7
|
function isIpv6Address(address) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
let sectionCount = 0;
|
|
9
|
+
let ans = true;
|
|
10
|
+
for (let i = 0; i <= address.length; i += 1) {
|
|
11
|
+
const char = address.charAt(i);
|
|
12
|
+
switch (char) {
|
|
13
|
+
case '':
|
|
14
|
+
case ':':
|
|
15
|
+
sectionCount += 1;
|
|
16
|
+
break;
|
|
17
|
+
default:
|
|
18
|
+
if (!(char >= '0' && char <= '9' || char >= 'a' && char <= 'f')) {
|
|
19
|
+
ans = false;
|
|
20
|
+
}
|
|
17
21
|
}
|
|
18
22
|
}
|
|
19
|
-
|
|
23
|
+
if (sectionCount !== 8) {
|
|
24
|
+
ans = false;
|
|
25
|
+
}
|
|
26
|
+
return ans;
|
|
20
27
|
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = isIpv4Address;
|
|
7
|
-
function isIpv4Address(address) {
|
|
8
|
-
const sections = address.split('.');
|
|
9
|
-
if (sections.length !== 4) {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
for (let i = 0; i < sections.length; i += 1) {
|
|
13
|
-
const section = sections;
|
|
14
|
-
const value = parseInt(section);
|
|
15
|
-
if (!(value >= 0 && value <= 255)) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return true;
|
|
20
|
-
}
|