pub enum Trusted {
None,
All,
These(Vec<Cidr>),
}Expand description
Which proxies to believe.
Variants§
None
Believe nobody. X-Forwarded-For is ignored entirely.
All
Believe whoever connected.
Correct only when nothing but your proxy can reach the process. If the port is open to the internet, this lets any client name its own address — which defeats rate limiting and falsifies every access log you have.
These(Vec<Cidr>)
Believe these addresses and networks.
Implementations§
Source§impl Trusted
impl Trusted
Sourcepub fn accepts(&self, peer: IpAddr) -> bool
pub fn accepts(&self, peer: IpAddr) -> bool
Whether a connection from peer may set the forwarded header at all.
Sourcepub fn is_known_hop(&self, address: IpAddr) -> bool
pub fn is_known_hop(&self, address: IpAddr) -> bool
Whether address is one of our proxies, and so should be skipped
when looking for the client in the chain.
Distinct from accepts, and the difference matters:
Trusted::All says “believe whoever connected” but names no
addresses, so it cannot recognise a hop. Treating every entry as a
known proxy would skip the whole chain and find no client at all.