Struct ForwardedSelectionPolicy
pub struct ForwardedSelectionPolicy { /* private fields */ }net only.Expand description
Selects which element of a Forwarded chain describes the client.
A chain lists the client-most hop first and the hop nearest to this service last (RFC 7239 §4). Only what a trusted proxy wrote can be relied on (RFC 7239 §8.1), and a proxy appending to a header the client sent keeps the client’s own claim in front, so the default counts from the right, as nginx, Envoy, HAProxy, ASP.NET Core and Rails do.
Elements whose for address is a trusted proxy are skipped,
then hops more are, counting from the side.
Without a remaining element there is no client, and callers fall back to the connection.
It is an extension of its own, read by every consumer of Forwarded client information
(see ForwardedClientExt); layers that record forwarding information can install it.
Implementations§
§impl ForwardedSelectionPolicy
impl ForwardedSelectionPolicy
pub fn new() -> ForwardedSelectionPolicy
pub fn new() -> ForwardedSelectionPolicy
The rightmost element, without skipping any.
pub fn with_side(self, side: ForwardedSide) -> ForwardedSelectionPolicy
pub fn with_side(self, side: ForwardedSide) -> ForwardedSelectionPolicy
The end of the chain to count from.
pub fn set_side(&mut self, side: ForwardedSide) -> &mut ForwardedSelectionPolicy
pub fn set_side(&mut self, side: ForwardedSide) -> &mut ForwardedSelectionPolicy
The end of the chain to count from.
pub fn with_hops(self, hops: usize) -> ForwardedSelectionPolicy
pub fn with_hops(self, hops: usize) -> ForwardedSelectionPolicy
Elements to skip from the side, such as 1 behind two trusted
proxies that each append.
pub fn set_hops(&mut self, hops: usize) -> &mut ForwardedSelectionPolicy
pub fn set_hops(&mut self, hops: usize) -> &mut ForwardedSelectionPolicy
Elements to skip from the side, such as 1 behind two trusted
proxies that each append.
pub fn with_trusted_proxies(
self,
proxies: impl IntoIterator<Item = IpNet>,
) -> ForwardedSelectionPolicy
pub fn with_trusted_proxies( self, proxies: impl IntoIterator<Item = IpNet>, ) -> ForwardedSelectionPolicy
Skip the elements whose for address is one of these proxies.
pub fn set_trusted_proxies(
&mut self,
proxies: impl IntoIterator<Item = IpNet>,
) -> &mut ForwardedSelectionPolicy
pub fn set_trusted_proxies( &mut self, proxies: impl IntoIterator<Item = IpNet>, ) -> &mut ForwardedSelectionPolicy
Skip the elements whose for address is one of these proxies.
pub fn install(
self: &Arc<ForwardedSelectionPolicy>,
extensions: &Extensions,
keep_existing: bool,
)
pub fn install( self: &Arc<ForwardedSelectionPolicy>, extensions: &Extensions, keep_existing: bool, )
Install this shared policy in extensions, unless keep_existing and one is set
already.
pub fn select<'a>(
&self,
forwarded: &'a Forwarded,
) -> Option<&'a ForwardedElement>
pub fn select<'a>( &self, forwarded: &'a Forwarded, ) -> Option<&'a ForwardedElement>
The element of forwarded describing the client, if any remains.
Trait Implementations§
§impl Clone for ForwardedSelectionPolicy
impl Clone for ForwardedSelectionPolicy
§fn clone(&self) -> ForwardedSelectionPolicy
fn clone(&self) -> ForwardedSelectionPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for ForwardedSelectionPolicy
impl Debug for ForwardedSelectionPolicy
§impl Default for ForwardedSelectionPolicy
impl Default for ForwardedSelectionPolicy
§fn default() -> ForwardedSelectionPolicy
fn default() -> ForwardedSelectionPolicy
impl Eq for ForwardedSelectionPolicy
impl Extension for ForwardedSelectionPolicy
impl NetExtension for ForwardedSelectionPolicy
§impl PartialEq for ForwardedSelectionPolicy
impl PartialEq for ForwardedSelectionPolicy
impl StructuralPartialEq for ForwardedSelectionPolicy
Auto Trait Implementations§
impl Freeze for ForwardedSelectionPolicy
impl RefUnwindSafe for ForwardedSelectionPolicy
impl Send for ForwardedSelectionPolicy
impl Sync for ForwardedSelectionPolicy
impl Unpin for ForwardedSelectionPolicy
impl UnsafeUnpin for ForwardedSelectionPolicy
impl UnwindSafe for ForwardedSelectionPolicy
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§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> ⓘ
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> ⓘ
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more