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§fn clone(&self) -> ProxyPolicy
fn clone(&self) -> ProxyPolicy
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more