Skip to main content

get_client_ip

Function get_client_ip 

Source
pub fn get_client_ip(headers: &HeaderMap, extensions: &Extensions) -> String
Expand description

Extracts the client IP address from HTTP headers and extensions, formatted as a string for logging.

A thin wrapper over micromegas_auth::client_ip::resolve_client_ip, which owns the actual resolution logic (X-Forwarded-For / X-Real-IP / socket address priority, with the to_canonical() normalization) – moved into the auth crate so IpAllowlist::allows can consult the same resolution for an authorization decision, not just for this function’s audit-logging callers. See that function’s doc comment for the full priority order and anti-spoofing rationale.

Returns “unknown” if no IP can be extracted.