3.9 KiB
3.9 KiB
代理工具孵化记录
状态:孵化中 | 更新:2026-03-24
工具列表
| 工具 | 端口 | 状态 | 项目目录 |
|---|---|---|---|
| mysql-proxy | 3307 | 可用 | mysql-proxy |
| ssh-proxy | 3308 | 可用 | ssh-proxy |
| mongo-proxy | 3309 | 可用 | mongo-proxy |
| redis-proxy | 3310 | 可用 | redis-proxy |
新增功能
2026-03-24
-
redis-proxy (新工具)
- Redis HTTP 代理,会话复用
- 支持 run/get/set/del/keys/info
- CLI 模式 + HTTP API 双模式
- 连接: flux_dev
-
mongo-proxy (新工具)
- MongoDB HTTP 代理,会话复用
- 支持 find/insert/update/delete/aggregate/count
- CLI 模式 + HTTP API 双模式
- 连接: suke_dev, suke_pro
2026-03-21
-
ssh-proxy 断线重连 (P0)
- exec 方法检测到会话失效时自动清除并重连
- 修复 get_or_create_session TOCTOU 竞态条件
-
日志智能分级 (P1)
- 慢请求告警: >3s WARN, >10s ERROR
- 退出码识别: exitCode 0/1/-1 视为正常,>=2 或 127 标记 ERROR
- UTF-8 安全截断
-
服务器配置扩展 (P1)
- 新增 server1 (一号机)、server2 (二号机)、ai_sg (新加坡 AI 机器)
- 共 5 台服务器
-
代码优化 (P2)
- 移除未使用的 async-trait 依赖
- 用 time crate 替换 40 行手写日期计算
- 清理未使用字段
2026-03-20
- ssh-proxy russh 迁移 (P0)
- 从 ssh2 迁移到 russh,原生支持 ed25519 密钥
- 修复了 ed25519 认证失败问题
- 使用 async/await 原生 API
2026-03-19
-
请求日志 (P0)
- 设置环境变量启用:
MYSQL_PROXY_LOG/SSH_PROXY_LOG - 日志格式:JSON,每行一条记录
- 设置环境变量启用:
-
ssh-proxy CLI JSON 输出 (P1)
ssh-proxy exec -n flux_dev -c "docker ps" -F json -
ssh-proxy 动态添加服务器 (P2)
ssh-proxy add-server -n myserver -H 192.168.1.100 -u root -p password # 或 API curl -X POST http://127.0.0.1:3308/servers/add \ -H "Content-Type: application/json" \ -d '{"name":"myserver","host":"192.168.1.100","user":"root","password":"secret"}' -
API 错误友好提示
- 错误时返回
usage字段,引导正确使用
- 错误时返回
2026-03-18
- mysql-proxy 动态添加连接 API
- ssh-proxy Windows 路径修复
- ssh-proxy 读取错误日志修复
实测性能
| 操作 | 代理 | 直连 | 提升 |
|---|---|---|---|
| mysql 首次查询 | ~150ms | ~500ms | 3x |
| mysql 复用会话 | ~50ms | ~500ms | 10x |
| ssh 首次执行 | ~900ms | ~1500ms | 1.7x |
| ssh 复用会话 | ~100-200ms | ~1500ms | 7-15x |
AI 推荐使用方式
优先使用 CLI 模式,命令简洁
# MySQL 查询 (CLI 优先)
mysql-proxy cli -c flux_dev -e "SELECT VERSION()"
# MySQL JSON 输出
mysql-proxy cli -c flux_dev -e "SHOW TABLES" -F json
# MySQL 执行 DML
mysql-proxy cli -c flux_dev -e "UPDATE users SET status=1" -x
# SSH 执行 (CLI 优先)
ssh-proxy exec -n flux_dev -c "docker ps"
# SSH JSON 输出
ssh-proxy exec -n flux_dev -c "docker ps" -F json
# 列出服务器
ssh-proxy servers
mysql-proxy connections
HTTP API (复杂场景):
# MySQL
curl -X POST http://127.0.0.1:3307/query \
-H "Content-Type: application/json" \
-d '{"conn":"flux_dev","sql":"SELECT VERSION()"}'
# SSH
curl -X POST http://127.0.0.1:3308/exec \
-H "Content-Type: application/json" \
-d '{"server":"flux_dev","command":"docker ps"}'
降级方案 (代理不可用):
mysql -h<host> -u<user> -p<password> -D<database> -e "<SQL>"
ssh <user>@<host> "<command>"
优势:
- CLI 命令简洁,AI 友好
- JSON 格式输出,易于解析
- 会话复用,响应快
- 错误提示友好
已知问题
ssh-proxy
- 暂无 (ed25519 已支持)
mysql-proxy
- 暂无
待优化
由 AI 在实际使用过程中根据遇到的问题填写