Adds an ip address to TrustProxyConfig.ranges or TrustProxyConfig.ips based on whether it is an IP range or not
(ipAddress string)
| 822 | |
| 823 | // Adds an ip address to TrustProxyConfig.ranges or TrustProxyConfig.ips based on whether it is an IP range or not |
| 824 | func (app *App) handleTrustedProxy(ipAddress string) { |
| 825 | if strings.IndexByte(ipAddress, '/') >= 0 { |
| 826 | _, ipNet, err := net.ParseCIDR(ipAddress) |
| 827 | if err != nil { |
| 828 | log.Warnf("IP range %q could not be parsed: %v", ipAddress, err) |
| 829 | } else { |
| 830 | app.config.TrustProxyConfig.ranges = append(app.config.TrustProxyConfig.ranges, ipNet) |
| 831 | } |
| 832 | } else { |
| 833 | ip := net.ParseIP(ipAddress) |
| 834 | if ip == nil { |
| 835 | log.Warnf("IP address %q could not be parsed", ipAddress) |
| 836 | } else { |
| 837 | app.config.TrustProxyConfig.ips[ipAddress] = struct{}{} |
| 838 | } |
| 839 | } |
| 840 | } |
| 841 | |
| 842 | // setCtxFunc applies the given context factory to the app. |
| 843 | // It is used internally by NewWithCustomCtx. It doesn't allow adding new methods, |