Revert "rationalize return logic in validateHeader()"

This reverts commit 513b59fa8875d77c86f122af4bb0cc547eb98c8f.
This commit is contained in:
Notealot 2021-10-27 09:13:32 +08:00
parent 513b59fa88
commit 84ec44d9d7

7
gin.go
View File

@ -416,7 +416,9 @@ func (engine *Engine) isTrustedProxy(ip net.IP) bool {
}
func (engine *Engine) validateHeader(header string) (clientIP string, valid bool) {
if header != "" {
if header == "" {
return "", false
}
items := strings.Split(header, ",")
for i := len(items) - 1; i >= 0; i-- {
ipStr := strings.TrimSpace(items[i])
@ -431,8 +433,7 @@ func (engine *Engine) validateHeader(header string) (clientIP string, valid bool
return ipStr, true
}
}
}
return "", false
return
}
// parseTrustedProxies parse Engine.trustedProxies to Engine.trustedCIDRs