pub struct ViolationCounters { /* private fields */ }Expand description
Per-IP per-category violation counts: the reference’s
suspicious_request_counts, the store the auto-ban engine resolves
thresholds against.
The store is an LRU capped at MAX_TRACKED_SUSPICIOUS_IPS IPs (the
reference evicts the oldest IP at the same cap), so attacker IP
cardinality cannot grow it without bound.
Implementations§
Source§impl ViolationCounters
impl ViolationCounters
Sourcepub fn record(&self, ip: IpAddr, categories: &[&str])
pub fn record(&self, ip: IpAddr, categories: &[&str])
Record one violation per category for ip (each listed category
gains +1; the reference maps an empty category list to the
uncategorized pseudo-category, mirrored here).
Sourcepub fn snapshot(&self, ip: IpAddr) -> HashMap<String, u64>
pub fn snapshot(&self, ip: IpAddr) -> HashMap<String, u64>
A copy of ip’s counts (the resolution reads a snapshot while the
store stays locked for the next writer).
Sourcepub fn tracked_ips(&self) -> usize
pub fn tracked_ips(&self) -> usize
How many IPs the store currently tracks (test/observability seam).
Trait Implementations§
Source§impl Clone for ViolationCounters
impl Clone for ViolationCounters
Source§impl Debug for ViolationCounters
impl Debug for ViolationCounters
Auto Trait Implementations§
impl Freeze for ViolationCounters
impl RefUnwindSafe for ViolationCounters
impl Send for ViolationCounters
impl Sync for ViolationCounters
impl Unpin for ViolationCounters
impl UnsafeUnpin for ViolationCounters
impl UnwindSafe for ViolationCounters
Blanket Implementations§
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