mirror of
https://github.com/pocketbase/pocketbase.git
synced 2025-02-03 18:02:17 +02:00
changed X-Forwarded-For parsing to use the first non-empty leftmost-ish ip as it is more close to the 'real ip'
This commit is contained in:
parent
9fa56b020c
commit
beca0a044e
@ -27,6 +27,8 @@
|
||||
|
||||
- New schema fields UI for "tidier" fields list.
|
||||
|
||||
- Updated the logs "real" user ip to check for `Fly-Client-IP` header and changed the `X-Forward-For` header to use the first non-empty leftmost-ish IP as it the closes to the "real IP".
|
||||
|
||||
|
||||
## v0.15.2
|
||||
|
||||
|
@ -377,10 +377,10 @@ func realUserIp(r *http.Request, fallbackIp string) string {
|
||||
}
|
||||
|
||||
if ipsList := r.Header.Get("X-Forwarded-For"); ipsList != "" {
|
||||
// extract the first non-empty leftmost-ish ip
|
||||
ips := strings.Split(ipsList, ",")
|
||||
// extract the rightmost ip
|
||||
for i := len(ips) - 1; i >= 0; i-- {
|
||||
ip := strings.TrimSpace(ips[i])
|
||||
for _, ip := range ips {
|
||||
ip = strings.TrimSpace(ip)
|
||||
if ip != "" {
|
||||
return ip
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user