Skip to content

Commit 82e7f57

Browse files
committed
Perf: speed up build
1 parent 684d35e commit 82e7f57

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

Build/build-anti-bogus-domain.js

+9-11
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,18 @@ const { task } = require('./lib/trace-runner');
88

99
const getBogusNxDomainIPs = async () => {
1010
/** @type {string[]} */
11-
const res = [];
11+
const result = [];
1212
for await (const line of await fetchRemoteTextAndCreateReadlineInterface('https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/bogus-nxdomain.china.conf')) {
1313
if (line.startsWith('bogus-nxdomain=')) {
14-
res.push(line.replace('bogus-nxdomain=', ''));
14+
const ip = line.slice(15).trim();
15+
if (isIPv4(ip)) {
16+
result.push(`IP-CIDR,${ip}/32,no-resolve`);
17+
} else if (isIPv6(ip)) {
18+
result.push(`IP-CIDR6,${ip}/128,no-resolve`);
19+
}
1520
}
1621
}
17-
return res;
22+
return result;
1823
};
1924

2025
const buildAntiBogusDomain = task(__filename, async () => {
@@ -26,14 +31,7 @@ const buildAntiBogusDomain = task(__filename, async () => {
2631
const result = [];
2732
for await (const line of readFileByLine(filePath)) {
2833
if (line === '# --- [Anti Bogus Domain Replace Me] ---') {
29-
(await bogusIpPromise).forEach(ip => {
30-
if (isIPv4(ip)) {
31-
result.push(`IP-CIDR,${ip}/32,no-resolve`);
32-
} else if (isIPv6(ip)) {
33-
result.push(`IP-CIDR6,${ip}/128,no-resolve`);
34-
}
35-
});
36-
34+
(await bogusIpPromise).forEach(rule => result.push(rule));
3735
continue;
3836
} else {
3937
const l = processLine(line);

0 commit comments

Comments
 (0)