Skip to content

Add portfile support#7724

Merged
mhils merged 1 commit intomitmproxy:mainfrom
xmo-odoo:portfile
May 23, 2025
Merged

Add portfile support#7724
mhils merged 1 commit intomitmproxy:mainfrom
xmo-odoo:portfile

Conversation

@xmo-odoo
Copy link
Contributor

Convenient when manipulating mitmproxy programmatically, as it's often useful to specify port 0 (for all sorts of servers) but then the user needs a way to retrieve the actual port being used.

mitmproxy logs the bound ports out by default, however because it logs to the fully buffered stdout and can generate quite a bit of log, this tends to be inconvenient. Writing out a file at a user-specified location makes it much easier for them to poll, and using json even if there is a minor race the user can just keep reading until they see a valid JSON file.

Closes #7720

Convenient when manipulating mitmproxy programmatically, as it's often
useful to specify port 0 (for all sorts of servers) but then the user
needs a way to retrieve the actual port being used.

mitmproxy logs the bound ports out by default, however because it logs
to the fully buffered stdout *and* can generate quite a bit of log,
this tends to be inconvenient. Writing out a file at a user-specified
location makes it much easier for them to poll, and using json even if
there is a minor race the user can just keep reading until they see a
valid JSON file.
Copy link
Member

@mhils mhils left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool, thank you! If we see more upvotes on #7720 over time, I'd be willing to consider moving this directly into mitmproxy/addons. But for now this is perfect. 😃

@mhils mhils merged commit 434daba into mitmproxy:main May 23, 2025
27 checks passed
@xmo-odoo xmo-odoo deleted the portfile branch May 26, 2025 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support creating a pidfile/portfile

2 participants