Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractHostIP ¶
ExtractHostIP parses the IP from a host:port string and returns it unmapped.
Types ¶
type List ¶
type List struct {
// contains filtered or unexported fields
}
List holds a parsed set of trusted upstream proxy prefixes and answers trust questions against it. The zero value (and a nil *List) is a valid, empty list that never trusts any address, so callers can use it without a nil check.
func FromPrefixes ¶
FromPrefixes wraps an already-parsed set of prefixes in a List.
func Parse ¶
Parse parses a comma-separated list of CIDR prefixes or bare IPs into a List. Bare IPs are converted to single-host prefixes (/32 or /128). An empty input yields an empty List that trusts nothing.
func (*List) IsTrusted ¶
IsTrusted reports whether the given host:port or bare IP falls within the list.
func (*List) ResolveClientIP ¶
ResolveClientIP extracts the real client IP from X-Forwarded-For using the list. It walks the XFF chain right-to-left, skipping IPs that match trusted prefixes; the first untrusted IP is the real client. If the list is empty or remoteAddr is not trusted, it returns the remoteAddr IP directly, ignoring any forwarding headers.