Files
rust-work/INCUBATOR.md
绝尘 11203f036f 新增: MySQL/SSH 代理工具
- mysql-proxy: MySQL HTTP 代理,连接池复用
- ssh-proxy: SSH HTTP 代理,会话复用
- mysql-cli: 轻量级 MySQL CLI 工具

功能特性:
- 延迟初始化,启动快
- CLI 和 HTTP API 双模式
- 请求日志支持
- 错误友好提示
- JSON 极简输出格式
2026-03-19 14:03:12 +08:00

101 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 代理工具孵化记录
> 状态:孵化中 | 更新2026-03-19
---
## 工具列表
| 工具 | 端口 | 状态 | 项目目录 |
|------|------|------|----------|
| mysql-proxy | 3307 | 可用 | `mysql-proxy` |
| ssh-proxy | 3308 | 可用 | `ssh-proxy` |
---
## 新增功能
### 2026-03-19
1. **请求日志** (P0)
- 设置环境变量启用:`MYSQL_PROXY_LOG` / `SSH_PROXY_LOG`
- 日志格式JSON每行一条记录
2. **ssh-proxy CLI JSON 输出** (P1)
```bash
ssh-proxy exec -n flux_dev -c "docker ps" -F json
```
3. **ssh-proxy 动态添加服务器** (P2)
```bash
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"}'
```
4. **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 推荐使用方式
```bash
# MySQL 查询 (AI 友好)
curl -X POST http://127.0.0.1:3307/query \
-H "Content-Type: application/json" \
-d '{"conn":"flux_dev","sql":"SELECT VERSION()"}'
# SSH 执行 (AI 友好)
curl -X POST http://127.0.0.1:3308/exec \
-H "Content-Type: application/json" \
-d '{"server":"flux_dev","command":"docker ps"}'
```
**优势**
- JSON 格式,易于解析
- 会话复用,响应快
- 错误提示友好
---
## 已知问题
### ssh-proxy
1. **ssh2 不支持 ed25519 密钥**
- 错误: `[Session(-19)] Callback returned error`
- 解决: 使用 PEM 格式 RSA 密钥
```bash
ssh-keygen -t rsa -b 2048 -f ~/.ssh/id_rsa_pem -m PEM -N ""
```
### mysql-proxy
- 暂无
---
## 待优化
*由 AI 在实际使用过程中根据遇到的问题填写*