Merge df1c72fe4123e0ae14141e359b5eaf1edf9b2266 into 8763f33c65f7df8be5b9fe7504ab7fcf20abb41d

This commit is contained in:
Eric Lindvall 2025-03-23 09:00:43 +08:00 committed by GitHub
commit eae53c9098
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -912,9 +912,10 @@ func (c *Context) ClientIP() string {
// It also checks if the remoteIP is a trusted proxy or not.
// In order to perform this validation, it will see if the IP is contained within at least one of the CIDR blocks
// defined by Engine.SetTrustedProxies()
// If the IP could not be parsed (because, for instance, it is an ipv6 address with a scope), it will return the remote IP as-is.
remoteIP := net.ParseIP(c.RemoteIP())
if remoteIP == nil {
return ""
return c.RemoteIP()
}
trusted := c.engine.isTrustedProxy(remoteIP)