mirror of
https://github.com/gin-gonic/gin.git
synced 2026-06-13 00:59:29 +08:00
Compare commits
2 Commits
c4f57c3741
...
aa55116299
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa55116299 | ||
|
|
41a4159766 |
11
gin.go
11
gin.go
@ -485,17 +485,20 @@ func (engine *Engine) validateHeader(header string) (clientIP string, valid bool
|
||||
for i := len(items) - 1; i >= 0; i-- {
|
||||
ipStr := strings.TrimSpace(items[i])
|
||||
ip := net.ParseIP(ipStr)
|
||||
valid = true
|
||||
|
||||
if ip == nil {
|
||||
break
|
||||
ipStr = ""
|
||||
valid = false
|
||||
}
|
||||
|
||||
// X-Forwarded-For is appended by proxy
|
||||
// Check IPs in reverse order and stop when find untrusted proxy
|
||||
if (i == 0) || (!engine.isTrustedProxy(ip)) {
|
||||
return ipStr, true
|
||||
if valid && (!engine.isTrustedProxy(ip)) {
|
||||
return ipStr, valid
|
||||
}
|
||||
}
|
||||
return "", false
|
||||
return "", valid
|
||||
}
|
||||
|
||||
// updateRouteTree do update to the route tree recursively
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user