1
0
mirror of https://github.com/tormachris/cf-workers-status-page.git synced 2024-09-21 05:03:02 +02:00

Merge pull request #9 from adaptive/patch-1

PoP location detection
This commit is contained in:
Adam Janiš 2020-11-17 18:05:57 +01:00 committed by GitHub
commit 126a48b5cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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))