fix(go): check for cloudflare proxy
This commit is contained in:
parent
62df1e1401
commit
c67ad664ff
1 changed files with 4 additions and 2 deletions
6
main.go
6
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/")
|
||||
|
|
Loading…
Reference in a new issue