Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A cli tool to proxy and analyze TCP connections.

License

NotificationsYou must be signed in to change notification settings

kevwan/tproxy

Repository files navigation

English |简体中文 |日本語

GoGo Report CardReleaseLicense: MIT

Buy Me A Coffee

Why I wrote this tool

When I develop backend services and writego-zero, I often need to monitor the network traffic. For example:

  1. monitoring gRPC connections, when to connect and when to reconnect
  2. monitoring MySQL connection pools, how many connections and figure out the lifetime policy
  3. monitoring any TCP connections on the fly

Installation

$ go install github.com/kevwan/tproxy@latest

Or use docker images:

$ docker run --rm -it -p<listen-port>:<listen-port> -p<remote-port>:<remote-port> kevinwan/tproxy:v1 tproxy -l 0.0.0.0 -p<listen-port> -r host.docker.internal:<remote-port>

For arm64:

$ docker run --rm -it -p<listen-port>:<listen-port> -p<remote-port>:<remote-port> kevinwan/tproxy:v1-arm64 tproxy -l 0.0.0.0 -p<listen-port> -r host.docker.internal:<remote-port>

On Windows, you can usescoop:

$ scoop install tproxy

Usages

$ tproxy --helpUsage 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  -qQuiet mode, only prints connection open/close and stats, defaultfalse  -r string    Remote address (host:port) to connect  -sEnable statistics  -t string    Thetype of protocol, currently support http2, grpc, redis and mongodb  -up int    Upward speed limit(bytes/second)

Examples

Monitor gRPC connections

$ tproxy -p 8088 -r localhost:8081 -t grpc -d 100ms
  • listen on localhost and port 8088
  • redirect the traffic tolocalhost:8081
  • protocol type to be gRPC
  • delay 100ms for each packets

image

Monitor MySQL connections

$ tproxy -p 3307 -r localhost:3306

image

Check the connection reliability (Retrans rate and RTT)

$ tproxy -p 3307 -r remotehost:3306 -s -q

image

Learn the connection pool behaviors

$ tproxy -p 3307 -r localhost:3306 -q -s

image

Give a Star! ⭐

If you like or are using this project, please give it astar. Thanks!


[8]ページ先頭

©2009-2025 Movatter.jp