feat: add max_clients limit per service#447
Open
daviddang91 wants to merge 3 commits intorathole-org:mainfrom
Open
feat: add max_clients limit per service#447daviddang91 wants to merge 3 commits intorathole-org:mainfrom
daviddang91 wants to merge 3 commits intorathole-org:mainfrom
Conversation
Implement connection limit feature allowing administrators to restrict the number of concurrent client connections per service. Features: - Add optional max_clients field to ServerServiceConfig - Shared ServiceConnectionTracker per service using Arc<Semaphore> - RAII-based ConnectionGuard for automatic slot management - Pre-authentication connection limit check - ServiceAtFullCapacity protocol response for rejected clients - Drop-based cleanup ensuring slots freed on disconnect - Configurable heartbeat_interval for disconnect detection Implementation details: - Connection tracking stored in Server.connection_trackers HashMap - Semaphore-based slot management (non-blocking try_acquire) - Automatic cleanup via ControlChannel Drop trait - Clean, minimal logging (connection/disconnection events only) Example configs: - server_simple.toml: single client limit (max_clients=1) - server.toml: multiple scenarios (1, 5, unlimited) - heartbeat_interval=10s for fast disconnect detection Backward compatible: existing configs work unchanged (unlimited by default)
Updated both English and Chinese README files to document the new max_clients configuration option for server services. - Added max_clients field in server.services configuration example - Explained that it limits concurrent connections per service - Default value: unlimited (backward compatible)
Consolidated example configurations to single pair of files: - Removed server_simple.toml and client_simple.toml - Simplified server.toml and client.toml to minimal config - Kept only essential single-service example with max_clients=1 This makes the examples easier to understand and maintain while still demonstrating the max_clients feature effectively.
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.
Implement connection limit feature allowing administrators to restrict the number of concurrent client connections per service.
Features:
Implementation details:
Example configs:
Backward compatible: existing configs work unchanged (unlimited by default)