Do not rate limit trusted IPs (#1078)
This commit is contained in:
@@ -93,19 +93,20 @@ impl RateLimiter for Server {
|
||||
|
||||
async fn is_http_anonymous_request_allowed(&self, addr: &IpAddr) -> trc::Result<()> {
|
||||
if let Some(rate) = &self.core.jmap.rate_anonymous {
|
||||
if self
|
||||
.core
|
||||
.storage
|
||||
.lookup
|
||||
.is_rate_allowed(
|
||||
KV_RATE_LIMIT_HTTP_ANONYMOUS,
|
||||
&ip_to_bytes(addr),
|
||||
rate,
|
||||
false,
|
||||
)
|
||||
.await
|
||||
.caused_by(trc::location!())?
|
||||
.is_some()
|
||||
if !self.is_ip_allowed(addr)
|
||||
&& self
|
||||
.core
|
||||
.storage
|
||||
.lookup
|
||||
.is_rate_allowed(
|
||||
KV_RATE_LIMIT_HTTP_ANONYMOUS,
|
||||
&ip_to_bytes(addr),
|
||||
rate,
|
||||
false,
|
||||
)
|
||||
.await
|
||||
.caused_by(trc::location!())?
|
||||
.is_some()
|
||||
{
|
||||
return Err(trc::LimitEvent::TooManyRequests.into_err());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user