Skip to main content

IpGateConfig

Struct IpGateConfig 

Source
pub struct IpGateConfig { /* private fields */ }
Expand description

The global IP gate: the parsed whitelist, blacklist, and exempt_ips lists.

Build it once at startup with IpGateConfig::new (which fails closed on an invalid entry) and evaluate request IPs with IpGateConfig::evaluate. The default value is three empty lists: the gate is inert, denying nobody and exempting nobody.

Implementations§

Source§

impl IpGateConfig

Source

pub fn new<W, B, E>( whitelist: W, blacklist: B, exempt_ips: E, ) -> Result<Self, IpGateError>

Parse and validate the three lists, failing closed on the first invalid entry.

Entry semantics match the reference whitelist matcher: a bare IP or a addr/prefix CIDR range, IPv4-mapped forms included, host bits cleared. The empty iterator is valid for any list.

§Errors

Returns an IpGateError naming the list and the first entry that is neither a valid IP nor a valid CIDR range.

Source

pub fn evaluate(&self, ip: IpAddr) -> IpGateVerdict

Evaluate a request IP against the gate.

The ordering is the reference contract’s: with a non-empty whitelist the whitelist gate decides (an unlisted, non-exempt IP is denied; an exempt IP does not pass the gate), otherwise the blacklist decides. The exemption flag is only set on an allowed verdict: it never adds a deny path and never removes one.

Source§

impl IpGateConfig

Source

pub fn evaluate_unknown(&self) -> IpGateVerdict

Evaluate the unknown client identity (no resolvable client address; the reference UNKNOWN_CLIENT_IDENTITY, its _check_unknown_identity_access): with a non-empty whitelist the identity can never match it, so it is denied; otherwise it passes with no skip state (it is neither whitelisted nor exempt, and the blacklist is not consulted). Callers skip this exactly where they skip IpGateConfig::evaluate (a route whitelist overriding the global lists).

Trait Implementations§

Source§

impl Clone for IpGateConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for IpGateConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for IpGateConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for IpGateConfig

Source§

impl PartialEq for IpGateConfig

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for IpGateConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.