Tidy: Complete TrustedProxies feature (#2887)

This commit is contained in:
Notealot
2021-10-06 09:37:25 +08:00
committed by GitHub
parent 1a2bc0e7cb
commit 39181329de
6 changed files with 80 additions and 72 deletions

View File

@ -778,7 +778,7 @@ func (c *Context) ClientIP() string {
// RemoteIP parses the IP from Request.RemoteAddr, normalizes and returns the IP (without the port).
// 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 in Engine.TrustedProxies
// defined by Engine.SetTrustedProxies()
func (c *Context) RemoteIP() (net.IP, bool) {
ip, _, err := net.SplitHostPort(strings.TrimSpace(c.Request.RemoteAddr))
if err != nil {