确保您的系统已安装:
-- 创建数据库
CREATE DATABASE clash_speed_test CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- 创建用户(可选)
CREATE USER 'clash_user'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON clash_speed_test.* TO 'clash_user'@'localhost';
FLUSH PRIVILEGES;
编辑 config.yaml
文件:
database:
host: "localhost"
port: 3306
username: "root" # 或您创建的用户
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 run test_speed.go
更准确的测速:
更完善的代理支持:
更好的性能:
更健壮的错误处理:
speed:
timeout: 15s # 增加超时时间
concurrency: 3 # 减少并发数
interval: 10m # 增加测试间隔
speed:
test_urls:
- "https://www.google.com"
- "https://www.youtube.com"
- "https://www.github.com"
- "https://httpbin.org/get" # 添加自定义URL
- "https://api.ipify.org" # IP检测服务
# 数据库配置
export DB_HOST=localhost
export DB_PORT=3306
export DB_USER=clash_user
export DB_PASS=your_password
export DB_NAME=clash_speed_test
# 测速配置
export SPEED_TEST_TIMEOUT=15s
export SPEED_TEST_INTERVAL=10m
export SPEED_TEST_CONCURRENCY=3
# 服务器配置
export PORT=3000
错误信息: 连接数据库失败: dial tcp: connect: connection refused
解决方案:
# 检查MySQL服务状态
sudo systemctl status mysql
# 启动MySQL服务
sudo systemctl start mysql
# 检查端口是否开放
netstat -tlnp | grep 3306
错误信息: 延迟测试失败: 所有测试URL都无法访问
解决方案:
错误信息: 无法通过本地代理测试节点
解决方案:
检查本地代理端口是否开放:
netstat -tlnp | grep 7890
netstat -tlnp | grep 7891
验证代理配置是否正确
尝试手动测试代理连接
错误信息: go: module lookup disabled by GOPROXY=off
解决方案:
# 设置Go代理
export GOPROXY=https://goproxy.cn,direct
# 或者使用官方代理
export GOPROXY=https://proxy.golang.org,direct
-- 优化MySQL配置
SET GLOBAL max_connections = 200;
SET GLOBAL innodb_buffer_pool_size = 1073741824; -- 1GB
程序会输出详细的日志信息:
定期清理旧的测试数据:
-- 删除30天前的测试结果
DELETE FROM test_results WHERE test_time < DATE_SUB(NOW(), INTERVAL 30 DAY);
-- 优化表
OPTIMIZE TABLE test_results;
监控关键指标:
在 internal/core/speed_tester.go
中添加新的测试方法:
func (st *SpeedTester) testNewProxyType(node database.Node) (*SpeedTestResult, error) {
// 实现新的代理类型测试逻辑
}
在 SpeedTestResult
结构体中添加新字段:
type SpeedTestResult struct {
// 现有字段...
NewMetric float64 `json:"new_metric"`
}
在配置文件中添加自定义测试URL:
speed:
test_urls:
- "https://your-custom-test-url.com"
如果遇到问题,请: