* add mode spec for WireGuard mode
* add WireGuard server implementation
* remove coverage excludes
* simplify wireguard spec
* lint!
* remove superfluous tests
* bump to mitmproxy_wireguard 0.1.1
* proxy/test_mode_specs: remove unused import
* fix wireguard server mode
* WireGuard: move keyfile gen into `.start()`
This way any file format errors result in `.last_exception` being set.
* fixup UDP support
* bump to mitmproxy_wireguard v0.1.2
This release fixes TCP connections which were broken in v0.1.1.
* fix crash handler
* add simple test for WireGuard server instances
* bump to mitmproxy_wireguard v0.1.5 and fix launching wg-test-client
* fixups
- monkeypatch `handle_client` instead of the handlers.
- fix OS detection
- ctx.log -> logging
* nits
* bump to mitmproxy_wireguard 0.1.6 for fixed test client
* move WireGuardDatagramTransport into dedicated module
this allows us to exclude it from individual coverage, which makes no sense.
Also improve type checking to make sure that it's a full replacement.
* cover WireGuardServerInstance.is_running property with tests
* enable specialized server instance creation
* test wireguard conf generation
* deduplicate tcp/udp handlers
* update CHANGELOG
Co-authored-by: Maximilian Hils <git@maximilianhils.com>
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.