diff options
author | Dessalines <dessalines@users.noreply.github.com> | 2020-07-01 18:54:46 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-01 18:54:46 -0400 |
commit | 52fcda96e141094ceef5c9dbc92d46879328b41f (patch) | |
tree | e591b4d6a07342dbf38e26ed745f234c6ef76994 /server | |
parent | 360e7aec424ca07a0329e18549f8dce692495ed8 (diff) |
Adding IP to the rate limit request line. (#882)
* Adding IP to the rate limit request line.
* Adding IP to the rate limit request line.
Diffstat (limited to 'server')
-rw-r--r-- | server/src/rate_limit/rate_limiter.rs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/server/src/rate_limit/rate_limiter.rs b/server/src/rate_limit/rate_limiter.rs index 3e2ea787..20a617c2 100644 --- a/server/src/rate_limit/rate_limiter.rs +++ b/server/src/rate_limit/rate_limiter.rs @@ -10,7 +10,7 @@ pub struct RateLimitBucket { allowance: f64, } -#[derive(Eq, PartialEq, Hash, Debug, EnumIter, Copy, Clone)] +#[derive(Eq, PartialEq, Hash, Debug, EnumIter, Copy, Clone, AsRefStr)] pub enum RateLimitType { Message, Register, @@ -80,12 +80,21 @@ impl RateLimiter { if rate_limit.allowance < 1.0 { debug!( - "Rate limited IP: {}, time_passed: {}, allowance: {}", - ip, time_passed, rate_limit.allowance + "Rate limited type: {}, IP: {}, time_passed: {}, allowance: {}", + type_.as_ref(), + ip, + time_passed, + rate_limit.allowance ); Err( APIError { - message: format!("Too many requests. {} per {} seconds", rate, per), + message: format!( + "Too many requests. type: {}, IP: {}, {} per {} seconds", + type_.as_ref(), + ip, + rate, + per + ), } .into(), ) |