|
2 هفته پیش | |
---|---|---|
.. | ||
internal | 2 هفته پیش | |
templates | 2 هفته پیش | |
README.md | 2 هفته پیش | |
USAGE.md | 2 هفته پیش | |
config.yaml | 2 هفته پیش | |
go.mod | 2 هفته پیش | |
go.sum | 2 هفته پیش | |
main.go | 2 هفته پیش | |
run.bat | 2 هفته پیش | |
run.sh | 2 هفته پیش |
这是一个用Go语言重写的Clash节点测速工具,相比Node.js版本具有更好的性能和更准确的测速结果。
# Windows
# 从 https://golang.org/dl/ 下载并安装
# Linux/Mac
wget https://go.dev/dl/go1.21.0.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.21.0.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
CREATE DATABASE clash_speed_test CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
编辑 config.yaml
文件:
database:
host: "localhost"
port: 3306
username: "your_username"
password: "your_password"
database: "clash_speed_test"
speed:
test_urls:
- "https://www.google.com"
- "https://www.youtube.com"
- "https://www.github.com"
timeout: 10s
concurrency: 5
interval: 5m
Windows:
run.bat
Linux/Mac:
chmod +x run.sh
./run.sh
手动运行:
go mod tidy
go build -o clash-speed-test .
./clash-speed-test
GET /api/results
GET /api/nodes
POST /api/test
对于Shadowsocks、Vmess、Trojan等高级代理,需要:
支持的本地代理端口:
# 数据库配置
export DB_HOST=localhost
export DB_PORT=3306
export DB_USER=root
export DB_PASS=password
export DB_NAME=clash_speed_test
# 测速配置
export SPEED_TEST_TIMEOUT=10s
export SPEED_TEST_INTERVAL=5m
export SPEED_TEST_CONCURRENCY=5
# 服务器配置
export PORT=3000
server.port
: HTTP服务器端口server.host
: HTTP服务器地址database.*
: 数据库连接配置speed.test_urls
: 测试URL列表speed.timeout
: 测试超时时间speed.concurrency
: 并发测试数量speed.interval
: 自动测试间隔speed.test_on_start
: 启动时是否立即测试log.level
: 日志级别log.file
: 日志文件路径根据网络环境调整 speed.concurrency
参数:
根据节点响应速度调整 speed.timeout
参数:
选择响应稳定的测试URL:
go-speed-test/
├── main.go # 主程序入口
├── config.yaml # 配置文件
├── go.mod # Go模块文件
├── go.sum # 依赖校验文件
├── internal/
│ ├── api/ # API接口
│ ├── config/ # 配置管理
│ ├── core/ # 核心逻辑
│ ├── database/ # 数据库操作
│ └── logger/ # 日志管理
├── templates/ # HTML模板
├── run.bat # Windows启动脚本
└── run.sh # Linux/Mac启动脚本
internal/core/
中添加核心逻辑internal/api/
中添加API接口internal/database/
中添加数据模型MIT License