Help us shape the future of Go! Take the 2026 Go Developer Survey

mitmproxy-go

module
v0.0.0-...-bcdfb6d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2026 License: MIT

README

mitmproxy-go

A Go port of mitmproxy, the interactive TLS-capable intercepting proxy, together with the packet-level parts of mitmproxy-rs (WireGuard, local and TUN modes, content views).

The port aims at full compatibility with upstream: flow files, the ~/.mitmproxy CA layout, the filter language, option names and precedence, hook names, proxy mode specs and the mitmweb API, verified against upstream fixtures and against the pinned Python mitmproxy in differential tests.

Upstream pins

Upstream Commit Notes
mitmproxy (Python) 3368a0a 13.0.0.dev, flow format version 21
mitmproxy-rs (Rust) 51fe2b7 workspace 0.13.0-dev; redirector artifacts come from the 0.12.x wheels

Status

Planning is complete. Foundation work (tooling, CI, flow data model, codecs and registries) is in progress; there is no binary yet. The three binaries mitmdump, mitmproxy and mitmweb will live under cmd/.

The work plan, with scope, architecture, package choices and acceptance criteria, is docs/plans/mitmproxy-go-port.md. Pinned dependencies and their upgrade paths are listed in docs/dependencies.md. Where the port behaves differently from mitmproxy on purpose, and why, is listed in docs/compat.md.

Requirements

Go 1.27 or newer.

Native local-mode manual acceptance: macOS and Windows.

Development

hack/fmt.sh    # gofmt, gofumpt, modernize, goimports-rereviser
hack/lint.sh   # go vet, golangci-lint
go test -race -count=1 ./...

Licence

MIT; see LICENSE. Upstream mitmproxy and mitmproxy-rs are MIT-licensed; fixtures copied from them carry their notice under testdata/.

Directories

Path Synopsis
Package addon runs addons: it registers them, and it dispatches hooks to them inside a single dispatch domain.
Package addon runs addons: it registers them, and it dispatches hooks to them inside a single dispatch domain.
addontest
Package addontest provides an addon for testing hook dispatch.
Package addontest provides an addon for testing hook dispatch.
eventsequence
Package eventsequence replays a finished flow as the sequence of hooks the proxy fired while the flow was live (mitmproxy's eventsequence).
Package eventsequence replays a finished flow as the sequence of hooks the proxy fired while the flow was live (mitmproxy's eventsequence).
hookdata
Package hookdata defines the values the proxy passes to the connection, TLS and QUIC hooks, mirroring the dataclasses mitmproxy passes to the same hooks.
Package hookdata defines the values the proxy passes to the connection, TLS and QUIC hooks, mirroring the dataclasses mitmproxy passes to the same hooks.
addons
anticache
Package anticache removes request headers that permit a not-modified response.
Package anticache removes request headers that permit a not-modified response.
anticomp
Package anticomp asks servers not to compress their responses.
Package anticomp asks servers not to compress their responses.
apphost
Package apphost serves in-process HTTP handlers from proxy request hooks.
Package apphost serves in-process HTTP handlers from proxy request hooks.
block
Package block filters client connections by their source IP address.
Package block filters client connections by their source IP address.
blocklist
Package blocklist blocks matching requests with empty responses or a closed connection.
Package blocklist blocks matching requests with empty responses or a closed connection.
browser
Package browser starts isolated browsers configured to use the proxy.
Package browser starts isolated browsers configured to use the proxy.
clientplayback
Package clientplayback replays saved HTTP requests through the proxy core.
Package clientplayback replays saved HTTP requests through the proxy core.
commandhistory
Package commandhistory persists command history and navigates filtered commands.
Package commandhistory persists command history and navigates filtered commands.
comment
Package comment adds user comments to flows and notifies update handlers.
Package comment adds user comments to flows and notifies update handlers.
core
Package core registers commands for editing flows and managing options.
Package core registers commands for editing flows and managing options.
cut
Package cut extracts flow attributes as byte values or text tables.
Package cut extracts flow attributes as byte values or text tables.
disableh2c
Package disableh2c refuses HTTP/2 upgrades and prior knowledge without TLS.
Package disableh2c refuses HTTP/2 upgrades and prior knowledge without TLS.
dnsresolver
Package dnsresolver resolves address questions in DNS and WireGuard modes.
Package dnsresolver resolves address questions in DNS and WireGuard modes.
dumper
Package dumper prints flows in mitmdump's human-readable format.
Package dumper prints flows in mitmdump's human-readable format.
errorcheck
Package errorcheck stops startup when the application logs an error.
Package errorcheck stops startup when the application logs an error.
eventstore
Package eventstore keeps a bounded frontend event log.
Package eventstore keeps a bounded frontend event log.
export
Package export renders flows as external commands or raw HTTP messages.
Package export renders flows as external commands or raw HTTP messages.
intercept
Package intercept pauses flows matching the configured interception filter.
Package intercept pauses flows matching the configured interception filter.
keepserving
Package keepserving shuts the proxy down once playback and file reads finish, porting mitmproxy's KeepServing.
Package keepserving shuts the proxy down once playback and file reads finish, porting mitmproxy's KeepServing.
maplocal
Package maplocal serves matching HTTP requests from local files or directories.
Package maplocal serves matching HTTP requests from local files or directories.
mapremote
Package mapremote rewrites the URLs of matching live HTTP requests.
Package mapremote rewrites the URLs of matching live HTTP requests.
modifybody
Package modifybody rewrites buffered request and response bodies using flow filters.
Package modifybody rewrites buffered request and response bodies using flow filters.
modifyheaders
Package modifyheaders rewrites request and response headers using flow filters.
Package modifyheaders rewrites request and response headers using flow filters.
nextlayer
Package nextlayer chooses protocol layer stacks from connection metadata and buffered bytes.
Package nextlayer chooses protocol layer stacks from connection metadata and buffered bytes.
onboarding
Package onboarding hosts the certificate installation app inside the proxy.
Package onboarding hosts the certificate installation app inside the proxy.
onboardingapp
Package onboardingapp serves the certificate installation page and downloads.
Package onboardingapp serves the certificate installation page and downloads.
proxyauth
Package proxyauth authenticates requests with a password, htpasswd file or LDAP.
Package proxyauth authenticates requests with a password, htpasswd file or LDAP.
proxyserver
Package proxyserver configures and runs TCP proxy listeners.
Package proxyserver configures and runs TCP proxy listeners.
readfile
Package readfile replays recorded flow files through the proxy's hooks.
Package readfile replays recorded flow files through the proxy's hooks.
save
Package save streams completed flows to mitmproxy dump files.
Package save streams completed flows to mitmproxy dump files.
savehar
Package savehar exports completed HTTP flows to HTTP Archive files.
Package savehar exports completed HTTP flows to HTTP Archive files.
serverplayback
Package serverplayback serves recorded HTTP responses to matching requests.
Package serverplayback serves recorded HTTP responses to matching requests.
serversideevents
Package serversideevents warns about buffered server-side event responses.
Package serversideevents warns about buffered server-side event responses.
stickyauth
Package stickyauth carries Authorization headers onto matching later requests.
Package stickyauth carries Authorization headers onto matching later requests.
stickycookie
Package stickycookie carries server cookies onto matching later requests.
Package stickycookie carries server cookies onto matching later requests.
stripdnshttpsrecords
Package stripdnshttpsrecords removes ECH and disabled HTTP/3 advertisements from HTTPS answers while retaining records and unrelated service parameters.
Package stripdnshttpsrecords removes ECH and disabled HTTP/3 advertisements from HTTPS answers while retaining records and unrelated service parameters.
termlog
Package termlog prints application log records to a terminal or pipe.
Package termlog prints application log records to a terminal or pipe.
tlsconfig
Package tlsconfig supplies the proxy core with the TLS configurations it uses to negotiate TLS, as upstream's tlsconfig addon supplies it with OpenSSL connection objects (py:mitmproxy/addons/tlsconfig.py).
Package tlsconfig supplies the proxy core with the TLS configurations it uses to negotiate TLS, as upstream's tlsconfig addon supplies it with OpenSSL connection objects (py:mitmproxy/addons/tlsconfig.py).
updatealtsvc
Package updatealtsvc retargets reverse-proxy Alt-Svc advertisements to the listener.
Package updatealtsvc retargets reverse-proxy Alt-Svc advertisements to the listener.
upstreamauth
Package upstreamauth adds HTTP Basic credentials to upstream and reverse requests.
Package upstreamauth adds HTTP Basic credentials to upstream and reverse requests.
view
Package view maintains an ordered, filtered flow store and frontend focus.
Package view maintains an ordered, filtered flow store and frontend focus.
Package certs generates and stores the TLS certificates of the proxy.
Package certs generates and stores the TLS certificates of the proxy.
cmd
mitmdump command
Mitmdump proxies traffic and prints flows to the terminal, as mitmproxy's mitmdump entry point does.
Mitmdump proxies traffic and prints flows to the terminal, as mitmproxy's mitmdump entry point does.
Package command manages typed commands that addons register and that the frontends invoke by name.
Package command manages typed commands that addons register and that the frontends invoke by name.
Package connection describes the client and server connections of a flow.
Package connection describes the client and server connections of a flow.
Package contentviews formats message bodies for display and interactive editing.
Package contentviews formats message bodies for display and interactive editing.
imagemeta
Package imagemeta extracts the display metadata of PNG, GIF, JPEG and ICO images, reading exactly the fields mitmproxy's parsers read.
Package imagemeta extracts the display metadata of PNG, GIF, JPEG and ICO images, reading exactly the fields mitmproxy's parsers read.
Package dns holds mitmproxy's DNS data model: messages, questions and resource records, and the protocol constants with their display names.
Package dns holds mitmproxy's DNS data model: messages, questions and resource records, and the protocol constants with their display names.
Package filter parses mitmproxy flow filter expressions.
Package filter parses mitmproxy flow filter expressions.
regex
Package regex compiles the regular expressions used by flow filters.
Package regex compiles the regular expressions used by flow filters.
Package flow defines mitmproxy's flows: one HTTP transaction, TCP session, UDP session or DNS query together with the client and server connections it ran over.
Package flow defines mitmproxy's flows: one HTTP transaction, TCP session, UDP session or DNS query together with the client and server connections it ran over.
state
Package state is the serialised-state vocabulary of flows.
Package state is the serialised-state vocabulary of flows.
Package flowio reads and writes mitmproxy flow files.
Package flowio reads and writes mitmproxy flow files.
flowjson
Package flowjson builds the content-free, insertion-ordered flow objects exposed by mitmweb, as mitmproxy/tools/web/app.py flow_to_json does.
Package flowjson builds the content-free, insertion-ordered flow objects exposed by mitmweb, as mitmproxy/tools/web/app.py flow_to_json does.
har
Package har imports HTTP Archive entries as mitmproxy HTTP flows.
Package har imports HTTP Archive entries as mitmproxy HTTP flows.
tnetstring
Package tnetstring implements mitmproxy's dialect of typed netstrings, the serialisation format of .mitm flow files.
Package tnetstring implements mitmproxy's dialect of typed netstrings, the serialisation format of .mitm flow files.
Package httpmsg holds mitmproxy's HTTP data model: raw header fields, requests, responses and the helpers built on them.
Package httpmsg holds mitmproxy's HTTP data model: raw header fields, requests, responses and the helpers built on them.
internal
difftest
Package difftest runs Python code against the pinned upstream mitmproxy, so that tests can compare the port's behaviour with upstream's.
Package difftest runs Python code against the pinned upstream mitmproxy, so that tests can compare the port's behaviour with upstream's.
emoji
Package emoji holds the flow-marker shortcodes of mitmproxy's mitmproxy/utils/emoji.py: every name a flow may be marked with and the character it is rendered as.
Package emoji holds the flow-marker shortcodes of mitmproxy's mitmproxy/utils/emoji.py: every name a flow may be marked with and the character it is rendered as.
h2
Package h2 implements independent, bounded HTTP/2 protocol endpoints over borrowed connections.
Package h2 implements independent, bounded HTTP/2 protocol endpoints over borrowed connections.
h3
Package h3 implements ordered HTTP/3 protocol events and framing.
Package h3 implements ordered HTTP/3 protocol events and framing.
htpasswd
Package htpasswd reads Apache password files supporting bcrypt and SHA-1.
Package htpasswd reads Apache password files supporting bcrypt and SHA-1.
http1
Package http1 reads and assembles bounded HTTP/1 messages without using net/http.
Package http1 reads and assembles bounded HTTP/1 messages without using net/http.
human
Package human holds the display helpers of mitmproxy's mitmproxy/utils/human.py: byte sizes, durations, timestamps and socket addresses formatted for people, and the size parser behind options such as body_size_limit.
Package human holds the display helpers of mitmproxy's mitmproxy/utils/human.py: byte sizes, durations, timestamps and socket addresses formatted for people, and the size parser behind options such as body_size_limit.
local
Package local contains the native redirector's IPC wire messages.
Package local contains the native redirector's IPC wire messages.
magisk
Package magisk builds the Magisk module archive that installs the mitmproxy CA certificate into Android's system certificate store, as mitmproxy/utils/magisk.py builds it.
Package magisk builds the Magisk module archive that installs the mitmproxy CA certificate into Android's system certificate store, as mitmproxy/utils/magisk.py builds it.
netstack
Package netstack accepts IP packets addressed to arbitrary destinations.
Package netstack accepts IP packets addressed to arbitrary destinations.
netutil/check
Package check validates host names and ports the way mitmproxy's mitmproxy/net/check.py does.
Package check validates host names and ports the way mitmproxy's mitmproxy/net/check.py does.
netutil/encoding
Package encoding decodes and encodes HTTP message bodies for the Content-Encoding values mitmproxy understands.
Package encoding decodes and encodes HTTP message bodies for the Content-Encoding values mitmproxy understands.
netutil/freeport
Package freeport finds a port that is free for TCP or both TCP and UDP, as mitmproxy's mitmproxy/net/free_port.py does for the paired protocols.
Package freeport finds a port that is free for TCP or both TCP and UDP, as mitmproxy's mitmproxy/net/free_port.py does for the paired protocols.
netutil/localip
Package localip finds the local address the operating system would use for outgoing traffic, as mitmproxy's mitmproxy/net/local_ip.py does.
Package localip finds the local address the operating system would use for outgoing traffic, as mitmproxy's mitmproxy/net/local_ip.py does.
netutil/serverspec
Package serverspec parses server specifications, which describe an upstream proxy or server, the way mitmproxy's mitmproxy/net/server_spec.py does: "http://example.com/", "example.org" or "example.com:443".
Package serverspec parses server specifications, which describe an upstream proxy or server, the way mitmproxy's mitmproxy/net/server_spec.py does: "http://example.com/", "example.org" or "example.com:443".
privfile
Package privfile opens private, operator-selected output files without following a final-component symlink.
Package privfile opens private, operator-selected output files without following a final-component symlink.
proxy
Package proxy drives protocol layers and owns their connections.
Package proxy drives protocol layers and owns their connections.
proxy/layer
Package layer defines the contract between the proxy's connection handler and its protocol layers: what a layer is, how it is built, how it reads and writes connections, and how it fires hooks.
Package layer defines the contract between the proxy's connection handler and its protocol layers: what a layer is, how it is built, how it reads and writes connections, and how it fires hooks.
proxy/layer/layertest
Package layertest checks protocol layers' replay, half-close and hook dispatch contracts using real connections.
Package layertest checks protocol layers' replay, half-close and hook dispatch contracts using real connections.
proxy/layers/dnslayer
Package dnslayer handles DNS exchanges over packet and length-prefixed stream transports.
Package dnslayer handles DNS exchanges over packet and length-prefixed stream transports.
proxy/layers/httplayer
Package httplayer connects HTTP protocol endpoints through a common request/response event vocabulary.
Package httplayer connects HTTP protocol endpoints through a common request/response event vocabulary.
proxy/layers/httplayer/h3test
Package h3test provides frame-level HTTP/3 peers on real loopback QUIC sockets.
Package h3test provides frame-level HTTP/3 peers on real loopback QUIC sockets.
proxy/layers/modes
Package modes registers the regular, reverse, and upstream proxy top layers.
Package modes registers the regular, reverse, and upstream proxy top layers.
proxy/layers/quic
Package quic intercepts QUIC connections and relays their streams and datagrams.
Package quic intercepts QUIC connections and relays their streams and datagrams.
proxy/layers/tcplayer
Package tcplayer relays TCP streams through serialised message hooks.
Package tcplayer relays TCP streams through serialised message hooks.
proxy/layers/tlslayer
Package tlslayer intercepts TLS connections using the configuration supplied by TLS hook handlers.
Package tlslayer intercepts TLS connections using the configuration supplied by TLS hook handlers.
proxy/layers/udplayer
Package udplayer relays UDP datagrams through serialised message hooks.
Package udplayer relays UDP datagrams through serialised message hooks.
proxy/layers/websocket
Package websocket relays upgraded HTTP connections through serial WebSocket hooks.
Package websocket relays upgraded HTTP connections through serial WebSocket hooks.
proxy/layers/websocket/autobahn command
Command autobahn runs a real echo origin and validates the frozen testsuite catalogue.
Command autobahn runs a real echo origin and validates the frozen testsuite catalogue.
proxy/modeserver
Package modeserver owns listeners and packet sources for proxy modes.
Package modeserver owns listeners and packet sources for proxy modes.
proxy/modespec
Package modespec parses mitmproxy mode specifications of the form mode[:configuration][@[listen_host:]listen_port].
Package modespec parses mitmproxy mode specifications of the form mode[:configuration][@[listen_host:]listen_port].
proxy/packettransport
Package packettransport demultiplexes a shared UDP socket into bounded, packet-preserving connections.
Package packettransport demultiplexes a shared UDP socket into bounded, packet-preserving connections.
proxy/proxytest
Package proxytest starts a complete in-process proxy for end-to-end tests.
Package proxytest starts a complete in-process proxy for end-to-end tests.
pyrepr
Package pyrepr renders values the way Python's repr() renders the objects they stand for, which is how mitmproxy shows values inside its messages and filter matches.
Package pyrepr renders values the way Python's repr() renders the objects they stand for, which is how mitmproxy shows values inside its messages and filter matches.
spec
Package spec parses separator-delimited flow modification options.
Package spec parses separator-delimited flow modification options.
stateutil
Package stateutil holds the helpers the flow models share when they write their serialised state and when they stamp a new flow or connection.
Package stateutil holds the helpers the flow models share when they write their serialised state and when they stamp a new flow or connection.
strutil
Package strutil holds the string and byte helpers of mitmproxy's mitmproxy/utils/strutils.py: escaping bytes for display and back, binary and XML sniffing, hex dumps, and protecting regions of source text from regular-expression rewrites.
Package strutil holds the string and byte helpers of mitmproxy's mitmproxy/utils/strutils.py: escaping bytes for display and back, binary and XML sniffing, hex dumps, and protecting regions of source text from regular-expression rewrites.
testutil
Package testutil holds helpers shared by the tests of this module.
Package testutil holds helpers shared by the tests of this module.
testutil/testflow
Package testflow builds the flows, connections and messages that upstream's tests build with mitmproxy/test/tflow.py and mitmproxy/test/tutils.py, with the same field values, so that tests ported from upstream read the same.
Package testflow builds the flows, connections and messages that upstream's tests build with mitmproxy/test/tflow.py and mitmproxy/test/tutils.py, with the same field values, so that tests ported from upstream read the same.
textwrap
Package textwrap ports the parts of Python's textwrap module that mitmproxy uses to lay out help text: dedent and wrap with their default settings.
Package textwrap ports the parts of Python's textwrap module that mitmproxy uses to lay out help text: dedent and wrap with their default settings.
tlsnames
Package tlsnames translates the cipher suite names used by crypto/tls and OpenSSL.
Package tlsnames translates the cipher suite names used by crypto/tls and OpenSSL.
tools/cmdline
Package cmdline builds mitmdump's flags from its registered options.
Package cmdline builds mitmdump's flags from its registered options.
tools/dump
Package dump assembles the mitmdump master: the addon set of mitmproxy's tools/dump.py, restricted to the ported addons.
Package dump assembles the mitmdump master: the addon set of mitmproxy's tools/dump.py, restricted to the ported addons.
tun
Package tun configures Linux TUN devices and carries their IP packets.
Package tun configures Linux TUN devices and carries their IP packets.
version
Package version holds mitmproxy-go's release version, as upstream's mitmproxy/version.py holds mitmproxy's.
Package version holds mitmproxy-go's release version, as upstream's mitmproxy/version.py holds mitmproxy's.
vtcodes
Package vtcodes detects whether an output supports virtual terminal escape codes and renders the ANSI styles mitmproxy prints with.
Package vtcodes detects whether an output supports virtual terminal escape codes and renders the ANSI styles mitmproxy prints with.
wireguard
Package wireguard connects encrypted WireGuard tunnels to userspace packet devices.
Package wireguard connects encrypted WireGuard tunnels to userspace packet devices.
Package master ties the option, command and addon registries together and runs the proxy's lifecycle (mitmproxy's Master).
Package master ties the option, command and addon registries together and runs the proxy's lifecycle (mitmproxy's Master).
Package omap provides an insertion-ordered map with string keys.
Package omap provides an insertion-ordered map with string keys.
Package options is a port of mitmproxy's option manager (mitmproxy/optmanager.py) and its core option set (mitmproxy/options.py).
Package options is a port of mitmproxy's option manager (mitmproxy/optmanager.py) and its core option set (mitmproxy/options.py).
Package tcp holds the message type of TCP flows.
Package tcp holds the message type of TCP flows.
Package tlsparse reads the TLS ClientHello a client sends first: it finds the handshake message in the TLS records the proxy has received so far, which may spread it over several records, and parses the parts that mitmproxy reports to addons (py:mitmproxy/tls.py ClientHello, py:mitmproxy/proxy/layers/tls.py and the kaitai-generated parser in py:mitmproxy/contrib/kaitaistruct/tls_client_hello.py).
Package tlsparse reads the TLS ClientHello a client sends first: it finds the handshake message in the TLS records the proxy has received so far, which may spread it over several records, and parses the parts that mitmproxy reports to addons (py:mitmproxy/tls.py ClientHello, py:mitmproxy/proxy/layers/tls.py and the kaitai-generated parser in py:mitmproxy/contrib/kaitaistruct/tls_client_hello.py).
Package udp holds the message type of UDP flows.
Package udp holds the message type of UDP flows.
Package websocket holds the data of a WebSocket connection that started as an HTTP flow: its messages and how it was closed.
Package websocket holds the data of a WebSocket connection that started as an HTTP flow: its messages and how it was closed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL