* fix server peername is None issue
peername would be None, we should use other not None property as key.
* Update tls_passthrough.py
---------
Co-authored-by: Maximilian Hils <github@maximilianhils.com>
* Add options for mitmweb and random port
* Clean up proxy settings on ^C
* [autofix.ci] apply automated fixes
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* Adapt mitmproxywrapper.py to Python 3 strings
This fixes errors like this one:
`TypeError: memoryview: a bytes-like object is required, not 'str'`
* [autofix.ci] apply automated fixes
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* add websocket messages in HAR file
* use websocket_end instead of websocket_message
* remove requestID_to_entry
* remove request
* add base64-encoded data if it is binary
* har dumper: nits
Co-authored-by: Maximilian Hils <git@maximilianhils.com>
Firefox Developer Tools reject to load HAR files that do not have
`har.log.pages` element (see
<https://bugzilla.mozilla.org/show_bug.cgi?id=1691240>). Adding a
placeholder entry fixes it.
Co-authored-by: Maciej Zielenkiewicz <maciej.zielenkiewicz@connectpoint.pl>
mitmproxy previously used a homegrown logging mechanism based around
`mitmproxy.ctx.log` and the `add_log` hook. This worked well for everything
we control, but does not work outside the mitmproxy universe.
For now we have simply ignored logging in e.g. tornado or h2, but with the
upcoming introduction of mitmproxy_wireguard we now have a dependency
on some Rust/PyO3 code for which we definitely want logs, but which also
cannot easily be changed to use our homegrown logging (PyO3 does the heavy
lifting to add interoperability with stdlib logging). Long story short,
we want to introduce a log handler for stdlib logging.
Now there are two ways how such a handler could operate:
1. We could build a handler that forwards all stdlib log events
into our homegrown mechanism.
2. We embrace stdlib's logging as the correct way to do things,
and get rid of our homegrown stuff.
This PR follows the second approach by removing the `add_log` hook and
rewriting the `TermLog` and `EventStore` addons to listen for stdlib log records.
This means that all `mitmproxy.ctx.log.info` events are now simply `logging.info` etc.
One upside of this approach is that many parts of the codebase now don't depend
on the existence of `mitmproxy.ctx` and we can use off-the-shelf things like pytest's
`caplog`. We can also now better colorize log output and/or add timestamps.
* Partial gRPC contentview prototype, not linted, no tests, not as add-on
* Linted (flake8)
* Save dev state
* Rewrote of protobuf parser, use decoding strategy, reduced rendered data. Parser uses generators
* minor cleanup
* fix: preferred encoding was provided as function instead of value
* flake8: line length
* Backlinked message tree objects, temporary debug out
* Partial implementation of gRPC definitions. Save state to fix a cras (data invalidate in edit mode)
* hack: deal with missing exception handling for generator based content views
* gRPC/Protoparser descriptions (with test code)
* replaced manual gzip decoding with mitmproxy.net.encoding.decode
* Refactored typing imports
* Reafctoring
* distinguish request vs response definitions, separate view config from parser config
* Code cleaning, moved customized protobuf definitions to example addon
* final cleanup
* changelog
* Stubs for tests
* Fixed render_riority of addon example
* Started adding tests
* Work on tests
* mypy
* Added pseudo encoder to tests, to cover special decodings
* Example addon test added
* finalized tests, no 100 percent coverage possible, see comments un uncovered code
* minor adjustments
* fixup tests
* Typos
Co-authored-by: Maximilian Hils <git@maximilianhils.com>