mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 01:00:34 +08:00
Perf: speed up build
This commit is contained in:
parent
684d35e1c7
commit
82e7f579bc
@ -8,13 +8,18 @@ const { task } = require('./lib/trace-runner');
|
|||||||
|
|
||||||
const getBogusNxDomainIPs = async () => {
|
const getBogusNxDomainIPs = async () => {
|
||||||
/** @type {string[]} */
|
/** @type {string[]} */
|
||||||
const res = [];
|
const result = [];
|
||||||
for await (const line of await fetchRemoteTextAndCreateReadlineInterface('https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/bogus-nxdomain.china.conf')) {
|
for await (const line of await fetchRemoteTextAndCreateReadlineInterface('https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/bogus-nxdomain.china.conf')) {
|
||||||
if (line.startsWith('bogus-nxdomain=')) {
|
if (line.startsWith('bogus-nxdomain=')) {
|
||||||
res.push(line.replace('bogus-nxdomain=', ''));
|
const ip = line.slice(15).trim();
|
||||||
|
if (isIPv4(ip)) {
|
||||||
|
result.push(`IP-CIDR,${ip}/32,no-resolve`);
|
||||||
|
} else if (isIPv6(ip)) {
|
||||||
|
result.push(`IP-CIDR6,${ip}/128,no-resolve`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const buildAntiBogusDomain = task(__filename, async () => {
|
const buildAntiBogusDomain = task(__filename, async () => {
|
||||||
@ -26,14 +31,7 @@ const buildAntiBogusDomain = task(__filename, async () => {
|
|||||||
const result = [];
|
const result = [];
|
||||||
for await (const line of readFileByLine(filePath)) {
|
for await (const line of readFileByLine(filePath)) {
|
||||||
if (line === '# --- [Anti Bogus Domain Replace Me] ---') {
|
if (line === '# --- [Anti Bogus Domain Replace Me] ---') {
|
||||||
(await bogusIpPromise).forEach(ip => {
|
(await bogusIpPromise).forEach(rule => result.push(rule));
|
||||||
if (isIPv4(ip)) {
|
|
||||||
result.push(`IP-CIDR,${ip}/32,no-resolve`);
|
|
||||||
} else if (isIPv6(ip)) {
|
|
||||||
result.push(`IP-CIDR6,${ip}/128,no-resolve`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
const l = processLine(line);
|
const l = processLine(line);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user