Event-driven transparent PROXY protocol relay
  • Go 98.4%
  • Dockerfile 1.6%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-27 02:50:02 +03:00
.github/workflows ci(github-action): update zekihan/release-workflows digest ( e01866e → 98a85ab ) 2026-11-26 23:34:28 +00:00
.dockerignore Implement event-driven mmproxy relay 2026-11-27 02:05:10 +03:00
.gitignore Implement event-driven mmproxy relay 2026-11-27 02:05:10 +03:00
.goreleaser.yaml Declare and package the mmproxy release 2026-11-27 02:15:53 +03:00
config_linux.go Complete address flag compatibility 2026-11-27 02:11:40 +03:00
Dockerfile Enable transparent routing in the non-root image 2026-11-27 02:33:06 +03:00
go.mod Build the release with patched Go 2026-11-27 02:24:54 +03:00
LICENSE Implement event-driven mmproxy relay 2026-11-27 02:05:10 +03:00
LICENSE-Go Declare and package the mmproxy release 2026-11-27 02:15:53 +03:00
main_linux.go Implement event-driven mmproxy relay 2026-11-27 02:05:10 +03:00
protocol.go Implement event-driven mmproxy relay 2026-11-27 02:05:10 +03:00
README.md Verify UDP admission at capacity 2026-11-27 02:50:02 +03:00
relay_linux_test.go Verify UDP admission at capacity 2026-11-27 02:50:02 +03:00
renovate.json chore(deps): add renovate.json (#1) 2026-11-27 02:33:44 +03:00
routing_linux.go Implement event-driven mmproxy relay 2026-11-27 02:05:10 +03:00
udp_linux.go Implement event-driven mmproxy relay 2026-11-27 02:05:10 +03:00
VERSION Enable transparent routing in the non-root image 2026-11-27 02:33:06 +03:00

mmproxy

A Linux PROXY protocol relay that forwards TCP streams and UDP datagrams to fixed or explicitly enabled dynamic destinations. The TCP frontend uses epoll and borrows splice pipes only while a direction has work. UDP flows and TCP sessions use the same admission and descriptor budget.

mmproxy -p tcp -l 127.0.0.1:2222 -4 127.0.0.1:2223 -6 '[::1]:2223' \
  -allowed-subnets /etc/mmproxy/allowed-subnets.txt -v 1

Use a peer allowlist on every production listener. PROXY headers are required by default. For TCP, -allow-raw-tcp requires a nonempty peer allowlist and enables transparent forwarding of raw peer addresses. -raw-detection-timeout defaults to 200 ms, and incomplete PROXY prefixes use the regular header deadline.

-dynamic-destination allows trusted peers to supply a destination. Use -allowed-destinations to restrict dynamic destination CIDRs. Valid addressless headers select the fixed backend by frontend family and use an ordinary backend connection. UDP accepts PROXY v2 datagrams and -close-after configures flow idle expiry.

Run with CAP_NET_ADMIN for transparent forwarding and built-in routing. Set MMPROXY_SETUP_ROUTING=true to install loopback routes and rules in the process network namespace. The default table is 123 and default rule priority is 32765. Override them with MMPROXY_ROUTING_TABLE and MMPROXY_ROUTING_PRIORITY. Existing matching entries stay in place. Conflicting entries stop startup. The process leaves policy routing installed on exit.

The scratch image runs as UID 65532. Grant NET_ADMIN and drop the other capabilities. The runtime must permit the executable to gain this capability at exec time. For example, with Docker:

docker run --rm --cap-drop=ALL --cap-add=NET_ADMIN \
  -e MMPROXY_SETUP_ROUTING=true ghcr.io/zekihan/mmproxy:1.0.3 -l 127.0.0.1:2222

The relay and parser are first-party. The policy routing encoder and environment contract derive from the first-party dockerfiles mmproxy entrypoint. The upstream v2.3.1 binary is only built inside compatibility tests.

Run go test -race ./... and go vet ./... locally. The CI namespace tests install routing in an isolated network namespace. Release binaries target Linux amd64 and arm64.

Namespace test Behavior
TCP forwarding Both implementations preserve the source and half-close streams. mmproxy also selects the IPv6 backend from a TCP6 PROXY header over an IPv4 listener and accepts fragmented headers.
Dynamic destinations Both forward PROXY v1 TCP and PROXY v2 UDP to the advertised destination when enabled. The namespace fixtures use transparent listeners and multiple listener sockets.
UDP flow expiry Both expire idle flows using -close-after. mmproxy keeps existing flows when its connection budget blocks new ones and admits new flows after expiry.
Mixed TCP mmproxy requires an explicit nonempty peer allowlist. It preserves the frontend source for both silent and talk-first raw TCP. Addressless headers use an ordinary connection to the fixed backend.
Policy routing mmproxy reuses matching entries and rejects conflicts.