From e48204a5e494640a597d38bf0c23cc7e230bceb5 Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Thu, 14 Dec 2023 11:47:13 -0500 Subject: cmd/xedn: add cdn-cgi/wtf/json Signed-off-by: Xe Iaso --- cmd/xedn/main.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'cmd/xedn/main.go') diff --git a/cmd/xedn/main.go b/cmd/xedn/main.go index 5e7e2cd..8eabddb 100644 --- a/cmd/xedn/main.go +++ b/cmd/xedn/main.go @@ -205,6 +205,21 @@ func main() { fmt.Fprintln(w) }) + cdn.HandleFunc("/cgi-cdn/wtf/json", func(w http.ResponseWriter, r *http.Request) { + enc := json.NewEncoder(w) + enc.SetIndent("", " ") + + enc.Encode(map[string]any{ + "headers": r.Header, + "your_ip": r.Header.Get("Fly-Client-Ip"), + "xedn": map[string]any{ + "region": os.Getenv("FLY_REGION"), + "instance": os.Getenv("FLY_ALLOC_ID"), + "binary": os.Args[0], + }, + }) + }) + hdlr := func(w http.ResponseWriter, r *http.Request) { etagLock.RLock() etag, ok := etags[r.URL.Path] -- cgit v1.2.3