pub struct TrustedProxyList { /* private fields */ }Expand description
A list of trusted upstream proxies, expressed as a set of user CIDRs plus an optional Cloudflare IP cache.
Implementations§
Source§impl TrustedProxyList
impl TrustedProxyList
Sourcepub fn new(
user_cidrs: Vec<IpNet>,
cf_cache: Option<Arc<CloudflareIpCache>>,
) -> Self
pub fn new( user_cidrs: Vec<IpNet>, cf_cache: Option<Arc<CloudflareIpCache>>, ) -> Self
Build a trusted-proxy list from user CIDRs and an optional Cloudflare IP cache.
Sourcepub fn localhost_only() -> Self
pub fn localhost_only() -> Self
Shortcut: localhost-only, no CF. Safe default for origins that are NOT behind any upstream proxy.
§Panics
This function contains .expect() calls on CIDR parsing, but in
practice it never panics: the CIDR strings (127.0.0.0/8 and
::1/128) are hardcoded constants that are guaranteed to be valid
IpNet values. The expects exist only to satisfy the FromStr
signature.
Sourcepub fn is_trusted(&self, peer: IpAddr) -> bool
pub fn is_trusted(&self, peer: IpAddr) -> bool
True if peer is in user_cidrs OR in the CF cache (when present).
Sourcepub fn user_cidrs(&self) -> &[IpNet]
pub fn user_cidrs(&self) -> &[IpNet]
Returns the configured user CIDRs (for diagnostics / inspection).
Sourcepub fn has_cloudflare_trust(&self) -> bool
pub fn has_cloudflare_trust(&self) -> bool
True if a CF cache is attached.
Trait Implementations§
Source§impl Clone for TrustedProxyList
impl Clone for TrustedProxyList
Source§fn clone(&self) -> TrustedProxyList
fn clone(&self) -> TrustedProxyList
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TrustedProxyList
impl RefUnwindSafe for TrustedProxyList
impl Send for TrustedProxyList
impl Sync for TrustedProxyList
impl Unpin for TrustedProxyList
impl UnsafeUnpin for TrustedProxyList
impl UnwindSafe for TrustedProxyList
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