pub struct IpAddressConfig {
pub headers: Vec<String>,
pub trusted_proxies: Vec<String>,
pub ipv6_subnet: f64,
pub localhost_fallback: bool,
pub disable_ip_tracking: bool,
}Expand description
IP-address extraction configuration.
Fields§
§headers: Vec<String>Ordered list of headers to check for the client IP.
Defaults to ["x-forwarded-for"]. Header names are case insensitive.
trusted_proxies: Vec<String>IP addresses or CIDRs removed from the right of a forwarded chain. Invalid entries are ignored. Without valid entries, only a single address is admitted. Deployments must prevent clients bypassing the proxy and supplying their own trusted forwarding headers.
ipv6_subnet: f64IPv6 grouping prefix; defaults to 64. Fractional values are floored, negative values become zero, and values at least 128 or NaN preserve the full address. IPv4-mapped addresses use IPv4 grouping.
localhost_fallback: boolFall back to localhost when no configured header resolves an address.
Defaults to true for NODE_ENV dev/development/test or a truthy TEST
environment flag. Applications may configure this explicitly.
disable_ip_tracking: boolIf true, IP tracking is entirely disabled (no IP stored in sessions).
Implementations§
Source§impl IpAddressConfig
impl IpAddressConfig
Sourcepub fn resolve_ip(&self, headers: &HashMap<String, String>) -> Option<String>
pub fn resolve_ip(&self, headers: &HashMap<String, String>) -> Option<String>
Resolve a forwarded client address using the initialized IP policy.
Trusted proxy matching uses the full address before IPv6 grouping. A malformed hop fails that header closed; the next configured header may still resolve an address. Tracking opt-out also disables fallback.