Repository navigation
Conversation
ConnectionHandler hardcoded a limit of 5 concurrent connections to any single destination address, with no way to change it. Add connection_max_per_address (default 5, preserving current behavior) so tools that legitimately need more concurrency to one host can raise it. Fixes mitmproxy#8322
This branch has not been deployed
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.
Fixes #8322
Summary
ConnectionHandler.__init__hardcodedasyncio.Semaphore(5)as the concurrency cap for connections to any single destination address, held for the connection's entire lifetime (open_connection()wrapshandle_connection()inside theasync with self.max_conns[address]:block). There was noOptionsfield or--setflag for this value anywhere — a 6th concurrent connection to the same address just queues indefinitely behind whichever of the 5 stays open longest.This adds
connection_max_per_address(default5, so behavior is unchanged unless a user opts in) and reads it inConnectionHandler.__init__instead of the hardcoded literal.Changes
mitmproxy/options.py: newconnection_max_per_addressoption, default5.mitmproxy/proxy/server.py:ConnectionHandler.__init__reads the option instead of the hardcoded5.test/mitmproxy/proxy/test_server.py: two new tests asserting the behavior (the Nth+1 connection actually blocks / doesn't block) via the publicSemaphoreAPI (acquire/locked), not by inspecting private state. One pins the existing default-5 behavior, the other confirms a customconnection_max_per_addressis honored.Testing
pytest test/mitmproxy/proxy/test_server.py test/mitmproxy/test_options.py— all pass.ruff check/ruff format --check/mypyon the changed files — all clean.