diff --git a/server.go b/server.go index f360f61..5a302ce 100644 --- a/server.go +++ b/server.go @@ -7,6 +7,7 @@ import ( "net" "net/http" "os" + "strings" "time" "github.com/spf13/cobra" @@ -70,7 +71,9 @@ func StartServer() error { func GetIP(r *http.Request) string { ip := r.Header.Get("X-Real-Ip") if ip == "" { - ip = r.Header.Get("X-Forwarded-For") + ips := r.Header.Get("X-Forwarded-For") + ipArr := strings.Split(ips, ",") + ip = strings.Trim(ipArr[len(ipArr)-1], " ") } if ip == "" { var err error