文章目录仓库说明rstcpcli目录安装直接下载源码编译子命令一览使用示例1. TCP Ping2. HTTP 客户端3. 文件下载4. 路由追踪5. 端口扫描6. DNS 诊断7. TLS 证书诊断8. WebSocket 测试9. UDP 探测10. 带宽测速11. 正向代理12. 反向代理13. TCP 隧道14. ACME 证书注册15. 服务模式构建本地构建Gitea Actions项目架构核心依赖License仓库说明国内仓库使用 https://git.t2be.cn/aspnmy/rstcpcli 这个是我自己的代码仓库主要用于内网设备拉取不允许外部用户注册但是公开项目可以拉取github镜像仓库 https://github.com/aspnmy/rstcpcli 这个是我的GitHub仓库用于分享代码方向先推 git.t2be.cn 不定时推 https://github.com/aspnmy/rstcpcli两个仓库如果有代码出入 请用代码助手分开分析业务侧重方向可能不一样rstcpcli新一代基础网络工具 — Rust 实现替代curlwgettcpingtraceroutenmapopenssl s_clientnslookup等一众网络工具。rstcpcli是一个用 Rust 编写的一体化网络工具集 TCP/UDP 探测、HTTP 客户端、文件下载、路由追踪、端口扫描、TLS 证书诊断、DNS 查询、带宽测速、正反向代理、TCP 隧道、ACME 证书注册于一身并支持以 MCP 协议或 REST API 模式运行服务端。目录安装子命令一览使用示例TCP PingHTTP 客户端文件下载路由追踪端口扫描DNS 诊断TLS 证书诊断WebSocket 测试UDP 探测带宽测速正向代理反向代理TCP 隧道ACME 证书注册服务模式构建项目架构License安装直接下载从 Releases 下载对应平台的二进制平台下载Linux x86_64rstcpcli-v0.2.1-linux.tar.gzWindows x86_64rstcpcli-v0.2.1-win.zip源码编译gitclone https://github.com/aspnmy/rstcpcli.git-brstcpclicdrstcpclicargobuild--release# 如需 ACME 证书注册功能依赖 acme-libcargobuild--release--featuresacme子命令一览命令分类说明替代目标ping探测TCP 端口探测 延迟测量tcpinghttp探测全能 HTTP 客户端curldownload探测全能文件下载wgetws探测WebSocket 连接测试—udp探测UDP 数据收发测试—trace诊断路由追踪 (每跳延迟)traceroute / tracertscan诊断端口扫描nmap (基础)cert诊断SSL/TLS 证书诊断openssl s_clientdns诊断DNS 记录查询nslookup / digspeedtest诊断带宽测速 (C/S 模式)iperfforward网关正向代理—reverse网关反向代理 负载均衡nginx / haproxy (基础)tunnel网关TCP 隧道 (端口转发)ssh -Lacme证书ACME 证书自动注册certbot / acme.sh (基础)server服务MCP 协议 / REST API 服务模式—使用示例1. TCP Ping# 基本探测 (4 次)rstcpclipingexample.com80# 持续探测rstcpcliping-cexample.com443# 自定义次数、间隔、超时rstcpcliping-n10-i0.5-w1example.com443# 显示时间戳rstcpcliping-texample.com4432. HTTP 客户端# GET 请求rstcpcli http https://api.example.com/users# POST JSONrstcpcli http-XPOST-HContent-Type: application/json-d{name:test}https://api.example.com/users# 输出响应头rstcpcli http-ihttps://example.com# 跟随重定向rstcpcli http-Lhttps://httpbin.org/redirect/3# 跳过证书验证rstcpcli http-khttps://self-signed.example.com# 输出到文件rstcpcli http-ooutput.json https://api.example.com/data# JSON 格式输出rstcpcli http--jsonhttps://api.example.com/health# 静默模式仅输出响应体rstcpcli http-shttps://example.com3. 文件下载# 基本下载rstcpcli download https://example.com/file.zip# 指定输出路径rstcpcli download-omyfile.zip https://example.com/file.zip# 指定输出目录rstcpcli download-P./downloads/ https://example.com/file.zip# 断点续传rstcpcli download-chttps://example.com/large-file.iso# 显示进度条rstcpcli download--progresshttps://example.com/large-file.iso# 限速下载rstcpcli download --limit-rate 500K https://example.com/file.zip4. 路由追踪# 基本追踪rstcpcli trace example.com# 指定端口和最大跳数rstcpcli trace-p443-m30example.com# 不解析主机名rstcpcli trace-n10.0.0.15. 端口扫描# 扫描指定端口rstcpcli scan example.com22,80,443,8080# 扫描端口范围rstcpcli scan example.com1-1000# 扫描 Top 1000 常用端口rstcpcli scan example.com --top-ports# 调整并发数和超时rstcpcli scan--concurrent200-w1example.com1-655356. DNS 诊断# 查询全部记录类型rstcpcli dns example.com# 查询特定记录类型rstcpcli dns--typeA example.com rstcpcli dns--typeMX example.com rstcpcli dns--typeTXT example.com# 指定 DNS 服务器rstcpcli dns--server8.8.8.8 example.com# 多服务器对比rstcpcli dns--server8.8.8.8,1.1.1.1--compareexample.com7. TLS 证书诊断# 基本诊断rstcpcli cert example.com# 指定端口rstcpcli cert-p8443example.com# 检查 OCSP 撤销状态rstcpcli cert--ocspexample.com# 输出完整证书链rstcpcli cert--chainexample.com8. WebSocket 测试# 连接测试rstcpcli ws wss://echo.websocket.org# 自定义超时和请求头rstcpcli ws-w10-HOrigin: https://example.comwss://stream.example.com# UDP 探测rstcpcli udp example.com53rstcpcli udp-n10-l64example.com539. UDP 探测rstcpcli udp example.com53rstcpcli udp-n10-l64-i0.5example.com5310. 带宽测速# 启动服务端rstcpcli speedtest server--listen:5201# 启动客户端rstcpcli speedtest client--target192.168.1.100:5201--duration3011. 正向代理# 转发本地 8080 到目标rstcpcli forward--listen:8080--targethttps://internal.example.com# 设置连接超时rstcpcli forward--listen:8080--targetexample.com:80--timeout1012. 反向代理# 基本负载均衡rstcpcli reverse--listen:80--backends192.168.1.1:80,192.168.1.2:80# least-conn 算法 健康检查rstcpcli reverse--listen:80--backends10.0.0.1:80,10.0.0.2:80--lbleast-conn --health-check13. TCP 隧道# 本地 3306 转发到远程 MySQLrstcpcli tunnel :3306 db.internal:330614. ACME 证书注册需要--features acme编译。# 签发证书 (http-01)rstcpcli acme issue example.com--emailadminexample.com# DNS-01 验证rstcpcli acme issue example.com--emailadminexample.com--challengedns-01# 续期证书rstcpcli acme renew example.com# 列出已注册证书rstcpcli acme list15. 服务模式# 启动 MCP 协议服务rstcpcli server--protocolmcp# 启动 REST API 服务rstcpcli server--protocolapi--listen0.0.0.0:8765# 同时启动 MCP APIrstcpcli server--protocolboth--listen0.0.0.0:8765API 模式下提供以下端点端点方法说明/api/v1/pingPOSTTCP Ping/api/v1/httpPOSTHTTP 请求/api/v1/dnsPOSTDNS 查询/api/v1/certPOST证书诊断/api/v1/scanPOST端口扫描/api/v1/webhook/:sourcePOSTWebhook 桥接构建本地构建# 标准构建cargobuild--release# 包含 ACME 功能cargobuild--release--featuresacme# 交叉编译 (Linux → Windows)cargobuild--release--targetx86_64-pc-windows-gnu# 交叉编译 (Windows → Linux)cargobuild--release--targetx86_64-unknown-linux-gnuGitea Actions项目已配置 Gitea Actions workflow (.gitea/workflows/rust-multiarch.yml)推送后自动构建多平台二进制。项目架构rstcpcli/ ├── src/ │ ├── main.rs # CLI 入口 clap 子命令定义 │ ├── probe/ # 探测模块 │ │ ├── tcp.rs # TCP Ping │ │ ├── http.rs # HTTP 客户端 │ │ ├── download.rs # 文件下载 │ │ ├── udp.rs # UDP 探测 │ │ └── ws.rs # WebSocket 测试 │ ├── diagnose/ # 诊断模块 │ │ ├── trace.rs # 路由追踪 │ │ ├── scan.rs # 端口扫描 │ │ ├── cert.rs # TLS 证书诊断 │ │ ├── dns.rs # DNS 查询 │ │ └── speedtest.rs # 带宽测速 │ ├── gateway/ # 网关模块 │ │ ├── forward.rs # 正向代理 │ │ ├── reverse.rs # 反向代理 负载均衡 │ │ └── tunnel.rs # TCP 隧道 │ ├── acme/ # ACME 证书注册 (optional) │ ├── server/ # 服务模式 │ │ ├── mcp.rs # MCP 协议实现 │ │ └── api.rs # REST API 端点 │ ├── bridge/ # Webhook 桥接 │ ├── output.rs # 输出格式化 (进度条/JSON/时间戳) │ ├── cookie.rs # Cookie 管理 │ ├── resolve.rs # DNS 解析辅助 │ ├── stats.rs # 统计信息 │ └── util.rs # 通用工具函数 ├── tests/ # 集成测试 │ ├── probe_tests.rs │ ├── diagnose_tests.rs │ ├── gateway_tests.rs │ └── integration_tests.rs ├── Cargo.toml ├── DESIGN.md # 设计文档 └── README.md核心依赖依赖用途clapCLI 参数解析tokio异步运行时reqwestHTTP 客户端 (支持 socks/gzip/brotli/http2/rustls)tokio-tungsteniteWebSocketrustls webpki-rootsTLS 纯 Rust 实现hickory-resolverDNS 解析x509-parser rcgen证书解析/生成axumREST API 服务端acme-lib (optional)ACME 证书注册scraperHTML 解析chrono serde时间处理 序列化socket2原始 socket 操作LicenseGNU General Public License v2.0 — 详见 LICENSE。