mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 09:10:35 +08:00
Perf: enable cache for nxdomain bogus source
This commit is contained in:
parent
85801b1b9e
commit
1f23212042
@ -6,8 +6,14 @@ import { processLine } from './lib/process-line';
|
|||||||
import { task } from './lib/trace-runner';
|
import { task } from './lib/trace-runner';
|
||||||
import { SHARED_DESCRIPTION } from './lib/constants';
|
import { SHARED_DESCRIPTION } from './lib/constants';
|
||||||
import { isProbablyIpv4, isProbablyIpv6 } from './lib/is-fast-ip';
|
import { isProbablyIpv4, isProbablyIpv6 } from './lib/is-fast-ip';
|
||||||
|
import { TTL, deserializeArray, fsCache, serializeArray } from './lib/cache-filesystem';
|
||||||
|
|
||||||
const getBogusNxDomainIPs = async () => {
|
const getBogusNxDomainIPs = async () => {
|
||||||
|
const url = 'https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/bogus-nxdomain.china.conf';
|
||||||
|
|
||||||
|
return fsCache.apply(
|
||||||
|
url,
|
||||||
|
async () => {
|
||||||
const result: string[] = [];
|
const result: string[] = [];
|
||||||
for await (const line of await fetchRemoteTextByLine('https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/bogus-nxdomain.china.conf')) {
|
for await (const line of await fetchRemoteTextByLine('https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/bogus-nxdomain.china.conf')) {
|
||||||
if (line && line.startsWith('bogus-nxdomain=')) {
|
if (line && line.startsWith('bogus-nxdomain=')) {
|
||||||
@ -20,6 +26,13 @@ const getBogusNxDomainIPs = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ttl: TTL.ONE_WEEK(),
|
||||||
|
serializer: serializeArray,
|
||||||
|
deserializer: deserializeArray
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const buildAntiBogusDomain = task(import.meta.path, async () => {
|
export const buildAntiBogusDomain = task(import.meta.path, async () => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user