isTrustedProxy will check whether the IP address is included in the trusted list according to Engine.trustedCIDRs
(ip net.IP)
| 467 | |
| 468 | // isTrustedProxy will check whether the IP address is included in the trusted list according to Engine.trustedCIDRs |
| 469 | func (engine *Engine) isTrustedProxy(ip net.IP) bool { |
| 470 | if engine.trustedCIDRs == nil { |
| 471 | return false |
| 472 | } |
| 473 | for _, cidr := range engine.trustedCIDRs { |
| 474 | if cidr.Contains(ip) { |
| 475 | return true |
| 476 | } |
| 477 | } |
| 478 | return false |
| 479 | } |
| 480 | |
| 481 | // validateHeader will parse X-Forwarded-For header and return the trusted client IP address |
| 482 | func (engine *Engine) validateHeader(header string) (clientIP string, valid bool) { |
no outgoing calls