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.
This commit is contained in:
Dessalines 2020-07-01 18:54:46 -04:00 committed by GitHub
parent 360e7aec42
commit 52fcda96e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,7 +10,7 @@ pub struct RateLimitBucket {
allowance: f64, allowance: f64,
} }
#[derive(Eq, PartialEq, Hash, Debug, EnumIter, Copy, Clone)] #[derive(Eq, PartialEq, Hash, Debug, EnumIter, Copy, Clone, AsRefStr)]
pub enum RateLimitType { pub enum RateLimitType {
Message, Message,
Register, Register,
@ -80,12 +80,21 @@ impl RateLimiter {
if rate_limit.allowance < 1.0 { if rate_limit.allowance < 1.0 {
debug!( debug!(
"Rate limited IP: {}, time_passed: {}, allowance: {}", "Rate limited type: {}, IP: {}, time_passed: {}, allowance: {}",
ip, time_passed, rate_limit.allowance type_.as_ref(),
ip,
time_passed,
rate_limit.allowance
); );
Err( Err(
APIError { 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(), .into(),
) )