1
0
mirror of https://github.com/tormachris/cf-workers-status-page.git synced 2024-11-23 22:45:43 +01:00

PoP location detection

This commit is contained in:
Hugo Romano 2020-11-17 15:35:49 +00:00
parent 8eadbb32ac
commit 01c058ed1b
No known key found for this signature in database
GPG Key ID: 94E55CAD885CE38C

View File

@ -64,10 +64,11 @@ export async function processCronTrigger(event) {
} }
// save last check timestamp including PoP location // save last check timestamp including PoP location
const res = await fetch("https://www.cloudflare.com/cdn-cgi/trace") const res = await fetch('https://cloudflare-dns.com/dns-query', {
const resText = await res.text() method: 'OPTIONS',
const loc = /loc=([\w]{2})/.exec(resText)[1] })
await setKV('lastUpdate', Date.now(), {loc}) const loc = res.headers.get('cf-ray').split('-')[1]
await setKV('lastUpdate', Date.now(), { loc })
// gc monitor statuses // gc monitor statuses
event.waitUntil(gcMonitors(config)) event.waitUntil(gcMonitors(config))