From: Dessalines Date: Wed, 1 Jul 2020 22:54:46 +0000 (-0400) Subject: Adding IP to the rate limit request line. (#882) X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/readmes/%7B%7D/%22%7Burl%7D/%7BcanonicalUrl%7D?a=commitdiff_plain;h=52fcda96e141094ceef5c9dbc92d46879328b41f;p=lemmy.git 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. --- 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(), )