Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do per IpAddr rate limiting first #4512

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions streamer/src/nonblocking/quic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,19 +367,7 @@ async fn run_server(

let remote_address = incoming.remote_address();

// first check overall connection rate limit:
if !overall_connection_rate_limiter.is_allowed() {
debug!(
"Reject connection from {:?} -- total rate limiting exceeded",
remote_address.ip()
);
stats
.connection_rate_limited_across_all
.fetch_add(1, Ordering::Relaxed);
incoming.ignore();
continue;
}

// first do per IpAddr rate limiting
if rate_limiter.len() > CONNECTION_RATE_LIMITER_CLEANUP_SIZE_THRESHOLD {
rate_limiter.retain_recent();
}
Expand All @@ -399,6 +387,19 @@ async fn run_server(
continue;
}

// then check overall connection rate limit:
if !overall_connection_rate_limiter.is_allowed() {
debug!(
"Reject connection from {:?} -- total rate limiting exceeded",
remote_address.ip()
);
stats
.connection_rate_limited_across_all
.fetch_add(1, Ordering::Relaxed);
incoming.ignore();
continue;
}

let Ok(client_connection_tracker) =
ClientConnectionTracker::new(stats.clone(), max_concurrent_connections)
else {
Expand Down
Loading