Skip to main content

IpBanConfig

Struct IpBanConfig 

Source
pub struct IpBanConfig {
    pub enable_ip_banning: bool,
    pub auto_ban_threshold: u32,
    pub auto_ban_duration: u64,
    pub threat_ban_config: HashMap<String, ThreatBanEntry>,
}
Expand description

The IP-banning knobs (the reference enable_ip_banning / auto_ban_threshold / auto_ban_duration / threat_ban_config group).

The defaults are the reference SecurityConfig defaults: banning on (enable_ip_banning = true, guard_core/_security_config_fields.py) with the reference threshold/duration pair.

Fields§

§enable_ip_banning: bool

enable_ip_banning. false makes every ban resolution a no-op; violations still count (the reference counts regardless so enabling banning later starts from observed history).

§auto_ban_threshold: u32

auto_ban_threshold: the flat fallback, measured against the total of all counted categories.

§auto_ban_duration: u64

auto_ban_duration: the flat fallback ban length (seconds).

§threat_ban_config: HashMap<String, ThreatBanEntry>

threat_ban_config: per-category threshold/duration overrides, consulted before the flat pair.

Implementations§

Source§

impl IpBanConfig

Source

pub fn new<I, K, V>( enable_ip_banning: bool, auto_ban_threshold: u32, auto_ban_duration: u64, threat_ban_config: I, ) -> Result<Self, IpBanConfigError>
where I: IntoIterator<Item = (K, V)>, K: AsRef<str>, V: Into<ThreatBanEntry>,

Build and validate a config, failing closed on a non-positive threshold/duration or an unknown threat_ban_config category.

§Errors

IpBanConfigError::NonPositive for a zero auto_ban_threshold or auto_ban_duration (the reference rejects both with ge=1), IpBanConfigError::UnknownCategory for a key outside valid_threat_categories.

Source

pub fn validate(&self) -> Result<(), IpBanConfigError>

Validate this config. Struct-literal builders can run the same checks the constructor applies.

§Errors

See IpBanConfig::new.

Trait Implementations§

Source§

impl Clone for IpBanConfig

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 IpBanConfig

Source§

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

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

impl Default for IpBanConfig

Source§

fn default() -> Self

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

impl Eq for IpBanConfig

Source§

impl PartialEq for IpBanConfig

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 IpBanConfig

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.