This commit is contained in:
4
main.go
4
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
|
||||
}
|
||||
|
Reference in New Issue
Block a user