mirror of
https://github.com/SukkaW/Surge.git
synced 2026-07-29 15:41:45 +08:00
Chore: parallel checking dead domains
This commit is contained in:
30
Build/lib/get-runner-geoip.ts
Normal file
30
Build/lib/get-runner-geoip.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { $$fetch } from './fetch-retry';
|
||||
|
||||
export interface RunnerGeoIP {
|
||||
ip: string,
|
||||
country: string,
|
||||
region: string,
|
||||
city: string,
|
||||
asn: number,
|
||||
asOrg: string,
|
||||
longitude: number,
|
||||
latitude: number,
|
||||
timezone: string,
|
||||
cfEdgeIP: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the current machine's egress IP and geo info. Used to confirm that
|
||||
* each matrix shard landed on a different GitHub-hosted runner region / egress
|
||||
* IP — the premise that lets sharding spread DoH load and dodge rate limits.
|
||||
*
|
||||
* Returns `null` on any failure so it never aborts the actual domain check.
|
||||
*/
|
||||
export async function getRunnerGeoIP(): Promise<RunnerGeoIP | null> {
|
||||
try {
|
||||
const res = await $$fetch('https://ip.api.skk.moe/cf-geoip');
|
||||
return await res.json() as RunnerGeoIP;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user