pub struct IpAllowlist(/* private fields */);Expand description
A set of CIDR ranges (or bare IPs) a credential may be used from.
Empty (the Default/parse(&[]) result) means “no restriction”: Self::allows always
returns true. Once non-empty, an unresolved client IP (None) never satisfies the
restriction – “unknown” must never be treated as “allowed”.
Implementations§
Source§impl IpAllowlist
impl IpAllowlist
Sourcepub fn parse(entries: &[String]) -> Result<IpAllowlist, Error>
pub fn parse(entries: &[String]) -> Result<IpAllowlist, Error>
Parses entries (CIDR notation, e.g. "10.0.0.0/8", or a bare IP, e.g.
"203.0.113.7") into an IpAllowlist. An empty slice parses to an empty (unrestricted)
allowlist. Fails on the first entry that is neither a valid CIDR nor a valid bare IP
address.
IpNet::from_str doesn’t accept a bare IP without a prefix, so this falls back to
parsing a bare IpAddr and widening it to a /32//128 via IpNet::from.
Also rejects a CIDR whose address has host bits set (e.g. 10.0.0.5/8): ipnet parses
it successfully but silently widens the range to the whole /8, which is the opposite of
what an operator narrowing an allowlist intends.
Sourcepub fn allows(&self, ip: Option<IpAddr>) -> bool
pub fn allows(&self, ip: Option<IpAddr>) -> bool
true when ip is permitted by this allowlist: always true when the allowlist is
empty (no restriction); otherwise true only when ip is Some and falls within at
least one stored network. An unresolved client IP (None) never satisfies a non-empty
allowlist.
Trait Implementations§
Source§impl Clone for IpAllowlist
impl Clone for IpAllowlist
Source§fn clone(&self) -> IpAllowlist
fn clone(&self) -> IpAllowlist
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for IpAllowlist
impl Debug for IpAllowlist
Source§impl Default for IpAllowlist
impl Default for IpAllowlist
Source§fn default() -> IpAllowlist
fn default() -> IpAllowlist
The empty, unrestricted allowlist.
impl Eq for IpAllowlist
Source§impl PartialEq for IpAllowlist
impl PartialEq for IpAllowlist
impl StructuralPartialEq for IpAllowlist
Auto Trait Implementations§
impl Freeze for IpAllowlist
impl RefUnwindSafe for IpAllowlist
impl Send for IpAllowlist
impl Sync for IpAllowlist
impl Unpin for IpAllowlist
impl UnsafeUnpin for IpAllowlist
impl UnwindSafe for IpAllowlist
Blanket Implementations§
impl<T> Allocation for T
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
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> ⓘ
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 tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].