mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-16 05:16:35 +08:00
refactor: rename method to reflect use-case
This commit is contained in:
parent
a889c58de7
commit
fc3aee84b5
@ -796,7 +796,7 @@ func (c *Context) ClientIP() string {
|
||||
|
||||
if trusted && c.engine.ForwardedByClientIP && c.engine.RemoteIPHeaders != nil {
|
||||
for _, headerName := range c.engine.RemoteIPHeaders {
|
||||
ip, valid := c.engine.validateHeader(c.requestHeader(headerName))
|
||||
ip, valid := c.engine.getTrustedClientIP(c.requestHeader(headerName))
|
||||
if valid {
|
||||
return ip
|
||||
}
|
||||
|
4
gin.go
4
gin.go
@ -454,8 +454,8 @@ func (engine *Engine) isTrustedProxy(ip net.IP) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// validateHeader will parse X-Forwarded-For header and return the trusted client IP address
|
||||
func (engine *Engine) validateHeader(header string) (clientIP string, valid bool) {
|
||||
// getTrustedClientIP will parse X-Forwarded-For header and return the trusted client IP address
|
||||
func (engine *Engine) getTrustedClientIP(header string) (clientIP string, valid bool) {
|
||||
if header == "" {
|
||||
return "", false
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user