@fastcar/core 0.2.45 → 0.2.46
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/package.json +1 -1
- package/src/utils/IPUtils.ts +35 -0
- package/src/utils.ts +2 -1
- package/target/utils/IPUtils.js +34 -0
- package/target/utils.js +3 -1
- package/test/example/logs/fastcar-server.logger.log +3 -0
- package/test/example/logs/fastcar-server.sys.log +8 -0
- package/test/example/logs/sys.log +0 -2
- package/utils.d.ts +4 -0
- package/test/example/logs/[fastcar-server] logger.log +0 -3
- package/test/example/logs/[fastcar-server] sys.log +0 -8
- /package/test/example/logs/{[fastcar-server] app.log → fastcar-server.app.log} +0 -0
package/package.json
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const getIPNum = function (address: string) {
|
|
2
|
+
let ip = address.split(".");
|
|
3
|
+
let total = 0;
|
|
4
|
+
ip.forEach((item, index) => {
|
|
5
|
+
total += parseInt(item) * Math.pow(256, 3 - index);
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
return total;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const InnerIPList = [
|
|
12
|
+
["10.0.0.0", "10.255.255.255"],
|
|
13
|
+
["172.16.0.0", "172.31.255.255"],
|
|
14
|
+
["192.168.0.0", "192.168.255.255"],
|
|
15
|
+
["127.0.0.0", "127.255.255.255"],
|
|
16
|
+
].map((item) => {
|
|
17
|
+
return [getIPNum(item[0]), getIPNum(item[1])];
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export default class IPUtils {
|
|
21
|
+
static isInnerIP = (ip: string): boolean => {
|
|
22
|
+
if (["0.0.0.0", "localhost"].includes(ip)) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
let n = ip.split(".");
|
|
27
|
+
if (n.length != 4) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
let ipn = getIPNum(ip);
|
|
31
|
+
return InnerIPList.some((item) => {
|
|
32
|
+
return ipn >= item[0] && ipn <= item[1];
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
}
|
package/src/utils.ts
CHANGED
|
@@ -8,6 +8,7 @@ import FormatStr from "./utils/FormatStr";
|
|
|
8
8
|
import MixTool from "./utils/Mix";
|
|
9
9
|
import TypeUtil from "./utils/TypeUtil";
|
|
10
10
|
import ValidationUtil from "./utils/ValidationUtil";
|
|
11
|
+
import IPUtils from "./utils/IPUtils";
|
|
11
12
|
|
|
12
13
|
//实用工具集合类
|
|
13
|
-
export { DateUtil, DataFormat, CryptoUtil, FileUtil, TypeUtil, ValidationUtil, FormatStr, ClassUtils, ClassLoader, MixTool };
|
|
14
|
+
export { DateUtil, DataFormat, CryptoUtil, FileUtil, TypeUtil, ValidationUtil, FormatStr, ClassUtils, ClassLoader, MixTool, IPUtils };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getIPNum = function (address) {
|
|
4
|
+
let ip = address.split(".");
|
|
5
|
+
let total = 0;
|
|
6
|
+
ip.forEach((item, index) => {
|
|
7
|
+
total += parseInt(item) * Math.pow(256, 3 - index);
|
|
8
|
+
});
|
|
9
|
+
return total;
|
|
10
|
+
};
|
|
11
|
+
const InnerIPList = [
|
|
12
|
+
["10.0.0.0", "10.255.255.255"],
|
|
13
|
+
["172.16.0.0", "172.31.255.255"],
|
|
14
|
+
["192.168.0.0", "192.168.255.255"],
|
|
15
|
+
["127.0.0.0", "127.255.255.255"],
|
|
16
|
+
].map((item) => {
|
|
17
|
+
return [getIPNum(item[0]), getIPNum(item[1])];
|
|
18
|
+
});
|
|
19
|
+
class IPUtils {
|
|
20
|
+
}
|
|
21
|
+
exports.default = IPUtils;
|
|
22
|
+
IPUtils.isInnerIP = (ip) => {
|
|
23
|
+
if (["0.0.0.0", "localhost"].includes(ip)) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
let n = ip.split(".");
|
|
27
|
+
if (n.length != 4) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
let ipn = getIPNum(ip);
|
|
31
|
+
return InnerIPList.some((item) => {
|
|
32
|
+
return ipn >= item[0] && ipn <= item[1];
|
|
33
|
+
});
|
|
34
|
+
};
|
package/target/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MixTool = exports.ClassLoader = exports.ClassUtils = exports.FormatStr = exports.ValidationUtil = exports.TypeUtil = exports.FileUtil = exports.CryptoUtil = exports.DataFormat = exports.DateUtil = void 0;
|
|
3
|
+
exports.IPUtils = exports.MixTool = exports.ClassLoader = exports.ClassUtils = exports.FormatStr = exports.ValidationUtil = exports.TypeUtil = exports.FileUtil = exports.CryptoUtil = exports.DataFormat = exports.DateUtil = void 0;
|
|
4
4
|
const classLoader_1 = require("./utils/classLoader");
|
|
5
5
|
exports.ClassLoader = classLoader_1.default;
|
|
6
6
|
const ClassUtils_1 = require("./utils/ClassUtils");
|
|
@@ -21,3 +21,5 @@ const TypeUtil_1 = require("./utils/TypeUtil");
|
|
|
21
21
|
exports.TypeUtil = TypeUtil_1.default;
|
|
22
22
|
const ValidationUtil_1 = require("./utils/ValidationUtil");
|
|
23
23
|
exports.ValidationUtil = ValidationUtil_1.default;
|
|
24
|
+
const IPUtils_1 = require("./utils/IPUtils");
|
|
25
|
+
exports.IPUtils = IPUtils_1.default;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
{"timestamp":"2023-07-24 16:49:43.665","level":"INFO","label":"fastcar-server.logger","message":"自定义的日志输出"}
|
|
2
|
+
{"timestamp":"2023-07-24 16:49:43.666","level":"WARN","label":"fastcar-server.logger","message":"自定义警告"}
|
|
3
|
+
{"timestamp":"2023-07-24 16:49:43.667","level":"ERROR","label":"fastcar-server.logger","message":"自定义报错"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{"timestamp":"2023-07-24 16:49:36.843","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
|
|
2
|
+
{"timestamp":"2023-07-24 16:49:38.241","level":"INFO","label":"fastcar-server.sys","message":"Complete component scan"}
|
|
3
|
+
{"timestamp":"2023-07-24 16:49:39.408","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
|
|
4
|
+
{"timestamp":"2023-07-24 16:49:39.912","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
|
|
5
|
+
{"timestamp":"2023-07-24 16:49:40.384","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
|
|
6
|
+
{"timestamp":"2023-07-24 16:49:45.679","level":"INFO","label":"fastcar-server.sys","message":"exit reason","splat":"[\"beforeExit exit\"]"}
|
|
7
|
+
{"timestamp":"2023-07-24 16:49:45.680","level":"INFO","label":"fastcar-server.sys","message":"Call the method before the application stops"}
|
|
8
|
+
{"timestamp":"2023-07-24 16:49:50.692","level":"INFO","label":"fastcar-server.sys","message":"application stop"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
{"timestamp":"2023-05-17 15:11:40.448","level":"ERROR","label":"sys","message":"Unsatisfied dependency expressed through [notFound] ","stack":"Error: Unsatisfied dependency expressed through [notFound] \n at NotFoundController.get (D:\\code\\fast-car\\fast-car\\fastcar-core\\src\\annotation\\bind\\AliasInjection.ts:16:27)\n at NotFoundController.getNotFound (D:\\code\\fast-car\\fast-car\\fastcar-core\\test\\example\\simple\\controller\\NotFoundController.ts:14:15)\n at Context.<anonymous> (D:\\code\\fast-car\\fast-car\\fastcar-core\\test\\example\\simple\\app.ts:89:13)\n at callFn (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runnable.js:366:21)\n at Test.Runnable.run (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runnable.js:354:5)\n at Runner.runTest (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:678:10)\n at D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:801:12\n at next (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:593:14)\n at D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:603:7\n at next (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:486:14)\n at Immediate._onImmediate (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:571:5)\n at processImmediate (node:internal/timers:466:21)\n at process.topLevelDomainCallback (node:domain:152:15)\n at process.callbackTrampoline (node:internal/async_hooks:128:24)"}
|
|
2
|
-
{"timestamp":"2023-05-17 15:11:40.456","level":"ERROR","label":"sys","message":"Unsatisfied dependency expressed through [autoNotFound] ","stack":"Error: Unsatisfied dependency expressed through [autoNotFound] \n at NotFoundController.get (D:\\code\\fast-car\\fast-car\\fastcar-core\\src\\annotation\\bind\\CallDependency.ts:17:26)\n at NotFoundController.getAutoNotFound (D:\\code\\fast-car\\fast-car\\fastcar-core\\test\\example\\simple\\controller\\NotFoundController.ts:18:15)\n at Context.<anonymous> (D:\\code\\fast-car\\fast-car\\fastcar-core\\test\\example\\simple\\app.ts:95:13)\n at callFn (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runnable.js:366:21)\n at Test.Runnable.run (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runnable.js:354:5)\n at Runner.runTest (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:678:10)\n at D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:801:12\n at next (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:593:14)\n at D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:603:7\n at next (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:486:14)\n at Immediate._onImmediate (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:571:5)\n at processImmediate (node:internal/timers:466:21)\n at process.topLevelDomainCallback (node:domain:152:15)\n at process.callbackTrampoline (node:internal/async_hooks:128:24)"}
|
package/utils.d.ts
CHANGED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
{"timestamp":"2023-05-17 15:11:40.432","level":"INFO","label":"[fastcar-server] logger","message":"自定义的日志输出"}
|
|
2
|
-
{"timestamp":"2023-05-17 15:11:40.433","level":"WARN","label":"[fastcar-server] logger","message":"自定义警告"}
|
|
3
|
-
{"timestamp":"2023-05-17 15:11:40.434","level":"ERROR","label":"[fastcar-server] logger","message":"自定义报错"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
{"timestamp":"2023-05-17 15:11:21.300","level":"INFO","label":"[fastcar-server] sys","message":"Start scanning component"}
|
|
2
|
-
{"timestamp":"2023-05-17 15:11:40.421","level":"INFO","label":"[fastcar-server] sys","message":"Complete component scan"}
|
|
3
|
-
{"timestamp":"2023-05-17 15:11:40.422","level":"INFO","label":"[fastcar-server] sys","message":"Call application initialization method"}
|
|
4
|
-
{"timestamp":"2023-05-17 15:11:40.424","level":"INFO","label":"[fastcar-server] sys","message":"start server app is run"}
|
|
5
|
-
{"timestamp":"2023-05-17 15:11:40.425","level":"INFO","label":"[fastcar-server] sys","message":"version 1.0.0"}
|
|
6
|
-
{"timestamp":"2023-05-17 15:11:42.456","level":"INFO","label":"[fastcar-server] sys","message":"exit reason","splat":"[\"beforeExit exit\"]"}
|
|
7
|
-
{"timestamp":"2023-05-17 15:11:42.457","level":"INFO","label":"[fastcar-server] sys","message":"Call the method before the application stops"}
|
|
8
|
-
{"timestamp":"2023-05-17 15:11:47.460","level":"INFO","label":"[fastcar-server] sys","message":"application stop"}
|
|
File without changes
|