Skip to main content

client_ip

Function client_ip 

Source
pub fn client_ip(
    headers: &HeaderMap,
    peer: Option<SocketAddr>,
    trust_proxy: bool,
) -> String
Expand description

Resolve the client’s IP address for logging and rate-limit keys.

When trust_proxy is true, inspects CF-Connecting-IP, Fly-Client-IP, and the rightmost valid IP address in X-Forwarded-For before falling back to peer. When trust_proxy is false, proxy headers are ignored and only peer is used. Returns "unknown" when no valid IP can be determined.