English | 简体中文
When I develop backend services and write go-zero, I often need to monitor the network traffic. For example:
- monitoring gRPC connections, when to connect and when to reconnect
- monitoring MySQL connection pools, how many connections and figure out the lifetime policy
- monitoring any TCP connections on the fly
$ go install github.com/meta-quick/tproxy@latest
$ tproxy --help
Usage of tproxy:
-d duration
the delay to relay packets
-down int
Downward speed limit(bytes/second)
-l string
Local address to listen on (default "localhost")
-p int
Local port to listen on, default to pick a random port
-q Quiet mode, only prints connection open/close and stats, default false
-r string
Remote address (host:port) to connect
-s Enable statistics
-t string
The type of protocol, currently support http2, grpc, redis and mongodb
-up int
Upward speed limit(bytes/second)
-x string
Relay protocol type, default to tcp, currently support tcp and udp
$ tproxy -p 8088 -r localhost:8081 -t grpc -d 100ms
- listen on localhost and port 8088
- redirect the traffic to
localhost:8081
- protocol type to be gRPC
- delay 100ms for each packets
$ tproxy -p 3307 -r localhost:3306
$ tproxy -p 3307 -r remotehost:3306 -s -q
$ tproxy -p 3307 -r localhost:3306 -q -s
If you like or are using this project, please give it a star. Thanks!