Skip to content

The Rust bits in mitmproxy. 🦀

License

Notifications You must be signed in to change notification settings

mhils/mitmproxy_rs

 
 

Repository files navigation

Note This repository is unreleased work-in-progress, but mitmproxy 9 ships with mitmproxy_wireguard already!

mitmproxy_rs

autofix.ci: enabled Continuous Integration Status Latest Version Supported Python versions PyPI - Wheel dev documentation

This repository contains mitmproxy's Rust bits, most notably:

  • WireGuard Mode: The ability to proxy any device that can be configured as a WireGuard client.
  • Windows OS Proxy Mode: The ability to proxy arbitrary Windows applications by name or pid.

Supported Architectures

mitmproxy_rs should work on most architectures / targets - including, but not limited to Windows, macOS, and Linux, running on x86_64 (x64) and aarch64 (arm64) CPUs.

Binary wheels for the following targets are available from PyPI:

  • Windows / x64 (x86_64-windows-msvc)
  • macOS / Intel (x86_64-apple-darwin)
  • macos / Apple Silicon (aarch64-apple-darwin) via "Universal 2" binaries
  • Linux / x86_64 (x86_64-unknown-linux-gnu)
  • Linux / aarch64 (aarch64-unknown-linux-gnu), i.e. for Raspberry Pi 2+ and similar devices

Architecture

library architecture

Build Requirements

  • Python 3.9+
  • Rust 1.65+
  • maturin 0.14+

Python API

dev documentation

Hacking

Setting up the development environment is relatively straightforward, as only a Rust toolchain and Python 3 are required:

# set up a new venv
python3 -m venv venv

# enter venv (use the activation script for your shell)
source ./venv/bin/activate

pip install maturin

Compiling the native Rust module then becomes easy:

# compile native Rust module and install it in venv
maturin develop

Once that's done (phew! Rust sure does take a while to compile!), the test echo server should work correctly. It will print instructions for connecting to it over a WireGuard VPN:

python3 ./wireguard_echo_test_server.py

The included mitm-wg-test-client binary can be used to test this echo test server, which can be built by running cargo build inside the test-client directory, and launched from target/debug/mitm-wg-test-client.

Introspecting the tokio runtime

The asynchronous runtime can be introspected using tokio-console if the crate was built with the tracing feature:

tokio-console http://localhost:6669

There should be no task that is busy when the program is idle, i.e. there should be no busy waiting.

Code style

The format for Rust code is enforced by rustfmt. To apply the formatting rules, use:

cargo fmt

The format for Python code (i.e. the test echo server and the type stubs) is enforced with black and can be applied with:

black wireguard_echo_test_server.py mitmproxy_rs.pyi benches/*.py

About

The Rust bits in mitmproxy. 🦀

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 87.3%
  • Python 12.6%
  • Shell 0.1%