{"id":13459951,"url":"https://github.com/kevwan/tproxy","last_synced_at":"2025-05-13T19:14:28.528Z","repository":{"id":37208012,"uuid":"503167251","full_name":"kevwan/tproxy","owner":"kevwan","description":"A cli tool to proxy and analyze TCP connections.","archived":false,"fork":false,"pushed_at":"2025-05-06T08:29:19.000Z","size":1771,"stargazers_count":3363,"open_issues_count":5,"forks_count":240,"subscribers_count":32,"default_branch":"main","last_synced_at":"2025-05-12T02:49:38.675Z","etag":null,"topics":["charles","connection","grpc","monitoring-tool","proxy","relay","tcp","tcpdump","wireshark"],"latest_commit_sha":null,"homepage":"https://go-zero.dev","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kevwan.png","metadata":{"files":{"readme":"readme-cn.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["kevwan"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null,"ethereum":null}},"created_at":"2022-06-14T01:21:58.000Z","updated_at":"2025-05-07T08:32:50.000Z","dependencies_parsed_at":"2023-11-08T13:27:47.110Z","dependency_job_id":"d6f30952-a18c-45db-b686-4bf6f7045422","html_url":"https://github.com/kevwan/tproxy","commit_stats":{"total_commits":139,"total_committers":15,"mean_commits":9.266666666666667,"dds":"0.47482014388489213","last_synced_commit":"d1ac7334d6c5c958012bdfe89ef18ac1a312d234"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevwan%2Ftproxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevwan%2Ftproxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevwan%2Ftproxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevwan%2Ftproxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kevwan","download_url":"https://codeload.github.com/kevwan/tproxy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253666035,"owners_count":21944620,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["charles","connection","grpc","monitoring-tool","proxy","relay","tcp","tcpdump","wireshark"],"created_at":"2024-07-31T10:00:32.879Z","updated_at":"2025-05-13T19:14:28.508Z","avatar_url":"https://github.com/kevwan.png","language":"Go","readme":"# tproxy\n\n[English](readme.md) | 简体中文 | [日本語](readme-ja.md)\n\n[![Go](https://github.com/kevwan/tproxy/workflows/Go/badge.svg?branch=main)](https://github.com/kevwan/tproxy/actions)\n[![Go Report Card](https://goreportcard.com/badge/github.com/kevwan/tproxy)](https://goreportcard.com/report/github.com/kevwan/tproxy)\n[![Release](https://img.shields.io/github/v/release/kevwan/tproxy.svg?style=flat-square)](https://github.com/kevwan/tproxy)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n\u003ca href=\"https://www.buymeacoffee.com/kevwan\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png\" alt=\"Buy Me A Coffee\" style=\"height: 60px !important;width: 217px !important;\" \u003e\u003c/a\u003e\n\n## 为啥写这个工具\n\n当我在做后端开发或者写 [go-zero](https://github.com/zeromicro/go-zero) 的时候，经常会需要监控网络连接，分析请求内容。比如：\n1. 分析 gRPC 连接何时连接、何时重连\n2. 分析 MySQL 连接池，当前多少连接，连接的生命周期是什么策略\n3. 也可以用来观察和分析任何 TCP 连接\n\n## 安装\n\n```shell\n$ GOPROXY=https://goproxy.cn/,direct go install github.com/kevwan/tproxy@latest\n```\n\n或者使用 docker 镜像：\n\n```shell\n$ docker run --rm -it -p \u003clisten-port\u003e:\u003clisten-port\u003e -p \u003cremote-port\u003e:\u003cremote-port\u003e kevinwan/tproxy:v1 tproxy -l 0.0.0.0 -p \u003clisten-port\u003e -r host.docker.internal:\u003cremote-port\u003e\n```\n\narm64 系统:\n\n```shell\n$ docker run --rm -it -p \u003clisten-port\u003e:\u003clisten-port\u003e -p \u003cremote-port\u003e:\u003cremote-port\u003e kevinwan/tproxy:v1-arm64 tproxy -l 0.0.0.0 -p \u003clisten-port\u003e -r host.docker.internal:\u003cremote-port\u003e\n```\n\nWindows:\n\n```shell\n$ scoop install tproxy\n```\n\n## 用法\n\n```shell\n$ tproxy --help\nUsage of tproxy:\n  -d duration\n    \tthe delay to relay packets\n  -down int\n    \tDownward speed limit(bytes/second)\n  -l string\n    \tLocal address to listen on (default \"localhost\")\n  -p int\n    \tLocal port to listen on, default to pick a random port\n  -q\tQuiet mode, only prints connection open/close and stats, default false\n  -r string\n    \tRemote address (host:port) to connect\n  -s\tEnable statistics\n  -t string\n    \tThe type of protocol, currently support http2, grpc, redis and mongodb\n  -up int\n    \tUpward speed limit(bytes/second)\n```\n\n## 示例\n\n### 分析 gRPC 连接\n\n```shell\n$ tproxy -p 8088 -r localhost:8081 -t grpc -d 100ms\n```\n\n- 侦听在 localhost 和 8088 端口\n- 重定向请求到 `localhost:8081`\n- 识别数据包格式为 gRPC\n- 数据包延迟100毫秒\n\n\u003cimg width=\"579\" alt=\"image\" src=\"https://user-images.githubusercontent.com/1918356/181794530-5b25f75f-0c1a-4477-8021-56946903830a.png\"\u003e\n\n### 分析 MySQL 连接\n\n```shell\n$ tproxy -p 3307 -r localhost:3306\n```\n\n\u003cimg width=\"600\" alt=\"image\" src=\"https://user-images.githubusercontent.com/1918356/173970130-944e4265-8ba6-4d2e-b091-1f6a5de81070.png\"\u003e\n\n### 查看网络状况（重传率和RTT）\n\n```shell\n$ tproxy -p 3307 -r remotehost:3306 -s -q\n```\n\n\u003cimg width=\"548\" alt=\"image\" src=\"https://user-images.githubusercontent.com/1918356/180252614-7cf4d1f9-9ba8-4aa4-a964-6f37cf991749.png\"\u003e\n\n### 查看连接池（总连接数、最大并发连接数、最长生命周期等）\n\n```shell\n$ tproxy -p 3307 -r :3306 -s -q\n```\n\n\u003cimg width=\"404\" alt=\"image\" src=\"https://user-images.githubusercontent.com/1918356/236633144-9136e415-5763-4051-8c59-78ac363229ac.png\"\u003e\n\n## 欢迎 star！⭐\n\n如果你正在使用或者觉得这个项目对你有帮助，请 **star** 支持，感谢！\n","funding_links":["https://github.com/sponsors/kevwan","https://www.buymeacoffee.com/kevwan"],"categories":["Go","语言资源库","抓包工具","\u003ca name=\"networking\"\u003e\u003c/a\u003eNetworking"],"sub_categories":["go"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevwan%2Ftproxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkevwan%2Ftproxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevwan%2Ftproxy/lists"}