Fix rsync: Use real rsync subprocess instead of in-process handler
In-process RsyncHandler couldn't match openrsync protocol 29 flow after version exchange. Changed handle_rsync_exec() to use handle_interactive_exec() (spawning real rsync --server subprocess), same approach as SCP handler. All file sizes (5MB, 20MB, 50MB, 100MB) successfully transferred with MD5 verification passing. Transfer speed ~712 KB/s limited by AES-256-CTR encryption overhead.
This commit is contained in:
58
AGENTS.md
58
AGENTS.md
@@ -1178,8 +1178,62 @@ markbase-core/src/ssh_server/
|
||||
- SCP 传输日志:/tmp/scp_test_*.txt
|
||||
- SSH server 日志:/private/tmp/markbase_ssh_scp_fix.log
|
||||
|
||||
## SSH Phase 16 Final: Rsync subprocess 模式修复完成(2026-06-17)⭐⭐⭐⭐⭐
|
||||
|
||||
**完成时间**:约 1 小时(调试)+ 测试
|
||||
**修改文件**:3 个
|
||||
|
||||
### 问题诊断 ⭐⭐⭐⭐⭐
|
||||
|
||||
**问题**:in-process RsyncHandler 在协议 29(openrsync)下版本协商后客户端无后续数据,30 秒超时断开
|
||||
|
||||
**根本原因**:
|
||||
1. ❌ in-process 状态机与真实 rsync 协议存在不匹配(token 编码 vs RSYNCDONE 标记)
|
||||
2. ❌ 协议 29 使用 raw I/O 而非 multiplex I/O,handler 状态机未完全对齐
|
||||
3. ❌ filter/exclude 列表交换缺失(rsync protocol >= 29 要求)
|
||||
|
||||
### 修复内容 ⭐⭐⭐⭐⭐
|
||||
|
||||
**决策**:使用真实 rsync 子进程替代 in-process handler
|
||||
|
||||
1. **channel.rs**:`handle_rsync_exec()` 改为调用 `handle_interactive_exec()`(与 SCP 相同模式)
|
||||
- 通过 `sh -c "rsync --server ..."` 启动真实 rsync 进程
|
||||
- 使用 stdin/stdout/stderr 管道 + poll() 处理 I/O
|
||||
- 保留 `RsyncHandler` 结构体但不使用(in-process 代码保留待后续参考)
|
||||
|
||||
### 测试验证 ⭐⭐⭐⭐⭐
|
||||
|
||||
**所有文件大小成功上传 + MD5 校验一致**:
|
||||
| 文件大小 | 传输时间 | 速度 | 完整性 |
|
||||
|---------|---------|------|--------|
|
||||
| 5MB | 7.3s | 717 KB/s | ✅ MD5 匹配 |
|
||||
| 20MB | 29.4s | 714 KB/s | ✅ MD5 匹配 |
|
||||
| 50MB | 73.6s | 712 KB/s | ✅ MD5 匹配 |
|
||||
| 100MB | 2m27s | 712 KB/s | ✅ MD5 匹配 |
|
||||
|
||||
**关键发现**:传输速度约 712-717 KB/s,受 AES-256-CTR 加密/解密性能限制
|
||||
|
||||
**子进程生命周期**:
|
||||
- 子进程正常退出(exit status 0)
|
||||
- 服务端发送 `SSH_MSG_CHANNEL_EOF` + `SSH_MSG_CHANNEL_CLOSE`
|
||||
- 客户端返回 `SSH_MSG_CHANNEL_CLOSE`
|
||||
- 会话正常结束
|
||||
|
||||
### 相关文件
|
||||
|
||||
**修改文件**:
|
||||
```
|
||||
markbase-core/src/ssh_server/channel.rs(handle_rsync_exec → handle_interactive_exec)
|
||||
```
|
||||
|
||||
### Git 推送状态 ⭐⭐⭐⭐⭐
|
||||
|
||||
**推送到两个 repo**:
|
||||
- ✅ m5max128gitea.momentry.ddns.net/admin/markbase.git
|
||||
- ✅ m4minigitea.momentry.ddns.net/warren/markbase.git
|
||||
|
||||
---
|
||||
|
||||
**最后更新**:2026-06-17 13:59
|
||||
**版本**:1.11(SSH Phase 15 Window Control 完成 + rsync/SCP 大文件传输成功)
|
||||
**最后更新**:2026-06-17 22:00
|
||||
**版本**:1.12(SSH Phase 16 Final: Rsync 子进程模式完成)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user