pub struct RateLimitManager { /* private fields */ }Expand description
Main rate limit manager
Implementations§
Source§impl RateLimitManager
impl RateLimitManager
Sourcepub fn new(config: &RateLimitConfig) -> Self
pub fn new(config: &RateLimitConfig) -> Self
Create a new rate limit manager
Sourcepub fn with_pow_config(config: &RateLimitConfig, pow_config: PowConfig) -> Self
pub fn with_pow_config(config: &RateLimitConfig, pow_config: PowConfig) -> Self
Create with custom PoW config
Sourcepub fn check(&self, addr: &IpAddr, category: &str) -> Result<(), RateLimitError>
pub fn check(&self, addr: &IpAddr, category: &str) -> Result<(), RateLimitError>
Check if a request should be rate limited
Sourcepub fn check_skip_ban(
&self,
addr: &IpAddr,
category: &str,
) -> Result<(), RateLimitError>
pub fn check_skip_ban( &self, addr: &IpAddr, category: &str, ) -> Result<(), RateLimitError>
Check rate limits for a request WITHOUT consulting the global ban list.
Behaves exactly like Self::check minus the ban gate. Used by routes
that must remain reachable from a banned IP (e.g. the password-recovery
flow) while still being subject to the normal per-category rate limit.
Trait Implementations§
Source§impl Default for RateLimitManager
impl Default for RateLimitManager
Source§impl RateLimitApi for RateLimitManager
impl RateLimitApi for RateLimitManager
Source§fn get_status(
&self,
addr: &IpAddr,
category: &str,
) -> ClResult<Vec<(AddressKey, RateLimitStatus)>>
fn get_status( &self, addr: &IpAddr, category: &str, ) -> ClResult<Vec<(AddressKey, RateLimitStatus)>>
Query current limit status for an address at all hierarchical levels
Source§fn penalize(
&self,
addr: &IpAddr,
reason: PenaltyReason,
amount: u32,
) -> ClResult<()>
fn penalize( &self, addr: &IpAddr, reason: PenaltyReason, amount: u32, ) -> ClResult<()>
Manually consume quota (increase usage) - e.g., after auth failure
Source§fn grant(&self, addr: &IpAddr, amount: u32) -> ClResult<()>
fn grant(&self, addr: &IpAddr, amount: u32) -> ClResult<()>
Decrease penalty count (grant extra quota) - e.g., after successful CAPTCHA
Source§fn ban(
&self,
addr: &IpAddr,
duration: Duration,
reason: PenaltyReason,
) -> ClResult<()>
fn ban( &self, addr: &IpAddr, duration: Duration, reason: PenaltyReason, ) -> ClResult<()>
Temporarily ban an address (all hierarchical levels)
Source§fn stats(&self) -> RateLimiterStats
fn stats(&self) -> RateLimiterStats
Get statistics about rate limiter state
Source§fn get_pow_requirement(&self, addr: &IpAddr) -> u32
fn get_pow_requirement(&self, addr: &IpAddr) -> u32
Get current PoW requirement for address (max of individual + network level)
Source§fn increment_pow_counter(
&self,
addr: &IpAddr,
reason: PowPenaltyReason,
) -> ClResult<()>
fn increment_pow_counter( &self, addr: &IpAddr, reason: PowPenaltyReason, ) -> ClResult<()>
Increment PoW counter for address
Auto Trait Implementations§
impl !Freeze for RateLimitManager
impl !RefUnwindSafe for RateLimitManager
impl !UnwindSafe for RateLimitManager
impl Send for RateLimitManager
impl Sync for RateLimitManager
impl Unpin for RateLimitManager
impl UnsafeUnpin for RateLimitManager
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().