mirror of
https://github.com/pocketbase/pocketbase.git
synced 2025-03-17 21:27:52 +02:00
[#282] reversed the X-Forwarded-For ips iteration
This commit is contained in:
parent
d4f160d959
commit
3f4f4cf031
@ -317,9 +317,10 @@ func realUserIp(r *http.Request, fallbackIp string) string {
|
||||
if ipsList := r.Header.Get("X-Forwarded-For"); ipsList != "" {
|
||||
ips := strings.Split(ipsList, ",")
|
||||
// extract the rightmost ip
|
||||
for _, ip := range ips {
|
||||
if trimmedIp := strings.TrimSpace(ip); trimmedIp != "" {
|
||||
return trimmedIp
|
||||
for i := len(ips) - 1; i >= 0; i-- {
|
||||
ip := strings.TrimSpace(ips[i])
|
||||
if ip != "" {
|
||||
return ip
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user