From 9a352f884f413cf11a8cf76b3615aee927dfa28d Mon Sep 17 00:00:00 2001 From: SukkaW Date: Sun, 7 Jul 2024 17:39:46 +0800 Subject: [PATCH] Fix Speedtest Hosts --- Build/build-speedtest-domainset.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Build/build-speedtest-domainset.ts b/Build/build-speedtest-domainset.ts index beb595d73..0faed415a 100644 --- a/Build/build-speedtest-domainset.ts +++ b/Build/build-speedtest-domainset.ts @@ -59,9 +59,10 @@ const querySpeedtestApi = async (keyword: string): Promise> retry: { retries: 2 } - })).then(r => r.json() as any).then((data: Array<{ url: string }>) => data.reduce( + })).then(r => r.json() as any).then((data: Array<{ url: string, host: string }>) => data.reduce( (prev, cur) => { - const hn = getHostname(cur.url, { detectIp: false, validateHostname: true }); + const line = cur.host || cur.url; + const hn = getHostname(line, { detectIp: false, validateHostname: true }); if (hn) { prev.push(hn); } @@ -146,6 +147,8 @@ export const buildSpeedtestDomainSet = task(import.meta.main, import.meta.path)( '.speedtest.com.sg', '.ookla.ddnsgeek.com', '.speedtest.pni.tw', + '.speedtest.cmcnetworks.net', + '.speedtestwnet.com.br', // Cloudflare '.speed.cloudflare.com', // Wi-Fi Man @@ -178,14 +181,14 @@ export const buildSpeedtestDomainSet = task(import.meta.main, import.meta.path)( 'fetch previous speedtest domainset', async () => { try { - const contents = await readFileIntoProcessedArray(path.resolve(import.meta.dir, '../List/domainset/speedtest.conf')); - contents.reduce((acc, line) => { + ( + await readFileIntoProcessedArray(path.resolve(import.meta.dir, '../List/domainset/speedtest.conf')) + ) .forEach(line => { const hn = getHostname(line, { detectIp: false, validateHostname: true }); if (hn) { - acc.push(hn); + domainTrie.add(hn); } - return acc; - }, []).forEach(domainTrie.add); + }); } catch { } } );