Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DirectAddress ¶
DirectAddress returns the client socket IP, stripped of port. This strategy should be used if the server accepts direct connections, rather than through a proxy.
func Leftmost ¶
Leftmost derives the client IP from the leftmost valid and non-private IP address in the X-Fowarded-For or Forwarded header. This strategy should be used when a valid, non-private IP closest to the client is desired. Note: This MUST NOT be used for security purposes. This IP can be trivially SPOOFED.
The returned IP may contain a zone identifier. If no valid IP can be derived, empty string will be returned.
func Rightmost ¶
Rightmost derives the client IP from the rightmost valid and non-private IP address in the X-Fowarded-For or Forwarded header. This strategy should be used when all reverse proxies between the internet and the server have private-space IP addresses.
The returned IP may contain a zone identifier. If no valid IP can be derived, empty string will be returned.
func SingleIPHeader ¶
SingleIPHeader derives an IP address from a single-IP header. A non-exhaustive list of such single-IP headers is: X-Real-IP, CF-Connecting-IP, True-Client-IP, Fastly-Client-IP, X-Azure-ClientIP, X-Azure-SocketIP, Fly-Client-IP. This strategy should be used when the given header is added by a trusted reverse proxy. You MUST ensure that this header is not spoofable (as is possible with Akamai's use of True-Client-IP, Fastly's default use of Fastly-Client-IP, and Azure's X-Azure-ClientIP). See the single-IP wiki page for more info: https://github.com/realclientip/realclientip-go/wiki/Single-IP-Headers
The returned IP may contain a zone identifier. If no valid IP can be derived, empty string will be returned.
Types ¶
This section is empty.