Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // CFConnectingIP is an HeaderParser. // https://support.cloudflare.com/hc/en-us/articles/206776727-What-is-True-Client-IP- CFConnectingIP = HeaderParser{"CF-Connecting-IP", parseXForwardedForHeader} // TrueClientIP is an HeaderParser. TrueClientIP = HeaderParser{"True-Client-IP", parseXForwardedForHeader} // XForwardedFor is an HeaderParser. XForwardedFor = HeaderParser{"X-Forwarded-For", parseXForwardedForHeader} // Forwarded is an HeaderParser. Forwarded = HeaderParser{"Forwarded", parseForwardedHeader} // XRealIP is an HeaderParser. XRealIP = HeaderParser{"X-Real-IP", parseXRealIPHeader} // DefaultHeaderParser is a list of headers and corresponding parsers to look up the real client IP. // They will be check in order, the first non-empty one will be picked, // or else the remote address is selected. DefaultHeaderParser = []HeaderParser{ CFConnectingIP, TrueClientIP, XForwardedFor, Forwarded, XRealIP, } )
Functions ¶
Types ¶
type HeaderParser ¶
type HeaderParser struct { Header string Parser ParseHeaderFunc }
HeaderParser parses a header to extract the real client IP address.
type ParseHeaderFunc ¶
ParseHeaderFunc parses and validates an IP address from a header. It must return an empty string if the header or contained IP address is invalid.
Click to show internal directories.
Click to hide internal directories.