diff --git a/main.go b/main.go index 735ac1d..a7305a7 100644 --- a/main.go +++ b/main.go @@ -40,11 +40,13 @@ Disallow: /harm/to/self func handleRequest(w http.ResponseWriter, r *http.Request, tmpl *template.Template) { sourceIP := func() string { + if r.Header.Get("CF-Connecting-IP") != "" { + return r.Header.Get("CF-Connecting-IP") + } if r.Header.Get("X-Forwarded-For") != "" { return r.Header.Get("X-Forwarded-For") - } else { - return strings.Split(r.RemoteAddr, ":")[0] } + return strings.Split(r.RemoteAddr, ":")[0] }() isHeadless := strings.HasPrefix(r.Header.Get("User-Agent"), "curl/")