- Go 98.4%
- Dockerfile 1.6%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .github/workflows | ||
| .dockerignore | ||
| .gitignore | ||
| .goreleaser.yaml | ||
| config_linux.go | ||
| Dockerfile | ||
| go.mod | ||
| LICENSE | ||
| LICENSE-Go | ||
| main_linux.go | ||
| protocol.go | ||
| README.md | ||
| relay_linux_test.go | ||
| renovate.json | ||
| routing_linux.go | ||
| udp_linux.go | ||
| VERSION | ||
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. |