Bidirectional proxy that bridges raw TCP and WebSocket binary frames.
tcp-ws: TCP inbound to WebSocket outbound (binary frames).ws-tcp: WebSocket inbound to TCP outbound (binary frames).- Optional HAProxy v2 header injection for
ws-tcpusingcf-connecting-ip.
cargo build --release
cargo run -- tcp-ws 127.0.0.1:9000 ws://127.0.0.1:8080
cargo run -- ws-tcp 127.0.0.1:8080 127.0.0.1:9000
cargo run -- ws-tcp 127.0.0.1:8080 127.0.0.1:9000 --haproxy-v2
Notes:
- In
ws-tcpmode, the proxy inspects the WebSocket handshake for thecf-connecting-ipheader. - When
--haproxy-v2is enabled, the proxy sends a HAProxy v2 PROXY header to the TCP backend using thecf-connecting-ipvalue if present, otherwise the remote socket address. - If the header IP is IPv6 and the backend connection is IPv4, the proxy maps IPv4 to an IPv6-mapped address to produce a valid v2 header.
tcp-ws <listen_addr> <ws_url>ws-tcp <listen_addr> <tcp_target> [--haproxy-v2 | --haproxy]
[TCP client] -> (tcp-ws) -> [WebSocket server]
[WebSocket client] -> (ws-tcp) -> [TCP server]
This project was originally called WebSocketMC.