mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 09:10:35 +08:00
Update CDN Hosts
This commit is contained in:
parent
015bdba23d
commit
cc4fd08893
@ -21,6 +21,7 @@ const querySpeedtestApi = async (keyword: string): Promise<Array<string | null>>
|
|||||||
s.acquire()
|
s.acquire()
|
||||||
]))[0];
|
]))[0];
|
||||||
|
|
||||||
|
let timer = null;
|
||||||
try {
|
try {
|
||||||
const randomUserAgent = topUserAgents[Math.floor(Math.random() * topUserAgents.length)];
|
const randomUserAgent = topUserAgents[Math.floor(Math.random() * topUserAgents.length)];
|
||||||
const key = `fetch speedtest endpoints: ${keyword}`;
|
const key = `fetch speedtest endpoints: ${keyword}`;
|
||||||
@ -29,7 +30,7 @@ const querySpeedtestApi = async (keyword: string): Promise<Array<string | null>>
|
|||||||
|
|
||||||
// AbortSignal.timeout() is not supported by bun.
|
// AbortSignal.timeout() is not supported by bun.
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
const timer = setTimeout(() => controller.abort(), 4000);
|
timer = setTimeout(() => controller.abort(), 4000);
|
||||||
|
|
||||||
const res = await fetchWithRetry(`https://www.speedtest.net/api/js/servers?engine=js&search=${keyword}&limit=100`, {
|
const res = await fetchWithRetry(`https://www.speedtest.net/api/js/servers?engine=js&search=${keyword}&limit=100`, {
|
||||||
headers: {
|
headers: {
|
||||||
@ -50,24 +51,23 @@ const querySpeedtestApi = async (keyword: string): Promise<Array<string | null>>
|
|||||||
},
|
},
|
||||||
signal: controller.signal
|
signal: controller.signal
|
||||||
});
|
});
|
||||||
|
|
||||||
clearTimeout(timer);
|
|
||||||
|
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
throw new Error(`${res.statusText}\n${await res.text()}`);
|
throw new Error(`${res.statusText}\n${await res.text()}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const json = await res.json<Array<{ url: string }>>();
|
const json = await res.json<Array<{ url: string }>>();
|
||||||
|
|
||||||
s.release();
|
|
||||||
|
|
||||||
console.timeEnd(key);
|
console.timeEnd(key);
|
||||||
|
|
||||||
return json.map(({ url }) => tldts.getHostname(url, { detectIp: false }));
|
return json.map(({ url }) => tldts.getHostname(url, { detectIp: false }));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
s.release();
|
|
||||||
console.log(e);
|
console.log(e);
|
||||||
return [];
|
return [];
|
||||||
|
} finally {
|
||||||
|
if (timer) {
|
||||||
|
clearTimeout(timer);
|
||||||
|
}
|
||||||
|
s.release();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -2296,3 +2296,4 @@ static-effect.reg.ru
|
|||||||
.espncdn.com
|
.espncdn.com
|
||||||
cdn.matterhorn.app
|
cdn.matterhorn.app
|
||||||
lumiere-a.akamaihd.net
|
lumiere-a.akamaihd.net
|
||||||
|
static.namebeta.com
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user