Do not rate limit trusted IPs (#1078)

This commit is contained in:
mdecimus
2025-01-11 15:51:18 +01:00
parent 013c580201
commit 3c2edd2910

View File

@@ -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());
}