gitmyhub

tproxy

Go ★ 3.7k updated 6d ago

A cli tool to proxy and analyze TCP connections.

A command-line TCP proxy that sits between your app and a backend service, logging every connection event in real time with protocol-aware decoding for gRPC, HTTP/2, Redis, and MongoDB.

GoDockersetup: easycomplexity 2/5

tproxy is a command-line tool that sits between your application and a backend service, forwarding all the network traffic while letting you watch what is happening in real time. The author built it to answer practical questions when developing backend services: when does a gRPC connection open and close, how many database connections are alive at once, and what is the actual retry behavior of a connection pool.

To use it, you pick a local port to listen on and point the tool at the real destination. For example, if your app normally talks to a database on port 3306, you tell tproxy to listen on port 3307 and forward everything to 3306. Your app connects to 3307, tproxy relays the traffic, and you see a running log of every connection event on your terminal. You can also introduce an artificial delay to simulate slow network conditions, or set speed limits in either direction to see how your app behaves under constrained bandwidth.

The tool understands a handful of specific protocols: gRPC, HTTP/2, Redis, and MongoDB. When you specify one of these, tproxy can decode the traffic and show you more meaningful output than raw bytes. For other TCP-based services like MySQL, it still works fine and shows connection-level statistics such as retransmission rates and round-trip times.

Installation is a single Go command, or you can run it via a Docker container without installing anything locally. Windows users can install it through the Scoop package manager. There are no background services or configuration files required. You run the command, pass a few flags, and it starts forwarding traffic immediately.

The tool is most useful when you are debugging a misbehaving connection pool, investigating reconnect loops, or trying to understand the traffic pattern between two services without setting up a more complex packet-capture tool.

Where it fits