Documentation
¶
Overview ¶
Package forwarded parses the X-Forwarded-For header along with a socket remote address to produce the chain of addresses that a request traversed.
It is a Go port of the npm module "forwarded". The returned slice always begins with the socket remote address, followed by the addresses parsed from the X-Forwarded-For header value in reverse order (that is, the proxy closest to the server first).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Forwarded ¶
Forwarded returns the list of addresses in the request chain.
The first element is remoteAddr (with any port stripped). The remaining elements are the comma-separated entries of the X-Forwarded-For value (xff), trimmed of surrounding whitespace and appended from the rightmost entry to the leftmost entry. Empty entries in the header are preserved as empty strings, matching the behavior of the npm "forwarded" module.
func FromRequest ¶
FromRequest returns the address chain for an *http.Request, reading r.RemoteAddr (with the port stripped) and the X-Forwarded-For header.
Types ¶
This section is empty.