Skip to content

Commit 3c2edd2

Browse files
committed
Do not rate limit trusted IPs (#1078)
1 parent 013c580 commit 3c2edd2

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

crates/jmap/src/auth/rate_limit.rs

+14-13
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,20 @@ impl RateLimiter for Server {
9393

9494
async fn is_http_anonymous_request_allowed(&self, addr: &IpAddr) -> trc::Result<()> {
9595
if let Some(rate) = &self.core.jmap.rate_anonymous {
96-
if self
97-
.core
98-
.storage
99-
.lookup
100-
.is_rate_allowed(
101-
KV_RATE_LIMIT_HTTP_ANONYMOUS,
102-
&ip_to_bytes(addr),
103-
rate,
104-
false,
105-
)
106-
.await
107-
.caused_by(trc::location!())?
108-
.is_some()
96+
if !self.is_ip_allowed(addr)
97+
&& self
98+
.core
99+
.storage
100+
.lookup
101+
.is_rate_allowed(
102+
KV_RATE_LIMIT_HTTP_ANONYMOUS,
103+
&ip_to_bytes(addr),
104+
rate,
105+
false,
106+
)
107+
.await
108+
.caused_by(trc::location!())?
109+
.is_some()
109110
{
110111
return Err(trc::LimitEvent::TooManyRequests.into_err());
111112
}

0 commit comments

Comments
 (0)