• Stars
    star
    2,892
  • Rank 15,185 (Top 0.4 %)
  • Language
    Go
  • License
    MIT License
  • Created almost 2 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A cli tool to proxy and analyze TCP connections.

tproxy

English | 简体中文

Go Go Report Card Release License: MIT

Buy Me A Coffee

Why I wrote this tool

When I develop backend services and write go-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 use scoop:

$ scoop install tproxy

Usages

$ tproxy --help
Usage of tproxy:
  -d duration
    	the delay to relay packets
  -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

Examples

Monitor gRPC connections

$ 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

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 a star. Thanks!

More Repositories

1

go-stash

go-stash is a high performance, free and open source server-side data processing pipeline that ingests data from Kafka, processes it, and then sends it to ElasticSearch.
Go
957
star
2

chatbot

A fast responsive, machine learning, conversational dialog engine for creating chat bots, written in Go.
Go
391
star
3

mapreduce

A in-process MapReduce library to help you optimizing service response time or concurrent task processing.
Go
142
star
4

depu

A tool to check available updates of packages in go.mod.
Go
112
star
5

stream

Stream API for Go.
Go
84
star
6

mdconv

A tool to convert markdown to html.
HTML
38
star
7

grpc-restful

gRPC gateway example.
Go
34
star
8

rust-zero

A web and RPC framework written in Rust.
Rust
31
star
9

why-golang

共创出一个有说服力的文档供大家参考,提供成熟套路和话术帮助gopher说服团队从其他语言转到golang
17
star
10

stargazers

Monitor star changes of GitHub repo, and send the notification to slack or lark.
Go
15
star
11

gozero-dtm

Showcase of go-zero + dtm
Go
12
star
12

kevwan

My personal repository.
12
star
13

gateway

HTTP to gRPC gateway standalone.
Go
11
star
14

gobench

Write and plot your benchmark just in Go.
Go
11
star
15

libcstl

Standard Template Library implementation in C.
C
5
star
16

cppdelegate

C# delegate implementation in C++
C++
5
star
17

adhoc

adhoc test repo
Go
4
star
18

zero-issues

The code for go-zero issues
Go
4
star
19

stack

A cli tool to prettify stacktrace in json logs.
Rust
4
star
20

chineseocr_lite

超轻量级中文ocr,支持竖排文字识别, 支持ncnn推理 , psenet(8.5M) + crnn(6.3M) + anglenet(1.5M) 总模型仅17M
C++
2
star
21

evio

Fast event-loop networking for Go
Go
1
star
22

microservices-in-action

The collection of articles on design principles and best practices in microservices with go-zero.
1
star