Documentation
¶
Overview ¶
Package proxyaddr is a middleware for determining client address for proxied requests.
Index ¶
Constants ¶
const ( // CIDRLoopback represents IPv4 and IPv6 loopback addresses CIDRLoopback = "loopback" // CIDRLinkLocal represents IPv4 and IPv6 link-local addresses CIDRLinkLocal = "linklocal" // CIDRUniqueLocal represents IPv4 private addresses and IPv6 unique local addresses CIDRUniqueLocal = "uniquelocal" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ProxyAddr ¶
type ProxyAddr struct {
// contains filtered or unexported fields
}
ProxyAddr stores the group of CIDR of trusted proxies. With these and HTTP "x-forwarded-for" header, ProxyAddr determines actual IP address of the connecting client.
func (*ProxyAddr) Handler ¶
Handler is the plain http.Handler which updates RemoteAddr with actual IP from x-forwarded-for header.
func (*ProxyAddr) Init ¶
Init initializes the list of trusted proxies with provided string values. Without initializing, ProxyAddr trusts no IP address at all, and does not change RemoteAddr field.
Parameters of Init can only be exported constants of this package or CIDR-formatted strings (like 10.0.0.0/8).
func (*ProxyAddr) ServeHTTP ¶
func (pa *ProxyAddr) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
ServeHTTP is the implementation of Negroni middleware interface.