pub struct ProxyPolicy { /* private fields */ }Expand description
How to derive a client address from the socket peer plus request headers.
Implementations§
Source§impl ProxyPolicy
impl ProxyPolicy
Sourcepub fn new(trusted_proxies: &[String], header: &str) -> Result<Self>
pub fn new(trusted_proxies: &[String], header: &str) -> Result<Self>
Validates the trusted-proxy CIDRs and the header name at startup.
Sourcepub fn resolve(
&self,
peer: Option<IpAddr>,
headers: &HeaderMap,
) -> Option<IpAddr>
pub fn resolve( &self, peer: Option<IpAddr>, headers: &HeaderMap, ) -> Option<IpAddr>
Resolves the effective client address.
Returns the canonicalized peer unless the peer is a trusted proxy, in which case the forwarded-for header is walked right to left, past any hop that is itself a trusted proxy, to the first address the chain did not add itself. That is the closest thing to the real client that the trusted portion of the chain vouches for; entries further left were written by whoever connected to the outermost proxy and cannot be believed.
Trait Implementations§
Source§impl Clone for ProxyPolicy
impl Clone for ProxyPolicy
Source§impl Debug for ProxyPolicy
impl Debug for ProxyPolicy
Auto Trait Implementations§
impl !Freeze for ProxyPolicy
impl RefUnwindSafe for ProxyPolicy
impl Send for ProxyPolicy
impl Sync for ProxyPolicy
impl Unpin for ProxyPolicy
impl UnsafeUnpin for ProxyPolicy
impl UnwindSafe for ProxyPolicy
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more