fcdns 0.3.16 → 0.4.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/README.md +12 -56
- package/lib/cli.js +18 -17
- package/lib/cli.js.map +1 -1
- package/lib/router.js +21 -24
- package/lib/router.js.map +1 -1
- package/lib/server.js +10 -12
- package/lib/server.js.map +1 -1
- package/package.json +1 -3
- package/CHANGELOG.md +0 -154
- package/lib/logger.js +0 -68
- package/lib/logger.js.map +0 -1
- package/lib/utils/countup.js +0 -9
- package/lib/utils/countup.js.map +0 -1
- package/lib/utils/get-elapsed.js +0 -9
- package/lib/utils/get-elapsed.js.map +0 -1
- package/lib/utils/get-timestamp.js +0 -8
- package/lib/utils/get-timestamp.js.map +0 -1
- package/lib/utils/level-to-string.js +0 -16
- package/lib/utils/level-to-string.js.map +0 -1
package/README.md
CHANGED
|
@@ -18,15 +18,15 @@ Options:
|
|
|
18
18
|
--test-server <server>
|
|
19
19
|
--untrusted-server <server>
|
|
20
20
|
--trusted-server <server>
|
|
21
|
-
--port
|
|
22
|
-
--
|
|
23
|
-
--
|
|
24
|
-
--hostname-
|
|
25
|
-
--
|
|
26
|
-
--
|
|
27
|
-
--test-
|
|
28
|
-
--
|
|
29
|
-
--
|
|
21
|
+
--port [port] (default: "53")
|
|
22
|
+
--timeout [seconds] (default: "30")
|
|
23
|
+
--ip-whitelist [filename] (default: "ip-whitelist.txt")
|
|
24
|
+
--hostname-whitelist [filename] (default: "hostname-whitelist.txt")
|
|
25
|
+
--hostname-blacklist [filename] (default: "hostname-blacklist.txt")
|
|
26
|
+
--route-cache [filename] (default: "route.txt")
|
|
27
|
+
--test-cache [filename] (default: "test.txt")
|
|
28
|
+
--test-timeout [ms] (default: "200")
|
|
29
|
+
--log [level] (default: "info")
|
|
30
30
|
-h, --help display help for command
|
|
31
31
|
```
|
|
32
32
|
|
|
@@ -62,7 +62,7 @@ fcdns会持久化缓存投毒测试的结果, 同一个主机名只在第一次
|
|
|
62
62
|
|
|
63
63
|
之所以需要依赖不可信DNS服务器, 是因为不可信DNS服务器通常比可信DNS服务器更快响应, 且返回的结果更准确.
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
由于fcdns只提供DNS转发功能, 建议使用CoreDNS等程序建立本地DNS服务器作为背后的代理.
|
|
66
66
|
|
|
67
67
|
### 可信DNS服务器(trusted server)
|
|
68
68
|
可信DNS服务器是一台DNS服务器, 客户端与该服务器的连接是不被污染的, 且该服务器不会返回被污染的结果.
|
|
@@ -70,7 +70,7 @@ fcdns会持久化缓存投毒测试的结果, 同一个主机名只在第一次
|
|
|
70
70
|
之所以需要可信DNS服务器, 是为了能够查询那些被投毒的主机名的正确记录.
|
|
71
71
|
可信DNS服务器返回的结果可能并不总是最准确, 但至少是具备可用性的.
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
由于fcdns只提供DNS转发功能, 建议使用CoreDNS等程序建立本地DNS服务器作为背后的代理.
|
|
74
74
|
|
|
75
75
|
### IP地址白名单(ip whitelist)
|
|
76
76
|
IP地址白名单用于指定允许用"不可信DNS服务器"返回的IP地址或IP地址范围,
|
|
@@ -80,7 +80,7 @@ IP地址白名单用于指定允许用"不可信DNS服务器"返回的IP地址
|
|
|
80
80
|
|
|
81
81
|
fcdns会持久化缓存查询最终选择的服务器, 同一个主机名只在第一次查询时会被IP地址白名单影响.
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
之所以使用白名单而不是黑名单, 是因为通常情况下白名单所需记录的内容条数较少.
|
|
84
84
|
|
|
85
85
|
#### 文件格式
|
|
86
86
|
白名单是一个文本文件, 以行为分隔符储存地址或地址范围.
|
|
@@ -129,50 +129,6 @@ wikipedia.org
|
|
|
129
129
|
*.wikipedia.org
|
|
130
130
|
```
|
|
131
131
|
|
|
132
|
-
## 宽松模式
|
|
133
|
-
在宽松模式下, 当相关主机名不存在路由缓存时(即第一次查询该主机名), 会立即查询不可信服务器并返回记录, 然后在后台执行投毒测试和路由缓存.
|
|
134
|
-
|
|
135
|
-
宽松模式通过降低fcdns的准确性, 提升了在可信信道不稳定情况下的用户体验, 这适用于只有少数主机名被投毒的环境.
|
|
136
|
-
|
|
137
|
-
## 性能
|
|
138
|
-
fcdns不是作为高性能DNS服务器开发的, 选择Node.js栈完全是出于开发方面的便利性.
|
|
139
|
-
fcdns的性能经过测试足以应付日常使用.
|
|
140
|
-
|
|
141
|
-
如果阅读fcdns的源代码, 则会发现一些可能进一步优化的部分,
|
|
142
|
-
不实施这些优化的主要原因是为了避免降低代码的可读性.
|
|
143
|
-
|
|
144
|
-
### 延迟
|
|
145
|
-
fcdns存在一些可以被注意到的延迟:
|
|
146
|
-
- 投毒测试
|
|
147
|
-
- 可信DNS服务器在无缓存的情况下被查询
|
|
148
|
-
- 不可信DNS服务器在无缓存的情况下被查询
|
|
149
|
-
- IP地址范围白名单
|
|
150
|
-
|
|
151
|
-
其中"可信DNS服务器"和"不可信DNS服务器"的延迟可以通过使用设置带有缓存的本地DNS服务器降至最低.
|
|
152
|
-
|
|
153
|
-
投毒测试的最大延迟由超时时间决定,
|
|
154
|
-
由于超时时间不应该设定为一个过低的值(建议至少为200ms), 因此首次投毒测试的延迟无法被消除.
|
|
155
|
-
随着fcdns的运行, 投毒测试的延迟将由于缓存的存在变得可以被忽略.
|
|
156
|
-
|
|
157
|
-
检查一个IP地址是否处于IP地址范围白名单内目前是通过遍历实现的,
|
|
158
|
-
在有5000条地址范围的情况下, 根据硬件的不同, 有可能会出现个位数毫秒的计算时间.
|
|
159
|
-
理论上可以通过将地址范围排序后做二分查找来加速此过程, 但暂未实现.
|
|
160
|
-
|
|
161
|
-
## 资源占用
|
|
162
|
-
### 硬盘占用
|
|
163
|
-
fcdns的缓存文件会在启动时自动压缩, 但在运行时是仅追加(append)的,
|
|
164
|
-
出现相同域名的并行查询时, 会重复写入相同的记录.
|
|
165
|
-
如果有非常大量完全不同域名的查询, 则缓存文件可能导致硬盘占用增加, 但在大部分场景下应该无需担心.
|
|
166
|
-
|
|
167
|
-
fcdns有两个缓存文件, 分别缓存投毒测试结果和路由结果.
|
|
168
|
-
由于路由缓存的优先级更高, 因此投毒测试缓存对于路由缓存来说是冗余的.
|
|
169
|
-
fcdns保留投毒测试缓存是考虑到了收集投毒测试结果的需要, 以及清空路由缓存的场景.
|
|
170
|
-
|
|
171
|
-
### 内存占用
|
|
172
|
-
fcdns的内存缓存受V8引擎的实现限制, 且缓存是只增不减的.
|
|
173
|
-
根据经验, Node.js程序的内存占用量通常会是使用类似数据类型的本地程序的两倍以上.
|
|
174
|
-
如果有非常大量完全不同域名的查询, 则内存缓存可能导致内存占用增加, 但在大部分场景下应该无需担心.
|
|
175
|
-
|
|
176
132
|
## 针对fcdns的攻击
|
|
177
133
|
### 以黑名单/白名单形式污染DNS服务器
|
|
178
134
|
禁止向非DNS服务器发送DNS数据包将会破坏fcdns的投毒测试功能.
|
package/lib/cli.js
CHANGED
|
@@ -15,18 +15,18 @@ commander_1.program
|
|
|
15
15
|
.name(require('../package.json').name)
|
|
16
16
|
.version(require('../package.json').version)
|
|
17
17
|
.description(require('../package.json').description)
|
|
18
|
-
.
|
|
19
|
-
.
|
|
20
|
-
.
|
|
21
|
-
.option('--port
|
|
22
|
-
.option('--
|
|
23
|
-
.option('--
|
|
24
|
-
.option('--hostname-
|
|
25
|
-
.option('--
|
|
26
|
-
.option('--
|
|
27
|
-
.option('--test-
|
|
28
|
-
.option('--
|
|
29
|
-
.option('--
|
|
18
|
+
.requiredOption('--test-server <server>')
|
|
19
|
+
.requiredOption('--untrusted-server <server>')
|
|
20
|
+
.requiredOption('--trusted-server <server>')
|
|
21
|
+
.option('--port [port]', '', '53')
|
|
22
|
+
.option('--timeout [seconds]', '', '30')
|
|
23
|
+
.option('--ip-whitelist [filename]', '', 'ip-whitelist.txt')
|
|
24
|
+
.option('--hostname-whitelist [filename]', '', 'hostname-whitelist.txt')
|
|
25
|
+
.option('--hostname-blacklist [filename]', '', 'hostname-blacklist.txt')
|
|
26
|
+
.option('--route-cache [filename]', '', 'route.txt')
|
|
27
|
+
.option('--test-cache <[ilename]', '', 'test.txt')
|
|
28
|
+
.option('--test-timeout [ms]', '', '200')
|
|
29
|
+
.option('--log [level]', '', 'info')
|
|
30
30
|
.action(async () => {
|
|
31
31
|
const options = getOptions();
|
|
32
32
|
const tester = await tester_1.Tester.create({
|
|
@@ -44,8 +44,7 @@ commander_1.program
|
|
|
44
44
|
ipWhitelist,
|
|
45
45
|
hostnameWhitelist,
|
|
46
46
|
hostnameBlacklist,
|
|
47
|
-
cacheFilename: options.routeCacheFilename
|
|
48
|
-
looseMode: options.looseMode
|
|
47
|
+
cacheFilename: options.routeCacheFilename
|
|
49
48
|
});
|
|
50
49
|
const logger = new extra_logger_1.Logger({
|
|
51
50
|
level: options.logLevel,
|
|
@@ -58,6 +57,7 @@ commander_1.program
|
|
|
58
57
|
logger,
|
|
59
58
|
trustedServer,
|
|
60
59
|
untrustedServer,
|
|
60
|
+
timeout: options.timeout,
|
|
61
61
|
port: options.port
|
|
62
62
|
});
|
|
63
63
|
})
|
|
@@ -69,6 +69,8 @@ function getOptions() {
|
|
|
69
69
|
const trustedServer = opts.trustedServer;
|
|
70
70
|
(0, errors_1.assert)(/^\d+$/.test(opts.port), 'The parameter port must be integer');
|
|
71
71
|
const port = Number.parseInt(opts.port, 10);
|
|
72
|
+
(0, errors_1.assert)(/^\d+$/.test(opts.timeout), 'The parameter timeout must be integer');
|
|
73
|
+
const timeout = Number.parseInt(opts.port, 10) * 1000;
|
|
72
74
|
const ipWhitelistFilename = opts.ipWhitelist;
|
|
73
75
|
const hostnameWhitelistFilename = opts.hostnameWhitelist;
|
|
74
76
|
const hostnameBlacklistFilename = opts.hostnameBlacklist;
|
|
@@ -77,20 +79,19 @@ function getOptions() {
|
|
|
77
79
|
(0, errors_1.assert)(/^\d+$/.test(opts.testTimeout), 'The parameter test timeout must be integer');
|
|
78
80
|
const testTimeout = Number.parseInt(opts.testTimeout, 10);
|
|
79
81
|
const logLevel = (0, extra_logger_1.stringToLevel)(opts.log, extra_logger_1.Level.Info);
|
|
80
|
-
const looseMode = opts.looseMode;
|
|
81
82
|
return {
|
|
82
83
|
testServer,
|
|
83
84
|
untrustedServer,
|
|
84
85
|
trustedServer,
|
|
85
86
|
port,
|
|
87
|
+
timeout,
|
|
86
88
|
ipWhitelistFilename,
|
|
87
89
|
hostnameWhitelistFilename,
|
|
88
90
|
hostnameBlacklistFilename,
|
|
89
91
|
routeCacheFilename,
|
|
90
92
|
testCacheFilename,
|
|
91
93
|
testTimeout,
|
|
92
|
-
logLevel
|
|
93
|
-
looseMode
|
|
94
|
+
logLevel
|
|
94
95
|
};
|
|
95
96
|
}
|
|
96
97
|
//# sourceMappingURL=cli.js.map
|
package/lib/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AACA,yCAAmC;AACnC,qCAAsC;AACtC,qCAAiC;AACjC,iDAA4C;AAC5C,mDAA8C;AAC9C,qCAAiC;AACjC,oEAA8D;AAC9D,+CAA2C;AAC3C,+CAA8E;AAC9E,gEAA0D;AAE1D,mBAAO;KACJ,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC;KACrC,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC;KAC3C,WAAW,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,WAAW,CAAC;KACnD,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AACA,yCAAmC;AACnC,qCAAsC;AACtC,qCAAiC;AACjC,iDAA4C;AAC5C,mDAA8C;AAC9C,qCAAiC;AACjC,oEAA8D;AAC9D,+CAA2C;AAC3C,+CAA8E;AAC9E,gEAA0D;AAE1D,mBAAO;KACJ,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC;KACrC,OA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,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,uCAAuC,CAAC,CAAA;IAC3E,MAAM,OAAO,GAAW,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,CAAA;IAE7D,MAAM,mBAAmB,GAAW,IAAI,CAAC,WAAW,CAAA;IACpD,MAAM,yBAAyB,GAAW,IAAI,CAAC,iBAAiB,CAAA;IAChE,MAAM,yBAAyB,GAAW,IAAI,CAAC,iBAAiB,CAAA;IAChE,MAAM,kBAAkB,GAAW,IAAI,CAAC,UAAU,CAAA;IAClD,MAAM,iBAAiB,GAAW,IAAI,CAAC,SAAS,CAAA;IAEhD,IAAA,eAAM,EAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,4CAA4C,CAAC,CAAA;IACpF,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;IAEzD,MAAM,QAAQ,GAAU,IAAA,4BAAa,EAAC,IAAI,CAAC,GAAG,EAAE,oBAAK,CAAC,IAAI,CAAC,CAAA;IAE3D,OAAO;QACL,UAAU;QACV,eAAe;QACf,aAAa;QACb,IAAI;QACJ,OAAO;QACP,mBAAmB;QACnB,yBAAyB;QACzB,yBAAyB;QACzB,kBAAkB;QAClB,iBAAiB;QACjB,WAAW;QACX,QAAQ;KACT,CAAA;AACH,CAAC"}
|
package/lib/router.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Router = exports.RouteResult = void 0;
|
|
4
4
|
const map_file_1 = require("./utils/map-file");
|
|
5
5
|
const resolve_a_1 = require("./utils/resolve-a");
|
|
6
|
-
const
|
|
6
|
+
const prelude_1 = require("@blackglory/prelude");
|
|
7
7
|
var RouteResult;
|
|
8
8
|
(function (RouteResult) {
|
|
9
9
|
RouteResult[RouteResult["UntrustedServer"] = 0] = "UntrustedServer";
|
|
@@ -11,30 +11,14 @@ var RouteResult;
|
|
|
11
11
|
RouteResult[RouteResult["Unresolved"] = 2] = "Unresolved";
|
|
12
12
|
})(RouteResult = exports.RouteResult || (exports.RouteResult = {}));
|
|
13
13
|
class Router {
|
|
14
|
-
constructor(cacheFilename, cache,
|
|
14
|
+
constructor(cacheFilename, cache, tester, untrustedResolver, ipWhitelist, hostnameWhitelist, hostnameBlacklist) {
|
|
15
15
|
this.cacheFilename = cacheFilename;
|
|
16
16
|
this.cache = cache;
|
|
17
|
-
this.looseMode = looseMode;
|
|
18
17
|
this.tester = tester;
|
|
19
18
|
this.untrustedResolver = untrustedResolver;
|
|
20
19
|
this.ipWhitelist = ipWhitelist;
|
|
21
20
|
this.hostnameWhitelist = hostnameWhitelist;
|
|
22
21
|
this.hostnameBlacklist = hostnameBlacklist;
|
|
23
|
-
this.route = (0, extra_promise_1.reusePendingPromise)(async (hostname) => {
|
|
24
|
-
const result = await this.routeByLocal(hostname);
|
|
25
|
-
if (result) {
|
|
26
|
-
return result;
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
if (this.looseMode) {
|
|
30
|
-
queueMicrotask(() => this.routeByNetwork(hostname));
|
|
31
|
-
return RouteResult.UntrustedServer;
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
return await this.routeByNetwork(hostname);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
22
|
}
|
|
39
23
|
static async create(options) {
|
|
40
24
|
const tester = options.tester;
|
|
@@ -43,10 +27,26 @@ class Router {
|
|
|
43
27
|
const hostnameWhitelist = options.hostnameWhitelist;
|
|
44
28
|
const hostnameBlacklist = options.hostnameBlacklist;
|
|
45
29
|
const cacheFilename = options.cacheFilename;
|
|
46
|
-
const looseMode = options.looseMode;
|
|
47
30
|
const cache = await (0, map_file_1.readMapFile)(cacheFilename);
|
|
48
31
|
await (0, map_file_1.writeMapFile)(cacheFilename, cache);
|
|
49
|
-
return new Router(cacheFilename, cache,
|
|
32
|
+
return new Router(cacheFilename, cache, tester, untrustedResolver, ipWhitelist, hostnameWhitelist, hostnameBlacklist);
|
|
33
|
+
}
|
|
34
|
+
async route(hostname) {
|
|
35
|
+
const result = await this.routeByLocal(hostname);
|
|
36
|
+
switch (result) {
|
|
37
|
+
case RouteResult.UntrustedServer:
|
|
38
|
+
case RouteResult.TrustedServer:
|
|
39
|
+
return result;
|
|
40
|
+
default: return await (0, prelude_1.go)(async () => {
|
|
41
|
+
const result = await this.routeByNetwork(hostname);
|
|
42
|
+
switch (result) {
|
|
43
|
+
case RouteResult.UntrustedServer:
|
|
44
|
+
case RouteResult.TrustedServer:
|
|
45
|
+
this.setCache(hostname, result);
|
|
46
|
+
default: return result;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
50
|
}
|
|
51
51
|
async routeByLocal(hostname) {
|
|
52
52
|
if (this.inHostnameWhitelist(hostname))
|
|
@@ -55,22 +55,19 @@ class Router {
|
|
|
55
55
|
return RouteResult.TrustedServer;
|
|
56
56
|
if (this.cache.has(hostname))
|
|
57
57
|
return this.cache.get(hostname);
|
|
58
|
-
return
|
|
58
|
+
return RouteResult.Unresolved;
|
|
59
59
|
}
|
|
60
60
|
async routeByNetwork(hostname) {
|
|
61
61
|
if (await this.tester.isPoisoned(hostname)) {
|
|
62
|
-
this.setCache(hostname, RouteResult.TrustedServer);
|
|
63
62
|
return RouteResult.TrustedServer;
|
|
64
63
|
}
|
|
65
64
|
else {
|
|
66
65
|
const addresses = await (0, resolve_a_1.resolveA)(this.untrustedResolver, hostname);
|
|
67
66
|
if (addresses.length > 0) {
|
|
68
67
|
if (this.inIPWhitelist(addresses)) {
|
|
69
|
-
this.setCache(hostname, RouteResult.UntrustedServer);
|
|
70
68
|
return RouteResult.UntrustedServer;
|
|
71
69
|
}
|
|
72
70
|
else {
|
|
73
|
-
this.setCache(hostname, RouteResult.TrustedServer);
|
|
74
71
|
return RouteResult.TrustedServer;
|
|
75
72
|
}
|
|
76
73
|
}
|
package/lib/router.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.js","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":";;;AAIA,8CAA0E;AAC1E,gDAA2C;AAC3C,
|
|
1
|
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":";;;AAIA,8CAA0E;AAC1E,gDAA2C;AAC3C,iDAAwC;AAExC,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,mEAAmB,CAAA;IACnB,+DAAiB,CAAA;IACjB,yDAAc,CAAA;AAChB,CAAC,EAJW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAItB;AAED,MAAa,MAAM;IACjB,YACU,aAAqB,EACrB,KAA+B,EAC/B,MAAc,EACd,iBAA+B,EAC/B,WAAwB,EACxB,iBAA+B,EAC/B,iBAA+B;QAN/B,kBAAa,GAAb,aAAa,CAAQ;QACrB,UAAK,GAAL,KAAK,CAA0B;QAC/B,WAAM,GAAN,MAAM,CAAQ;QACd,sBAAiB,GAAjB,iBAAiB,CAAc;QAC/B,gBAAW,GAAX,WAAW,CAAa;QACxB,sBAAiB,GAAjB,iBAAiB,CAAc;QAC/B,sBAAiB,GAAjB,iBAAiB,CAAc;IACtC,CAAC;IAEJ,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAOnB;QACC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;QAC7B,MAAM,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAA;QACnD,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAA;QACvC,MAAM,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAA;QACnD,MAAM,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAA;QACnD,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,CAAA;QAE3C,MAAM,KAAK,GAAG,MAAM,IAAA,sBAAW,EAAsB,aAAa,CAAC,C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-node-dns"));
|
|
32
32
|
const return_style_1 = require("return-style");
|
|
33
|
-
const ms_1 = __importDefault(require("ms"));
|
|
34
33
|
const chalk_1 = __importDefault(require("chalk"));
|
|
35
34
|
const record_types_1 = require("./record-types");
|
|
36
|
-
|
|
37
|
-
function startServer({ logger, port, router, trustedServer, untrustedServer }) {
|
|
35
|
+
function startServer({ logger, port, timeout, router, trustedServer, untrustedServer }) {
|
|
38
36
|
const server = dns.createServer();
|
|
39
37
|
server.on('error', console.error);
|
|
40
38
|
server.on('socketError', console.error);
|
|
@@ -43,17 +41,17 @@ function startServer({ logger, port, router, trustedServer, untrustedServer }) {
|
|
|
43
41
|
res.header.rcode = dns.consts.NAME_TO_RCODE.SERVFAIL;
|
|
44
42
|
const startTime = Date.now();
|
|
45
43
|
const question = req.question[0];
|
|
46
|
-
|
|
47
|
-
if (
|
|
48
|
-
logger.error(`${formatHostname(question.name)} ${
|
|
44
|
+
const [err1, result] = await (0, return_style_1.getErrorResultAsync)(() => router.route(question.name));
|
|
45
|
+
if (err1) {
|
|
46
|
+
logger.error(`${formatHostname(question.name)} ${err1}`, getElapsed(startTime));
|
|
49
47
|
logger.trace(`response: ${JSON.stringify(res)}`);
|
|
50
48
|
return res.send();
|
|
51
49
|
}
|
|
52
50
|
logger.debug(`${formatHostname(question.name)} ${router_1.RouteResult[result]}`, getElapsed(startTime));
|
|
53
51
|
const server = result === router_1.RouteResult.TrustedServer ? trustedServer : untrustedServer;
|
|
54
|
-
|
|
55
|
-
if (
|
|
56
|
-
logger.error(`${formatHostname(question.name)} ${
|
|
52
|
+
const [err2, response] = await (0, return_style_1.getErrorResultAsync)(() => resolve(server, question, timeout));
|
|
53
|
+
if (err2) {
|
|
54
|
+
logger.error(`${formatHostname(question.name)} ${err2}`, getElapsed(startTime));
|
|
57
55
|
logger.trace(`response: ${JSON.stringify(res)}`);
|
|
58
56
|
return res.send();
|
|
59
57
|
}
|
|
@@ -67,7 +65,7 @@ function startServer({ logger, port, router, trustedServer, untrustedServer }) {
|
|
|
67
65
|
server.serve(port);
|
|
68
66
|
}
|
|
69
67
|
exports.startServer = startServer;
|
|
70
|
-
|
|
68
|
+
function resolve(server, question, timeout) {
|
|
71
69
|
return new Promise((resolve, reject) => {
|
|
72
70
|
let response;
|
|
73
71
|
const request = dns.Request({
|
|
@@ -77,7 +75,7 @@ const resolve = (0, extra_promise_1.reusePendingPromise)(function (server, quest
|
|
|
77
75
|
port: server.port,
|
|
78
76
|
type: 'udp'
|
|
79
77
|
},
|
|
80
|
-
timeout
|
|
78
|
+
timeout,
|
|
81
79
|
cache: false,
|
|
82
80
|
try_edns: true
|
|
83
81
|
});
|
|
@@ -98,7 +96,7 @@ const resolve = (0, extra_promise_1.reusePendingPromise)(function (server, quest
|
|
|
98
96
|
});
|
|
99
97
|
request.send();
|
|
100
98
|
});
|
|
101
|
-
}
|
|
99
|
+
}
|
|
102
100
|
function formatHostname(hostname) {
|
|
103
101
|
return chalk_1.default.cyan(hostname);
|
|
104
102
|
}
|
package/lib/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAA8C;AAC9C,qDAAsC;AAEtC,+CAAkD;AAElD,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAA8C;AAC9C,qDAAsC;AAEtC,+CAAkD;AAElD,kDAAyB;AACzB,iDAA2C;AAW3C,SAAgB,WAAW,CAAC,EAC1B,MAAM,EACN,IAAI,EACJ,OAAO,EACP,MAAM,EACN,aAAa,EACb,eAAe,EACK;IACpB,MAAM,MAAM,GAAG,GAAG,CAAC,YAAY,EAAE,CAAA;IAEjC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;IACjC,MAAM,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"keywords": [
|
|
6
6
|
"dns"
|
|
@@ -35,7 +35,6 @@
|
|
|
35
35
|
"@commitlint/cli": "^17.0.3",
|
|
36
36
|
"@commitlint/config-conventional": "^17.0.3",
|
|
37
37
|
"@types/jest": "^27.4.1",
|
|
38
|
-
"@types/ms": "^0.7.31",
|
|
39
38
|
"@types/node": "14",
|
|
40
39
|
"@types/ping": "^0.4.1",
|
|
41
40
|
"@typescript-eslint/eslint-plugin": "^5.30.7",
|
|
@@ -63,7 +62,6 @@
|
|
|
63
62
|
"extra-logger": "^0.6.8",
|
|
64
63
|
"extra-promise": "^2.3.0",
|
|
65
64
|
"iterable-operator": "^1.1.0",
|
|
66
|
-
"ms": "^2.1.3",
|
|
67
65
|
"native-node-dns": "0.7.6",
|
|
68
66
|
"native-node-dns-packet": "0.1.5",
|
|
69
67
|
"patch-package": "^6.4.7",
|
package/CHANGELOG.md
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
|
-
|
|
5
|
-
### [0.3.16](https://github.com/BlackGlory/fcdns/compare/v0.3.15...v0.3.16) (2022-07-25)
|
|
6
|
-
|
|
7
|
-
### [0.3.15](https://github.com/BlackGlory/fcdns/compare/v0.3.14...v0.3.15) (2022-04-16)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
### Bug Fixes
|
|
11
|
-
|
|
12
|
-
* hostname blacklist ([0e21a21](https://github.com/BlackGlory/fcdns/commit/0e21a214c13633ee4a3b2fe6353ae97d72f3fa65))
|
|
13
|
-
|
|
14
|
-
### [0.3.14](https://github.com/BlackGlory/fcdns/compare/v0.3.13...v0.3.14) (2022-04-16)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
### Features
|
|
18
|
-
|
|
19
|
-
* add hostname blacklist ([f196de1](https://github.com/BlackGlory/fcdns/commit/f196de13e742935ccdf4f67e1b54f73b057e15e8))
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
### Bug Fixes
|
|
23
|
-
|
|
24
|
-
* make hostname list files optional ([ab2352f](https://github.com/BlackGlory/fcdns/commit/ab2352ff55dd05f947fa8eedd9dc6706e36c67ad))
|
|
25
|
-
|
|
26
|
-
### [0.3.13](https://github.com/BlackGlory/fcdns/compare/v0.3.12...v0.3.13) (2022-04-01)
|
|
27
|
-
|
|
28
|
-
### [0.3.12](https://github.com/BlackGlory/fcdns/compare/v0.3.11...v0.3.12) (2022-03-26)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
### Bug Fixes
|
|
32
|
-
|
|
33
|
-
* try fix the out of range problem about SOA serial ([ebc5275](https://github.com/BlackGlory/fcdns/commit/ebc5275cd7ec3074e07558b52ca93d492919f07c))
|
|
34
|
-
|
|
35
|
-
### [0.3.11](https://github.com/BlackGlory/fcdns/compare/v0.3.10...v0.3.11) (2022-03-26)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
### Bug Fixes
|
|
39
|
-
|
|
40
|
-
* make sure to throw errors ([85ee589](https://github.com/BlackGlory/fcdns/commit/85ee58964c0b20df765c1d61dc4e3fb5e2c95dfd))
|
|
41
|
-
|
|
42
|
-
### [0.3.10](https://github.com/BlackGlory/fcdns/compare/v0.3.9...v0.3.10) (2022-03-23)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
### Bug Fixes
|
|
46
|
-
|
|
47
|
-
* edge case ([9162617](https://github.com/BlackGlory/fcdns/commit/9162617e2ace75b22e418674320f79858bbdc959))
|
|
48
|
-
|
|
49
|
-
### [0.3.9](https://github.com/BlackGlory/fcdns/compare/v0.3.8...v0.3.9) (2022-03-20)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
### Bug Fixes
|
|
53
|
-
|
|
54
|
-
* logging ([4902a1f](https://github.com/BlackGlory/fcdns/commit/4902a1f1390a83d02dbbf48395c74d791f5f27da))
|
|
55
|
-
|
|
56
|
-
### [0.3.8](https://github.com/BlackGlory/fcdns/compare/v0.3.7...v0.3.8) (2022-03-20)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
### Bug Fixes
|
|
60
|
-
|
|
61
|
-
* logging ([21a71d5](https://github.com/BlackGlory/fcdns/commit/21a71d5988da3b32564b058be51fe98366bb3ccf))
|
|
62
|
-
|
|
63
|
-
### [0.3.7](https://github.com/BlackGlory/fcdns/compare/v0.3.6...v0.3.7) (2022-03-20)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
### Bug Fixes
|
|
67
|
-
|
|
68
|
-
* forward entire response instead of answers ([326fbaf](https://github.com/BlackGlory/fcdns/commit/326fbaf40bc028bdd8c1d3b7c5c540430aa0e7dd))
|
|
69
|
-
|
|
70
|
-
### [0.3.6](https://github.com/BlackGlory/fcdns/compare/v0.3.5...v0.3.6) (2022-03-03)
|
|
71
|
-
|
|
72
|
-
### [0.3.5](https://github.com/BlackGlory/fcdns/compare/v0.3.4...v0.3.5) (2022-02-28)
|
|
73
|
-
|
|
74
|
-
### [0.3.4](https://github.com/BlackGlory/fcdns/compare/v0.3.3...v0.3.4) (2022-02-28)
|
|
75
|
-
|
|
76
|
-
### [0.3.3](https://github.com/BlackGlory/fcdns/compare/v0.3.2...v0.3.3) (2022-01-02)
|
|
77
|
-
|
|
78
|
-
### [0.3.2](https://github.com/BlackGlory/fcdns/compare/v0.3.1...v0.3.2) (2021-12-21)
|
|
79
|
-
|
|
80
|
-
### [0.3.1](https://github.com/BlackGlory/fcdns/compare/v0.3.0...v0.3.1) (2021-12-17)
|
|
81
|
-
|
|
82
|
-
## [0.3.0](https://github.com/BlackGlory/fcdns/compare/v0.2.7...v0.3.0) (2021-12-17)
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
### ⚠ BREAKING CHANGES
|
|
86
|
-
|
|
87
|
-
* - The minimum version is Node.js v16
|
|
88
|
-
|
|
89
|
-
* upgrade dependencies ([c9072dc](https://github.com/BlackGlory/fcdns/commit/c9072dc80e8f6867aca7f0a9d05abec154195f21))
|
|
90
|
-
|
|
91
|
-
### [0.2.7](https://github.com/BlackGlory/fcdns/compare/v0.2.6...v0.2.7) (2021-12-12)
|
|
92
|
-
|
|
93
|
-
### [0.2.6](https://github.com/BlackGlory/fcdns/compare/v0.2.5...v0.2.6) (2021-10-17)
|
|
94
|
-
|
|
95
|
-
### [0.2.5](https://github.com/BlackGlory/fcdns/compare/v0.2.4...v0.2.5) (2021-10-14)
|
|
96
|
-
|
|
97
|
-
### [0.2.4](https://github.com/BlackGlory/fcdns/compare/v0.2.3...v0.2.4) (2021-10-06)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
### Features
|
|
101
|
-
|
|
102
|
-
* add loose mode ([561f7f9](https://github.com/BlackGlory/fcdns/commit/561f7f9181a5bd76e5093ed5e7fc65daadd4702d))
|
|
103
|
-
|
|
104
|
-
### [0.2.3](https://github.com/BlackGlory/fcdns/compare/v0.2.2...v0.2.3) (2021-09-18)
|
|
105
|
-
|
|
106
|
-
### [0.2.2](https://github.com/BlackGlory/fcdns/compare/v0.2.1...v0.2.2) (2021-07-12)
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
### Bug Fixes
|
|
110
|
-
|
|
111
|
-
* isHostnamePattern ([eee8e03](https://github.com/BlackGlory/fcdns/commit/eee8e03703e4cac962db6b2d05965f877051c30b))
|
|
112
|
-
|
|
113
|
-
### [0.2.1](https://github.com/BlackGlory/fcdns/compare/v0.2.0...v0.2.1) (2021-07-09)
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
### Features
|
|
117
|
-
|
|
118
|
-
* improve hostname pattern ([f86b9a6](https://github.com/BlackGlory/fcdns/commit/f86b9a64c92160dc5995fa1dc77e0a1f2c1daa3d))
|
|
119
|
-
|
|
120
|
-
## [0.2.0](https://github.com/BlackGlory/fcdns/compare/v0.1.6...v0.2.0) (2021-07-09)
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
### ⚠ BREAKING CHANGES
|
|
124
|
-
|
|
125
|
-
* rename whitelist.txt to ip-whitelist.txt
|
|
126
|
-
|
|
127
|
-
### Features
|
|
128
|
-
|
|
129
|
-
* add hostname whitelist ([f96d2f3](https://github.com/BlackGlory/fcdns/commit/f96d2f38daf1506e168d7e380b09edad87165d06))
|
|
130
|
-
* support to parse ip addresses in whitelist ([10024db](https://github.com/BlackGlory/fcdns/commit/10024db45acb5201f67ecc64a7e2cf54ade396b4))
|
|
131
|
-
|
|
132
|
-
### [0.1.6](https://github.com/BlackGlory/fcdns/compare/v0.1.5...v0.1.6) (2021-05-17)
|
|
133
|
-
|
|
134
|
-
### [0.1.5](https://github.com/BlackGlory/fcdns/compare/v0.1.4...v0.1.5) (2021-05-14)
|
|
135
|
-
|
|
136
|
-
### [0.1.4](https://github.com/BlackGlory/fcdns/compare/v0.1.3...v0.1.4) (2021-05-08)
|
|
137
|
-
|
|
138
|
-
### [0.1.3](https://github.com/BlackGlory/fcdns/compare/v0.1.2...v0.1.3) (2021-05-08)
|
|
139
|
-
|
|
140
|
-
### [0.1.2](https://github.com/BlackGlory/fcdns/compare/v0.1.1...v0.1.2) (2021-04-22)
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
### Bug Fixes
|
|
144
|
-
|
|
145
|
-
* handle uncaught errors ([a324ed8](https://github.com/BlackGlory/fcdns/commit/a324ed8241feb1aab029b5bd23d3f792bce42c58))
|
|
146
|
-
|
|
147
|
-
### [0.1.1](https://github.com/BlackGlory/fcdns/compare/v0.1.0...v0.1.1) (2021-04-14)
|
|
148
|
-
|
|
149
|
-
## 0.1.0 (2021-04-12)
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
### Features
|
|
153
|
-
|
|
154
|
-
* init ([5185bb9](https://github.com/BlackGlory/fcdns/commit/5185bb9103536124b15192b340bd0a91d1eb49af))
|
package/lib/logger.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createCustomLogger = void 0;
|
|
7
|
-
const extra_logger_1 = require("extra-logger");
|
|
8
|
-
const level_to_string_1 = require("./utils/level-to-string");
|
|
9
|
-
const types_1 = require("@blackglory/types");
|
|
10
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
-
function createCustomLogger(level) {
|
|
12
|
-
return (0, extra_logger_1.createLogger)(level, {
|
|
13
|
-
[1]: printMessage(1, console.log),
|
|
14
|
-
[2]: printMessage(2, console.log),
|
|
15
|
-
[3]: printMessage(3, console.info),
|
|
16
|
-
[4]: printMessage(4, console.warn),
|
|
17
|
-
[5]: printError(5, console.error),
|
|
18
|
-
[6]: printError(6, console.error)
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
exports.createCustomLogger = createCustomLogger;
|
|
22
|
-
function printMessage(level, log) {
|
|
23
|
-
return ({ id, timestamp, hostname, elapsed, message }) => {
|
|
24
|
-
const pre = createPrefix({ level, id, timestamp, hostname });
|
|
25
|
-
const post = (0, types_1.isntUndefined)(elapsed) ? createPostfix({ elapsed }) : null;
|
|
26
|
-
let result = `${pre} ${message}`;
|
|
27
|
-
if (post) {
|
|
28
|
-
result += ' ' + post;
|
|
29
|
-
}
|
|
30
|
-
log(result);
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
function printError(level, log) {
|
|
34
|
-
return ({ id, timestamp, hostname, elapsed, reason }) => {
|
|
35
|
-
const pre = createPrefix({ level, id, timestamp, hostname });
|
|
36
|
-
const post = (0, types_1.isntUndefined)(elapsed) ? createPostfix({ elapsed }) : null;
|
|
37
|
-
let result = `${pre} ${reason}`;
|
|
38
|
-
if (post) {
|
|
39
|
-
result += ' ' + post;
|
|
40
|
-
}
|
|
41
|
-
log(result);
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
function createPrefix({ level, timestamp, id, hostname }) {
|
|
45
|
-
return `[${(0, level_to_string_1.levelToString)(level).toUpperCase()}]`
|
|
46
|
-
+ `[${formatDate(timestamp)}]`
|
|
47
|
-
+ ` #${id}`
|
|
48
|
-
+ ` ${formatHostname(hostname)}`;
|
|
49
|
-
}
|
|
50
|
-
function createPostfix({ elapsed }) {
|
|
51
|
-
return formatElapsedTime(elapsed);
|
|
52
|
-
}
|
|
53
|
-
function formatDate(timestamp) {
|
|
54
|
-
return new Date(timestamp).toLocaleString();
|
|
55
|
-
}
|
|
56
|
-
function formatHostname(hostname) {
|
|
57
|
-
return chalk_1.default.cyan(hostname);
|
|
58
|
-
}
|
|
59
|
-
function formatElapsedTime(elapsed) {
|
|
60
|
-
if (elapsed <= 100) {
|
|
61
|
-
return chalk_1.default.green `${elapsed}ms`;
|
|
62
|
-
}
|
|
63
|
-
if (elapsed <= 300) {
|
|
64
|
-
return chalk_1.default.yellow `${elapsed}ms`;
|
|
65
|
-
}
|
|
66
|
-
return chalk_1.default.red `${elapsed}ms`;
|
|
67
|
-
}
|
|
68
|
-
//# sourceMappingURL=logger.js.map
|
package/lib/logger.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";;;;;;AAAA,+CAAkD;AAClD,4DAAsD;AACtD,6CAAiD;AACjD,kDAAyB;AAyBzB,SAAgB,kBAAkB,CAAC,KAAY;IAC7C,OAAO,IAAA,2BAAY,EAAC,KAAK,EAAE;QACzB,GAAa,EAAE,YAAY,IAAc,OAAO,CAAC,GAAG,CAAC;QACrD,GAAa,EAAE,YAAY,IAAc,OAAO,CAAC,GAAG,CAAC;QACrD,GAAY,EAAE,YAAY,IAAa,OAAO,CAAC,IAAI,CAAC;QACpD,GAAY,EAAE,YAAY,IAAa,OAAO,CAAC,IAAI,CAAC;QACpD,GAAa,EAAE,UAAU,IAAc,OAAO,CAAC,KAAK,CAAC;QACrD,GAAa,EAAE,UAAU,IAAc,OAAO,CAA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,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,QAAQ,EAAW;IAC/D,OAAO,IAAI,IAAA,+BAAa,EAAC,KAAK,CAAC,CAAC,WAAW,EAAE,GAAG;UACzC,IAAI,UAAU,CAAC,SAAS,CAAC,GAAG;UAC5B,KAAK,EAAE,EAAE;UACT,IAAI,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAA;AACvC,CAAC;AAED,SAAS,aAAa,CAAC,EAAE,OAAO,EAAuB;IACrD,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAA;AACnC,CAAC;AAED,SAAS,UAAU,CAAC,SAAiB;IACnC,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,cAAc,EAAE,CAAA;AAC7C,CAAC;AAED,SAAS,cAAc,CAAC,QAAgB;IACtC,OAAO,eAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;AAC7B,CAAC;AAED,SAAS,iBAAiB,CAAC,OAAe;IACxC,IAAI,OAAO,IAAI,GAAG,EAAE;QAClB,OAAO,eAAK,CAAC,KAAK,CAAA,GAAG,OAAO,IAAI,CAAA;KACjC;IAED,IAAI,OAAO,IAAI,GAAG,EAAE;QAClB,OAAO,eAAK,CAAC,MAAM,CAAA,GAAG,OAAO,IAAI,CAAA;KAClC;IAED,OAAO,eAAK,CAAC,GAAG,CAAA,GAAG,OAAO,IAAI,CAAA;AAChC,CAAC"}
|
package/lib/utils/countup.js
DELETED
package/lib/utils/countup.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"countup.js","sourceRoot":"","sources":["../../src/utils/countup.ts"],"names":[],"mappings":";;;AAAA,IAAI,KAAK,GAAG,CAAC,CAAA;AAEb,SAAgB,OAAO;IACrB,OAAO,EAAE,KAAK,CAAA;AAChB,CAAC;AAFD,0BAEC"}
|
package/lib/utils/get-elapsed.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getElapsed = void 0;
|
|
4
|
-
const get_timestamp_1 = require("./get-timestamp");
|
|
5
|
-
function getElapsed(startTime) {
|
|
6
|
-
return (0, get_timestamp_1.getTimestamp)() - startTime;
|
|
7
|
-
}
|
|
8
|
-
exports.getElapsed = getElapsed;
|
|
9
|
-
//# sourceMappingURL=get-elapsed.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-elapsed.js","sourceRoot":"","sources":["../../src/utils/get-elapsed.ts"],"names":[],"mappings":";;;AAAA,wDAAmD;AAEnD,SAAgB,UAAU,CAAC,SAAiB;IAC1C,OAAO,IAAA,4BAAY,GAAE,GAAG,SAAS,CAAA;AACnC,CAAC;AAFD,gCAEC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-timestamp.js","sourceRoot":"","sources":["../../src/utils/get-timestamp.ts"],"names":[],"mappings":";;;AAAA,SAAgB,YAAY;IAC1B,OAAO,IAAI,CAAC,GAAG,EAAE,CAAA;AACnB,CAAC;AAFD,oCAEC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.levelToString = void 0;
|
|
4
|
-
function levelToString(level) {
|
|
5
|
-
switch (level) {
|
|
6
|
-
case 3: return 'Info';
|
|
7
|
-
case 2: return 'Debug';
|
|
8
|
-
case 4: return 'Warn';
|
|
9
|
-
case 1: return 'Trace';
|
|
10
|
-
case 5: return 'Error';
|
|
11
|
-
case 6: return 'Fatal';
|
|
12
|
-
default: return 'None';
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.levelToString = levelToString;
|
|
16
|
-
//# sourceMappingURL=level-to-string.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"level-to-string.js","sourceRoot":"","sources":["../../src/utils/level-to-string.ts"],"names":[],"mappings":";;;AAEA,SAAgB,aAAa,CAAC,KAAY;IACxC,QAAQ,KAAK,EAAE;QACb,MAAe,CAAC,CAAC,OAAO,MAAM,CAAA;QAC9B,MAAgB,CAAC,CAAC,OAAO,OAAO,CAAA;QAChC,MAAe,CAAC,CAAC,OAAO,MAAM,CAAA;QAC9B,MAAgB,CAAC,CAAC,OAAO,OAAO,CAAA;QAChC,MAAgB,CAAC,CAAC,OAAO,OAAO,CAAA;QAChC,MAAgB,CAAC,CAAC,OAAO,OAAO,CAAA;QAChC,OAAO,CAAC,CAAC,OAAO,MAAM,CAAA;KACvB;AACH,CAAC;AAVD,sCAUC"}
|