Documentation
¶
Overview ¶
Package clientip normalises client addresses for rate-limit keys and resolves the client address behind trusted proxies.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RateLimitKey ¶
RateLimitKey returns the per-IP rate-limit key for a source address: IPv4 unchanged, IPv6 masked to its /64, anything unparsable the shared "invalid" key. /56 and /48 rotation by one client still works; only /64 is collapsed.
func Resolve ¶
Resolve returns the client address for a request that crossed trustedHops appending proxies. With n X-Forwarded-For entries it uses entry n-hops; with hops <= 0, fewer entries than hops, or an unparsable or empty entry it falls back to the peer address, so unparsable text is never used as a key. IPv6 stays full-width; use RateLimitKey for the /64 key.
Types ¶
This section is empty.