Feature: transfer a Go-managed host to the MFC master from the web console
A Go-managed host cannot receive the client upgrade that only the MFC master can push. Transfer moves its main link there and brings it back after N days; MFC has no reason to return it. Transfer is not share: ASSIGN writes the target and drops the current connection, so the old master sees the host go offline and the new master gets a normal main link it can remote control and upgrade. While a transfer is live the client refuses a second transfer and any share, so no host is handed to a third master that expiry would orphan. Server: admin-only `transfer_device` WS command, COMMAND_ASSIGN_MASTER + SHARE_TYPE_YAMA_FOREVER as `host:port:days::transport\0`, byte-compatible with the MFC dialog. The transport segment is always present (YAMA_TRANSFER_TRANSPORT, default 0/TCP) because clients keep their current link when it is missing: a WSS-managed host would otherwise retry WSS against the MFC master's raw TCP port and never connect. The empty shine segment keeps the host's header encryption. The button only renders when `device_list.transfer` is present, which MFC never sends, so no MFC change is needed. devicehistory keeps transfer_to/transfer_until for the card badge and drops the marker on expiry or on a fresh login here. Client: KernelManager.cpp writes the registry and disconnects; ClientDll.cpp re-reads the registry at the top of every reconnect, so a mid-session transfer lands on the next round. Expiry is checked before every connect attempt as well as inside the heartbeat loop, so an unreachable target cannot pin the host to an expired address until a restart; restoring rebuilds the link captured on entry (address, header encryption, transport). linux/main.cpp applies the transfer on the main loop and restores the captured endpoint at expiry; Android does the same; macOS has neither share nor transfer.
This commit is contained in:
1 parent
b466f568ab
commit
63c7cdf588
18 files changed
+1024
-177
No files matched your search
+10
-8
@@ -30,7 +30,7 @@ SimpleRemoter 的 Linux 客户端,支持远程桌面、远程终端、文件
|
||||
| 屏幕预览(缩略图) | `ScreenPreview.cpp` | `client/ScreenPreview.cpp` | ✅ 完整(X11 抓屏 → 缩放 → 原始 BGRA 上报,由服务端统一编码 JPEG;双击预览、列表缩略图、MCP `get_screenshot` 均可用。无 `DISPLAY` 时不声明能力位,服务端不会发请求) |
|
||||
| V2 文件传输 | `FileTransferV2.h` | `file_upload.h` | ✅ 服务端↔Linux(含 MCP `upload_file`/`download_file`:发送完成包带流式 SHA-256,路径不存在/无权限回 `TOKEN_DOWNLOAD_ERROR`) |
|
||||
| C2C 文件接收 | `FileTransferV2.h` | `file_upload.h` | ✅ Windows/MCP → Linux(目标目录由服务端 `dst_dir` 指定,落盘后回执) |
|
||||
| 主机转移 | `common/host_transfer.h` + main.cpp | `KernelManager.cpp` | ✅ 完整(`COMMAND_ASSIGN_MASTER`,下发后立即另起一条连接,主连接重连时生效;到期自动回原主控并收掉那条连接) |
|
||||
| 主机转移 | `common/host_transfer.h` + main.cpp | `KernelManager.cpp` | ✅ 完整(`COMMAND_ASSIGN_MASTER`,**真的转移**:收包后立刻断开原主控、主连接连到新主控,旧主控上这台主机随即离线;新主控可正常远控/升级,但不能再转移或分享它;到期自动回原主控) |
|
||||
| 主机分享 | `common/host_share.h` + main.cpp | `KernelManager.cpp` / `ClientDll.cpp` | ✅ 完整(每条分享记录 fork 一个 `--share` 子进程,主连接不受影响;取消分享立即断开,重启自动恢复) |
|
||||
| 配置持久化 | `LinuxConfig` | INI 文件 | ✅ 完整 |
|
||||
| MCP 远程管理 | 复用 `SystemManager.h` / `PTYHandler.h` / `ScreenHandler.h` | 服务端 MCP | ✅ 档 1:`kill_process`、`exec_command`、`terminal_open/exec/close`、`remote_open/close/mouse/keyboard/clipboard`(服务端放开门禁,客户端协议本已实现) |
|
||||
@@ -219,21 +219,23 @@ Windows 客户端的同名命令没有摘要(走内存加载器/更新器)
|
||||
服务端选中一台主机后点「转移主机」,选目标主控和有效天数,客户端会:
|
||||
|
||||
1. 把目标写进 `~/.config/ghost/config.conf` 的 `transfer` 键(`ip:port:transport:shine:valid_to`);
|
||||
2. **立即另起一条通往新主控的连接**(与分享同一个 fork+exec 机制),新主控马上就能看到
|
||||
这台主机上线;它与老主控之间的主连接原样保留,不会断开;
|
||||
3. 下一次重连(断线重连、客户端重启)时主连接才搬到新主控,那条临时连接随之消失;
|
||||
2. **立刻断开当前主控**,主连接改连新主控——转移是把这条主连接搬走,不是另开一条。
|
||||
老主控上这台主机随即离线,`--share` 那种旁路连接在这里是不对的:新主控拿到的
|
||||
会是一条不能升级、也不真正属于它的连接;
|
||||
3. 新主控从此可以像自己的主机一样操作它:远控、文件、终端、**升级程序**都正常;
|
||||
4. 过了有效天数自动回到转移前的原主控——原地址只记在内存里(启动参数或编译期默认),
|
||||
不写回配置,所以重启后仍然有效;到期时那条临时连接一并收掉。
|
||||
不写回配置,所以重启后仍然有效;到期时按原地址重连。
|
||||
|
||||
第 2 步与 Windows 客户端现有的实际行为一致(`KernelManager.cpp` 的转移分支会贯穿到分享
|
||||
分支、额外起一个 shared 实例);差别只在到期处理:Windows 那条连接要等进程重启才消失。
|
||||
转移期间(`now <= valid_to`)客户端会拒绝两件事:**再次转移**和**分享**。前者是为了防止
|
||||
主机被 B 转到 C、到期却按 A 复原,中间那一跳成为谁也不认的孤儿;后者是因为主机此刻只
|
||||
连着新主控,新主控无权再把它分出去。两条都会回一条消息进服务端消息栏,不会静默丢弃。
|
||||
|
||||
注意事项:
|
||||
|
||||
- 目标是永久转移(天数填 0)时客户端会拒绝,避免把主机改到一个不可达的地址后无法回退;
|
||||
- 有效期内重复下发会被忽略(与 Windows 客户端一致);
|
||||
- 转移期间切换传输方式(明文 / WS / WSS)会跟随服务端下发的 `transport` 段;
|
||||
- 「取消分享」不会影响转移建立的临时连接;
|
||||
- 「取消分享」只收掉分享子进程,撤销不了转移;
|
||||
- 只想把主机要回来,直接把 `transfer` 键清空并重启客户端即可。
|
||||
|
||||
## 主机分享
|
||||
|
||||
Reference in new issue
Block a user