mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-29 01:51:52 +08:00
Chore: refactor fetch text by line & load previous speedtest set
This commit is contained in:
@@ -10,6 +10,8 @@ import { fetchWithRetry } from './lib/fetch-retry';
|
||||
import { SHARED_DESCRIPTION } from './lib/constants';
|
||||
import { getGorhillPublicSuffixPromise } from './lib/get-gorhill-publicsuffix';
|
||||
import picocolors from 'picocolors';
|
||||
import { fetchRemoteTextByLine } from './lib/fetch-text-by-line';
|
||||
import { processLine } from './lib/process-line';
|
||||
|
||||
const s = new Sema(2);
|
||||
|
||||
@@ -65,6 +67,7 @@ const querySpeedtestApi = async (keyword: string): Promise<Array<string | null>>
|
||||
};
|
||||
|
||||
export const buildSpeedtestDomainSet = task(import.meta.path, async () => {
|
||||
// Predefined domainset
|
||||
/** @type {Set<string>} */
|
||||
const domains = new Set<string>([
|
||||
'.speedtest.net',
|
||||
@@ -130,6 +133,14 @@ export const buildSpeedtestDomainSet = task(import.meta.path, async () => {
|
||||
'.backend.librespeed.org'
|
||||
]);
|
||||
|
||||
// Download previous speedtest domainset
|
||||
for await (const l of await fetchRemoteTextByLine('https://ruleset.skk.moe/List/domainset/speedtest.conf')) {
|
||||
const line = processLine(l);
|
||||
if (line) {
|
||||
domains.add(line);
|
||||
}
|
||||
}
|
||||
|
||||
let timer;
|
||||
|
||||
const pMap = ([
|
||||
|
||||
Reference in New Issue
Block a user