Feature: Transfer a Linux host to another master
The Linux client ignored COMMAND_ASSIGN_MASTER, so a host could not be moved to a different controller the way the Windows client allows. The payload is host:port:days:shine[:transport]; the parsing, record encoding and address application live in a shared header so a macOS client can reuse them unchanged. An assignment only rewrites the connection target. The running session stays up and the next reconnect - a dropped link or a restart - goes to the new master, matching the Windows behaviour. The target and its expiry are stored in a single "transfer" config key, while the address the process started with is kept in memory only: the config's own master/port entries are never overwritten, so restarting mid-transfer still has the original to fall back to. When the expiry passes the client restores that address, clears the key and reconnects. Malformed payloads and zero-day assignments are rejected outright. The way back depends on an expiry time, so honouring a permanent move would strand a host on an address it cannot leave. Give the POSIX connect() a timeout as well (non-blocking connect plus poll, 10 seconds). A blocking connect waiting for SYN retransmission froze the main loop for about two minutes when the port was filtered, delaying both heartbeats and the expiry restore. The transfer state is initialised after daemonize() for the same reason it is logged: logging before the double fork can leave the child deadlocked on the logger mutex. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
0b22d5e870
commit
3b3aed50e5
4 files changed
+346
-6
No files matched your search
@@ -29,6 +29,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`,重连生效;到期自动回原主控。主机分享未实现) |
|
||||
| 配置持久化 | `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`(服务端放开门禁,客户端协议本已实现) |
|
||||
|
||||
@@ -211,6 +212,22 @@ Windows 客户端的同名命令没有摘要(走内存加载器/更新器)
|
||||
|
||||
回滚:把 `ghost.old` 拷回 `ghost` 并重启即可(它会在下次升级时被覆盖)。
|
||||
|
||||
## 主机转移
|
||||
|
||||
服务端选中一台主机后点「转移主机」,选目标主控和有效天数,客户端会:
|
||||
|
||||
1. 把目标写进 `~/.config/ghost/config.conf` 的 `transfer` 键(`ip:port:transport:shine:valid_to`);
|
||||
2. **不立刻断开**,当前连接照常维持,下一次重连(断线重连、客户端重启)才连到新主控;
|
||||
3. 过了有效天数自动回到转移前的原主控——原地址只记在内存里(启动参数或编译期默认),
|
||||
不写回配置,所以重启后仍然有效。
|
||||
|
||||
注意事项:
|
||||
|
||||
- 目标是永久转移(天数填 0)时客户端会拒绝,避免把主机改到一个不可达的地址后无法回退;
|
||||
- 有效期内重复下发会被忽略(与 Windows 客户端一致);
|
||||
- 转移期间切换传输方式(明文 / WS / WSS)会跟随服务端下发的 `transport` 段;
|
||||
- 只想把主机要回来,直接把 `transfer` 键清空并重启客户端即可。
|
||||
|
||||
## 常见问题
|
||||
|
||||
### Q: 远程桌面功能不工作
|
||||
@@ -313,6 +330,7 @@ loginctl show-session $(loginctl | grep $(whoami) | awk '{print $1}') -p Type
|
||||
| `PublicIP` | 公网 IP 缓存 | `1.2.3.4` |
|
||||
| `GeoLocation` | 地理位置缓存 | `北京市` |
|
||||
| `QualityLevel` | 屏幕质量等级 | `2` (Good / H264 1080P) |
|
||||
| `transfer` | 主机转移记录(空 = 未转移),见「主机转移」 | `1.2.3.4:443:6:0:1790000000` |
|
||||
|
||||
### 质量等级说明
|
||||
|
||||
|
||||
Reference in new issue
Block a user