pub fn effective_client_ip(
trusted: &[String],
peer: IpAddr,
xff: Option<&str>,
) -> IpAddrExpand description
Resolve the EFFECTIVE client IP (DW-009 trusted-proxy chain).
-
Peer NOT in
trusted_proxies: the peer itself (an inbound XFF is untrusted and ignored — spoofing gains nothing). -
Peer trusted: walk the inbound XFF chain right-to-left; the rightmost address that is NOT itself a trusted proxy is the client. If every entry is trusted (or the XFF is absent/unparseable), the leftmost parseable entry stands in; with nothing parseable the peer (the closest trusted hop) is used.
Documented weakness: when the WHOLE XFF chain is trusted, the leftmost entry is CLIENT-SUPPLIED and therefore spoofable by anything that can speak to a trusted proxy — a request from inside the trusted space can present an arbitrary leftmost address and be evaluated against it. There is no more-credible source to prefer in that shape; treat trusted space as hostile to the extent you rely on IP ACLs.