feat(server): enforce per-IP connection cap#54
Merged
Conversation
The zero-buffer rendezvous channel lets the accept loop hold one accepted connection beyond the worker pool, so peak per-IP occupancy is workers+1. Validate --max-conns-per-ip in 1..=(workers+1) and document workers+1 (not workers) as the neutralizing maximum, addressing the P2 review comment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--max-conns-per-ip, derived by default asmax(1, workers / 8)and validated through the neutralizing maximumworkers + 1Context
PR #51 added the production nftables layer for issue #29: per-source concurrent connection limits plus new-connection rate limiting. Its commit history deliberately left the in-app concurrent cap open so the binary would also be safe by default on OpenBSD or deployments without a host firewall.
This PR completes that remaining application-layer work. The application only accounts for concurrent resources; connection-rate limiting remains owned by the firewall. Reverse-proxy deployments can neutralize the in-app cap with
workers + 1, which includes the extra accepted stream that can be parked on the zero-capacity rendezvous channel.Validation
make check-D warningsHuman merge requested because this changes the worker-exhaustion threat model.
Closes #29