fcdns 0.5.9 → 0.5.10
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 +8 -8
- package/dist/cli.cjs +67 -51
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,14 +19,14 @@ Options:
|
|
|
19
19
|
--test-server <server>
|
|
20
20
|
--untrusted-server <server>
|
|
21
21
|
--trusted-server <server>
|
|
22
|
-
--port
|
|
23
|
-
--timeout
|
|
24
|
-
--ip-whitelist
|
|
25
|
-
--hostname-whitelist
|
|
26
|
-
--hostname-blacklist
|
|
27
|
-
--cache
|
|
28
|
-
--test-timeout
|
|
29
|
-
--log
|
|
22
|
+
--port <port> (default: "53")
|
|
23
|
+
--timeout <seconds> (default: "30")
|
|
24
|
+
--ip-whitelist <filename> (default: "ip-whitelist.txt")
|
|
25
|
+
--hostname-whitelist <filename> (default: "hostname-whitelist.txt")
|
|
26
|
+
--hostname-blacklist <filename> (default: "hostname-blacklist.txt")
|
|
27
|
+
--cache <filename> (default: "cache.db")
|
|
28
|
+
--test-timeout <milliseconds> (default: "200")
|
|
29
|
+
--log <level> (default: "info")
|
|
30
30
|
-h, --help display help for command
|
|
31
31
|
```
|
|
32
32
|
|
package/dist/cli.cjs
CHANGED
|
@@ -53,27 +53,39 @@ commander_1.program
|
|
|
53
53
|
.requiredOption('--test-server <server>')
|
|
54
54
|
.requiredOption('--untrusted-server <server>')
|
|
55
55
|
.requiredOption('--trusted-server <server>')
|
|
56
|
-
.option('--port
|
|
57
|
-
.option('--timeout
|
|
58
|
-
.option('--ip-whitelist
|
|
59
|
-
.option('--hostname-whitelist
|
|
60
|
-
.option('--hostname-blacklist
|
|
61
|
-
.option('--cache
|
|
62
|
-
.option('--test-timeout
|
|
63
|
-
.option('--log
|
|
56
|
+
.option('--port <port>', '', '53')
|
|
57
|
+
.option('--timeout <seconds>', '', '30')
|
|
58
|
+
.option('--ip-whitelist <filename>', '', 'ip-whitelist.txt')
|
|
59
|
+
.option('--hostname-whitelist <filename>', '', 'hostname-whitelist.txt')
|
|
60
|
+
.option('--hostname-blacklist <filename>', '', 'hostname-blacklist.txt')
|
|
61
|
+
.option('--cache <filename>', '', 'cache.db')
|
|
62
|
+
.option('--test-timeout <milliseconds>', '', '200')
|
|
63
|
+
.option('--log <level>', '', 'info')
|
|
64
64
|
.action(async () => {
|
|
65
|
-
const options =
|
|
66
|
-
|
|
65
|
+
const options = commander_1.program.opts();
|
|
66
|
+
const cacheFilename = getCacheFilename(options);
|
|
67
|
+
const testServer = getTestServer(options);
|
|
68
|
+
const testTimeout = getTestTimeout(options);
|
|
69
|
+
const timeout = getTimeout(options);
|
|
70
|
+
const port = getPort(options);
|
|
71
|
+
const logLevel = getLogLevel(options);
|
|
72
|
+
const ipWhitelistFilename = getIpWhiltelistFilename(options);
|
|
73
|
+
const hostnameWhitelistFilename = getHostnameWhitelistFilename(options);
|
|
74
|
+
const hostnameBlacklistFilename = getHostnameBlacklistFilename(options);
|
|
75
|
+
const untrustedServer = getUntrustedServer(options);
|
|
76
|
+
const trustedServer = getTrustedServer(options);
|
|
77
|
+
Database.openDatabase(cacheFilename);
|
|
67
78
|
await Database.prepareDatabase();
|
|
68
79
|
(0, you_died_1.youDied)(() => Database.closeDatabase());
|
|
69
80
|
const poisonTester = new poison_tester_1.PoisonTester({
|
|
70
|
-
server:
|
|
71
|
-
timeout:
|
|
81
|
+
server: testServer,
|
|
82
|
+
timeout: testTimeout
|
|
72
83
|
});
|
|
73
|
-
const untrustedResolver = (0, create_dns_resolver_1.createDNSResolver)(
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
const
|
|
84
|
+
const untrustedResolver = (0, create_dns_resolver_1.createDNSResolver)(untrustedServer.host
|
|
85
|
+
+ (untrustedServer.port ? `:${untrustedServer.port}` : ''));
|
|
86
|
+
const ipWhitelist = await ip_ranges_1.IPRanges.fromFile(ipWhitelistFilename);
|
|
87
|
+
const hostnameWhitelist = await hostnames_1.Hostnames.fromFile(hostnameWhitelistFilename);
|
|
88
|
+
const hostnameBlacklist = await hostnames_1.Hostnames.fromFile(hostnameBlacklistFilename);
|
|
77
89
|
const router = new router_1.Router({
|
|
78
90
|
poisonTester,
|
|
79
91
|
untrustedResolver,
|
|
@@ -82,50 +94,54 @@ commander_1.program
|
|
|
82
94
|
hostnameBlacklist
|
|
83
95
|
});
|
|
84
96
|
const logger = new extra_logger_1.Logger({
|
|
85
|
-
level:
|
|
97
|
+
level: logLevel,
|
|
86
98
|
transport: new extra_logger_1.TerminalTransport({})
|
|
87
99
|
});
|
|
88
|
-
const untrustedServer = (0, parse_server_info_1.parseServerInfo)(options.untrustedServer);
|
|
89
|
-
const trustedServer = (0, parse_server_info_1.parseServerInfo)(options.trustedServer);
|
|
90
100
|
(0, server_1.startServer)({
|
|
91
101
|
router,
|
|
92
102
|
logger,
|
|
93
103
|
trustedServer,
|
|
94
104
|
untrustedServer,
|
|
95
|
-
timeout
|
|
96
|
-
port
|
|
105
|
+
timeout,
|
|
106
|
+
port
|
|
97
107
|
});
|
|
98
108
|
})
|
|
99
109
|
.parse();
|
|
100
|
-
function
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
(0,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
110
|
+
function getTestServer(options) {
|
|
111
|
+
return options.testServer;
|
|
112
|
+
}
|
|
113
|
+
function getUntrustedServer(options) {
|
|
114
|
+
return (0, parse_server_info_1.parseServerInfo)(options.untrustedServer);
|
|
115
|
+
}
|
|
116
|
+
function getTrustedServer(options) {
|
|
117
|
+
return (0, parse_server_info_1.parseServerInfo)(options.trustedServer);
|
|
118
|
+
}
|
|
119
|
+
function getPort(options) {
|
|
120
|
+
(0, prelude_1.assert)(/^\d+$/.test(options.port), 'The parameter port must be integer');
|
|
121
|
+
return Number.parseInt(options.port, 10);
|
|
122
|
+
}
|
|
123
|
+
function getTimeout(options) {
|
|
124
|
+
(0, prelude_1.assert)(/^\d+$/.test(options.timeout), 'The parameter timeout must be integer');
|
|
125
|
+
return Number.parseInt(options.port, 10) * 1000;
|
|
126
|
+
}
|
|
127
|
+
function getIpWhiltelistFilename(options) {
|
|
128
|
+
return options.ipWhitelist;
|
|
129
|
+
}
|
|
130
|
+
function getHostnameWhitelistFilename(options) {
|
|
131
|
+
return options.hostnameWhitelist;
|
|
132
|
+
}
|
|
133
|
+
function getHostnameBlacklistFilename(options) {
|
|
134
|
+
return options.hostnameBlacklist;
|
|
135
|
+
}
|
|
136
|
+
function getCacheFilename(options) {
|
|
137
|
+
return options.cache;
|
|
138
|
+
}
|
|
139
|
+
function getTestTimeout(options) {
|
|
140
|
+
(0, prelude_1.assert)(/^\d+$/.test(options.testTimeout), 'The parameter test timeout must be integer');
|
|
141
|
+
return Number.parseInt(options.testTimeout, 10);
|
|
142
|
+
}
|
|
143
|
+
function getLogLevel(options) {
|
|
144
|
+
return (0, extra_logger_1.stringToLevel)(options.log, extra_logger_1.Level.Info);
|
|
129
145
|
}
|
|
130
146
|
//# sourceMappingURL=cli.js.map
|
|
131
147
|
|
|
@@ -48243,7 +48259,7 @@ exports.Constructor = Constructor;
|
|
|
48243
48259
|
/***/ ((module) => {
|
|
48244
48260
|
|
|
48245
48261
|
"use strict";
|
|
48246
|
-
module.exports = JSON.parse('{"name":"fcdns","version":"0.5.
|
|
48262
|
+
module.exports = JSON.parse('{"name":"fcdns","version":"0.5.10","description":"DNS relay server with fact-checking.","keywords":["dns"],"bin":"dist/cli.cjs","files":["migrations","dist"],"repository":"git@github.com:BlackGlory/fcdns.git","author":"BlackGlory <woshenmedoubuzhidao@blackglory.me>","license":"MIT","scripts":{"prepare":"ts-patch install -s","deduplicate":"yarn-deduplicate","postinstall":"patch-package","prepublishOnly":"run-s postinstall prepare clean build bundle","lint":"eslint --ext .js,.jsx,.ts,.tsx --quiet src","test":"jest --config jest.config.js","test:debug":"node --inspect-brk node_modules/.bin/jest --runInBand","test:coverage":"jest --coverage --config jest.config.js","clean":"rimraf lib dist","build":"run-p build:*","build:src":"tsc --project tsconfig.build.json","build:scripts":"tsc --project tsconfig.scripts.json","bundle":"webpack --stats-error-details","smoke":"node dist/cli.cjs --help","release":"standard-version","script:generate-whitelist-by-cc":"ts-node scripts/generate-whitelist-by-cc.ts","script:import-poison-test-results-from-ndjson-map-file":"ts-node scripts/import-poison-test-results-from-ndjson-map-file.ts","script:import-route-results-from-ndjson-map-file":"ts-node scripts/import-route-results-from-ndjson-map-file.ts"},"husky":{"hooks":{"pre-commit":"run-s postinstall prepare clean lint build test bundle smoke","commit-msg":"commitlint --env HUSKY_GIT_PARAMS"}},"devDependencies":{"@commitlint/cli":"^17.0.3","@commitlint/config-conventional":"^17.0.3","@types/better-sqlite3":"^7.6.0","@types/jest":"^27.4.1","@types/node":"14","@types/ping":"^0.4.1","@typescript-eslint/eslint-plugin":"^5.33.0","@typescript-eslint/parser":"^5.33.0","eslint":"^8.21.0","extra-prompts":"^0.1.3","husky":"4","internet-number":"^3.0.3","jest":"^27.5.1","npm-run-all":"^4.1.5","rimraf":"^3.0.2","standard-version":"^9.5.0","ts-jest":"^27.1.4","ts-node":"^10.9.1","ts-patch":"^2.0.2","typescript":"^4.7.4","typescript-transform-paths":"^3.3.1","webpack":"^5.74.0","webpack-cli":"^4.10.0","webpack-shebang-plugin":"^1.1.8","yarn-deduplicate":"^5.0.0"},"dependencies":{"@blackglory/better-sqlite3-migrations":"^0.1.15","@blackglory/errors":"^2.2.2","@blackglory/prelude":"^0.1.3","@blackglory/structures":"^0.6.2","address-range":"^0.2.11","better-sqlite3":"^7.6.2","chalk":"^4.1.2","commander":"^9.4.0","extra-filesystem":"^0.4.5","extra-lazy":"^1.3.1","extra-logger":"^0.6.9","extra-promise":"^2.4.1","iterable-operator":"^1.2.0","migrations-file":"^0.2.4","native-node-dns":"0.7.6","native-node-dns-packet":"0.1.5","patch-package":"^6.4.7","ping":"^0.4.2","return-style":"^1.0.0","you-died":"^0.4.1"}}');
|
|
48247
48263
|
|
|
48248
48264
|
/***/ })
|
|
48249
48265
|
/******/ ]);
|