pub struct AdminRateLimiter { /* private fields */ }Expand description
Simple sliding-window rate limiter for admin API endpoints.
Without rate limiting, an attacker who compromises the admin API key can make unlimited requests, enabling rapid brute-force enumeration of agents/sessions and denial-of-service against the control plane.
This implements a global sliding window: it tracks timestamps of recent requests and rejects new ones when the window is full.
Implementations§
Source§impl AdminRateLimiter
impl AdminRateLimiter
Sourcepub fn new(max_requests: u64, window_duration: Duration) -> Self
pub fn new(max_requests: u64, window_duration: Duration) -> Self
Create a new rate limiter with the given capacity and window duration.
Sourcepub fn check_rate_limit(&self) -> bool
pub fn check_rate_limit(&self) -> bool
Check whether a request should be allowed.
Returns true if the request is within the rate limit, false if it
should be rejected. Automatically evicts expired entries from the window.
Auto Trait Implementations§
impl !Freeze for AdminRateLimiter
impl RefUnwindSafe for AdminRateLimiter
impl Send for AdminRateLimiter
impl Sync for AdminRateLimiter
impl Unpin for AdminRateLimiter
impl UnsafeUnpin for AdminRateLimiter
impl UnwindSafe for AdminRateLimiter
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