diff --git a/main.go b/main.go index e791a33..5d5a7cd 100644 --- a/main.go +++ b/main.go @@ -247,6 +247,8 @@ func handleDashboardJSON(w http.ResponseWriter, r *http.Request) { func getClientIP(r *http.Request) string { xff := r.Header.Get("X-Forwarded-For") + xrip := r.Header.Get("X-Real-Ip") + log.Printf("X-Forwarded-For: %s, X-Real-Ip: %s, RemoteAddr: %s", xff, xrip, r.RemoteAddr) if xff != "" { parts := strings.Split(xff, ",") ip := strings.TrimSpace(parts[0]) @@ -254,7 +256,7 @@ func getClientIP(r *http.Request) string { return ip } } - xrip := r.Header.Get("X-Real-Ip") + if xrip != "" && isValidIP(xrip) { return xrip }