I’m new to mitmproxy, and I’m having some difficulty figuring out how to add arguments to scripts. It looks like in some previous commits of the documentation and examples folder, there was an example for adding arguments to scripts , but the documentation hasn’t had anything to say about handling arguments for at least the last 8 months. I’ve got a few questions.
- Has something change significantly in the API so that arguments are no longer easily added to scripts?
- If this is just a case of the documentation lagging behind development, would someone be able to provide a minimal example of a modification of this script, but where example. com is instead an argument?
Assuming you are on master (and not 2.0.x), your script can register options: https://github.com/mitmproxy/mitmproxy/blob/master/examples/simple/custom_option.py. You can set options during startup using
--set, or you can edit them from within mitmproxy in the options editor. Documentation for 3.0 is in the works
Gotcha - I now realize that I was having two separate problems.
- I had the 3.0 mitmproxy binaries installed on my system, but I had 2.0.2 installed in a virtual environment which I’m using to develop something around mitmproxy. This is because I used pip to install mitmproxy in the virtual environment without directing it to the Git repository.
- There’s possibly a small mistake in the documentation. readme.md should include custom_option.py, and it should not include script_argument.py, which is not in the folder. I missed custom_option.py since it wasn’t in the table.
Thanks for your help!
Good point - would you mind sending a PR that fixes that?
Just made one. For some reason discourse won’t let me put the link here, but it’s pull request 2820. Also, not sure why my above posts just got flagged as spam.