pub struct ReputationTracker { /* private fields */ }Expand description
Tracks per-IP reputation and computes a PoW-difficulty escalation for
abusive sources (DOS-2). A clean / new IP contributes 0 (so well-behaved
clients are never penalized); an IP that accrues handshake violations within
the sliding window pays an escalating difficulty, capped at
MAX_DIFFICULTY. The map is bounded (see Self::with_capacity).
Implementations§
Source§impl ReputationTracker
impl ReputationTracker
pub fn new() -> Self
Sourcepub fn with_capacity(max_entries: usize) -> Self
pub fn with_capacity(max_entries: usize) -> Self
Create a tracker bounded to at most max_entries tracked IPs (DOS-2).
Sourcepub fn record_violation(&self, ip: IpAddr)
pub fn record_violation(&self, ip: IpAddr)
Record a violation (e.g., failed handshake)
Sourcepub fn reset_violations(&self, ip: IpAddr)
pub fn reset_violations(&self, ip: IpAddr)
Reset violations (e.g., successful session established or valid TLS ticket)
Sourcepub fn calculate_difficulty(&self, ip: IpAddr, has_ticket: bool) -> u8
pub fn calculate_difficulty(&self, ip: IpAddr, has_ticket: bool) -> u8
Calculate dynamic PoW difficulty based on reputation
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ReputationTracker
impl Freeze for ReputationTracker
impl Send for ReputationTracker
impl Sync for ReputationTracker
impl Unpin for ReputationTracker
impl UnsafeUnpin for ReputationTracker
impl UnwindSafe for ReputationTracker
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