From fc3aee84b56344ea9880f08498ce7165db78a91f Mon Sep 17 00:00:00 2001 From: Stefan Bildl Date: Sat, 25 Mar 2023 15:02:48 +0100 Subject: [PATCH] refactor: rename method to reflect use-case --- context.go | 2 +- gin.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/context.go b/context.go index 5716318e..725947ba 100644 --- a/context.go +++ b/context.go @@ -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 } diff --git a/gin.go b/gin.go index f95e5dda..3cb9aced 100644 --- a/gin.go +++ b/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 }