998c16edc5773fbeb9b28bc4e5bfe1cb342d2b96
94
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
998c16edc5 |
Feature: support camera streaming on Android hosts
Android 摄像头(COMMAND_WEBCAM)此前未实现。客户端用 Camera2 ImageReader 直接输出 JPEG(1280x720、8fps、按传感器方向摆正),第一帧到达时从 JPEG SOF 读出真实宽高再发 TOKEN_WEBCAM_BITMAPINFO(部分 HAL 会按方向物理旋转 导致宽高互换,以实际帧为准可避免服务端尺寸不符丢帧黑屏),之后每帧 [TOKEN_WEBCAM_DIB][isCompress=1][JPGD][JPEG]。 服务端视频对话框识别 JPGD FOURCC,用 libjpeg 直接解成 bottom-up BGR24; DrawDib 与「保存 AVI」两条路径都不用改,目标机也不需要安装 VFW 编解码器。 BITMAPINFO 的 biSizeImage 按 DWORD 对齐的 stride 计算。 注意:服务端不要引用 turbojpeg 的 tj* 符号——会拉进与 Debug 构建不兼容的 运行时,启动即 0xC0000005;解码统一走项目已在用的 jpeg_* API。 验证:模拟器虚拟相机出图,窗口标题 127.0.0.1 - Video 1280x720;关闭对话框 后 camera stopped,服务端稳定。 Model: deepseek-flash Co-Authored-By: Claude Code <noreply@anthropic.com> |
||
|
|
28c0c9a2a6 |
Feature: add file management to the Android client
Android 客户端此前没有文件管理:声明了 CLIENT_CAP_V2 却没有实现,主控的 文件管理对话框和 MCP 的 list_files/download_file/upload_file 对 APK 只会 超时。本次复用 Linux/macOS 已在用的 common/FileManager.h,只补平台差异: - 盘符模型:P=应用私有目录、I=内部存储、S/T/...=SD 卡与 U 盘;V2 上传 通过 FileTransferV2::SetPathMapper 复用同一套映射。 - 文件通道线上是 GBK。NDK 的 iconv 要 API 28,客户端 minSdk 是 21,改走 JNI -> Java Charset(NativeText.kt),严格模式失败原样透传。 - Android 11+ 引导开启「所有文件访问」;未授权时只挂 P: 并回一条提示。 API <=29 用运行时存储权限 + requestLegacyExternalStorage。 - 顺带实现 COMMAND_SEARCH_FILE(深度 32、1 万条),并让 MCP 的 list_files/download_file/upload_file/read_file 对 APK 开闸。 验证:arm64/armeabi 与模拟器 ABI 编译通过;模拟器上用 MCP 完成列盘、 列目录、下载、上传、中文文件名往返,GUI 文件管理器正常显示 P:/I:/S:。 Model: deepseek-flash Co-Authored-By: Claude Code <noreply@anthropic.com> |
||
|
|
06b93f7bdb |
Feat(client): complete the macOS feature set (phase 0 and 1)
Phase 0 makes implementations that already existed reachable. macOS now declares TERMINAL, SCREEN_CLIPBOARD, PROCESS and C2C_RECV_ACK; PROCESS is a new bit and Linux declares it too. SystemManager was dead code -- its constructor took a second argument and it did not derive IOCPManager, so the sub-connection skeleton could never instantiate it -- and now matches the createHandler/OnReceive contract, so COMMAND_SYSTEM really spawns a sub-connection (proc_listpids, SIGKILL). DataProcess always gets a NULL user, so main.mm keeps a g_pMainClient handle and the V2 C2C receiver finally answers TOKEN_C2C_RECV_RESULT. The server asks for SupportsTerminal() on MAC for exec_command / terminal_* and for SupportsProcess() for kill_process, so an old build gets "client is too old" instead of a command nobody answers; kToolPlatforms and mcp/tools.json follow. http_probe stays win/lnx: the terminal works on macOS, but the probe uses GNU-only base64 -w. Phase 1 is POSIX parity. ScreenPreview captures through CGDisplayCreateImage, scales and ships BGRX for the server to encode, and the capability is only declared when preflight or a real capture says the display is readable. ActivityHistory samples the frontmost layer-0 window once a second and prints the same records as Windows and Linux. COMMAND_SCREEN_KEYFRAME_REQ is now consumed by Linux (x264 IDR) and macOS (VideoToolbox force keyframe): the receive thread raises a flag, the capture thread -- which owns the encoder -- consumes it and puts it back if the frame never went out. The macOS quality level persists in NSUserDefaults because main.mm rewrites config.conf. Linux client and Debug x64 server rebuild green; check_platform_table PASS. Not built or run on a Mac. Co-Authored-By: deepseek-flash |
||
|
|
a25e89b220 |
Feat(client): report macOS runtime logs to the controller
macOS already handled COMMAND_QUERY_LOG and opened the sub-connection that sends TOKEN_REPORT_LOG, but the snapshot was always empty: macOS Mprintf went to NSLog/fprintf(stderr) and never through Logger, so the ring it dumps stayed empty and both the 运行日志 dialog and MCP get_client_log got nothing. macOS now writes Logger like Linux does, with enable=false so no second log file appears under ~/.config/ghost, and Logger mirrors each line to stderr, which main.mm already redirects to /tmp/ghost.log in daemon and App bundle mode. Prefix and timestamp match on both sides, so dialog and file can be compared line for line. main.mm logged its own lifecycle through NSLog, which never reaches the ring, so the lines people open the dialog for were missing; those calls now use Mprintf. The ObjC helpers (ScreenHandler/H264Encoder/InputHandler/Permissions) keep NSLog and stay file-only. POSIX reports one snapshot per connection, so reopening 运行日志 takes a fresh one; Windows keeps pushing every 3s. Verified with a WSL probe built with -D__APPLE__ (ring, incremental dump, stderr mirror), a MinGW probe for the _WIN32 branch, and a green Linux client rebuild. Not built or run on a real Mac. Co-Authored-By: deepseek-flash |
||
|
|
b743de6747 |
Feat(client): add TLS transport to the macOS client
macOS shares the Linux transport: TlsChannel.h now dispatches __APPLE__ to the OpenSSL implementation, so handshake, pinned trust anchor, reload and removal all come from client/TlsChannelLinux.cpp. Only the platform glue is new: ConfigDir() follows initConfigPaths (HOME, then getpwuid(), then /tmp; no XDG) so the anchor sits next to config.conf, and ExeDir() uses _NSGetExecutablePath. First connect stays plaintext. The operator turns TLS on from the online list: COMMAND_TLS_ENABLE carries the anchor PEM, COMMAND_TLS_DISABLE removes it. macos/main.mm saves the anchor, calls TlsReload() and only reconnects when the transport actually changed, so re-saving the same anchor does not drop a live session. RES_TLS is filled from TlsEnabled() and refreshed on every reconnect; fillLoginInfo clears szReserved first now, because AddReserved appends and it runs twice on a group change. CMake builds arm64 only (deployment target 11.0) and links Homebrew openssl@3 statically when libcrypto.a is present, so the binary carries no Homebrew path dependency. Not built or run on a Mac yet: the Apple branch was syntax-checked under WSL and the login refresh probe-tested; macos/README.txt has the build and verify steps. Co-Authored-By: deepseek-flash |
||
|
|
3d87ec6720 |
Fix(client): detach the receive thread instead of leaking one per connection
CloseHandle and SAFE_CLOSE_HANDLE are empty off Windows, so the POSIX receive thread is never released: nothing detaches it and nothing joins it. Every IOCPClient keeps one thread for good, and each screen, file, shell or log sub-connection constructs a fresh IOCPClient. Once the leak reaches RLIMIT_NPROC, pthread_create returns EAGAIN, std::thread throws, and OnServerReceiving's catch(...) swallows it: every command that spawns a worker goes quiet while COMMAND_SYSTEM keeps working. Observed on a Mac after six weeks: 2048 threads against a 1333 limit. Detach the thread right after creation so it is reclaimed when it returns; the destructor still waits on m_bWorkThread, so nothing else changes. Also log the pthread_create failure that used to be silent, and publish S_STOP as the very last write in WorkThreadProc: the destructor reads it as "thread is gone" and frees this, so the m_bIsRunning that used to follow it could land in freed memory. Two smaller fixes on the same sub-connection path: - common/sub_conn_thread.h never called SetDefaultProto, so sub-connects fell back to plaintext TCP whatever g_SETTINGS.protoType said: behind a reverse proxy the packet dies before the master (no [ConnAuth] on the server, only "waiting for ack timed out" on the client). Android did. - macos/main.mm and linux/main.cpp log the spawn before starting the worker and catch std::system_error, reporting e.code().value() rather than errno, which libc++/libstdc++ never set here. The macOS skeleton also reports ConnectServer failures and a null createHandler. Co-Authored-By: deepseek-flash |
||
|
|
9fadb58c76 |
Fix(client): rotate HELL header encoding across reconnects
A Release client drew one of the twelve HELL header encodings in the constructor and kept it for life. The Go fallback server latches a type from the first packet and only decodes None..V6, so every client that drew V7..V10 could never log in to it — a third of them, at random, for good. The main connection now advances to the next type when it reconnects after a connection that was never login-acked (CMD_MASTERSETTING), and republishes the accepted type into CONNECT_ADDRESS::szFuture. A type that did log in is kept, so a healthy client no longer churns through values the fallback would reject. Sub-connections, including one-shot ones (file/process/screen), inherit the published value at construction and on every reconnect instead of rolling their own dice. Debug keeps its None..V6-only range; the initial Release type now comes from random_device rather than time() % N, which handed a whole batch started in the same second the same value. The slot sits at szFuture+16, after LOCAL_TEST_CLIENT_MAGIC, guarded by static_asserts; it is memory-only and never persisted or sent. Swapping the encoder is a single atomic function-pointer store, so the send and receive threads see either the old or the new encoder and never a dropped object. Co-Authored-By: deepseek-flash |
||
|
|
a801a2999a |
Feature: Support input blocking and privacy overlay on Android hosts
remote_block_input rejected anything but Windows because the Android client had no COMMAND_SCREEN_BLOCK_INPUT handler. This adds the overlay on the client and the server gating, and wires up COMMAND_SCREEN_BLANK. Client: the accessibility service hangs a full-screen TYPE_ACCESSIBILITY_OVERLAY on itself. block=true makes it transparent and touchable so it swallows physical taps; black=true paints it black. Both are absolute states, so repeated commands are idempotent, and the handler clears the overlay when the screen sub-connection dies (Android has no "released when the calling thread exits" fallback). During a remote gesture the overlay is flipped to FLAG_NOT_TOUCHABLE, mirroring Windows' BlockInput(false) wrap; the flag change and the injection must be separated by a short delay or the gesture is swallowed. Server: CLIENT_CAP_PRIVACY_OVERLAY distinguishes new APKs from old ones; Linux/macOS and old APKs still get -32005 up front. Tool masks, instructions and mcp/tools.json follow the change. COMMAND_SCREEN_BLANK is implemented but not exposed as a tool: MediaProjection captures the overlay, so blacking out the screen blinds the operator too and cannot emulate Windows' WDA_EXCLUDEFROMCAPTURE. Verified on the Android 15 emulator: blocked taps are swallowed while remote clicks still land, the block re-arms after each gesture, the watchdog auto-unblocks at the deadline, a dropped sub-connection clears the overlay, and a black overlay shows up in both screencap and get_screenshot. The committed ghost.apk is stale; rebuild before release. Co-Authored-By: deepseek-flash |
||
|
|
445bd8bbb9 |
Feature: Support the remote terminal on Android hosts
The terminal tools were Windows/Linux only because the Android client had no COMMAND_SHELL handler: the server opened a shell sub-connection and the command was silently dropped, leaving exec_command to time out. This adds the PTY path on the client and the matching server gating. Client: COMMAND_SHELL on the main connection spawns a terminal thread that opens an authenticated sub-connection, sends TOKEN_TERMINAL_START and keeps the PTY alive until the server closes it. common/PTYHandler.h is reused, with a minSdk-21 openpty built from posix_openpt/grantpt and /system/bin/sh (mksh) as the shell. A new CLIENT_CAP_TERMINAL bit lets the server reject old APKs up front with -32005. Server: the tool masks, instructions and docs matrix accept APK. While verifying, exec_command left a second echoed copy of the command line in stdout: mksh forks with ECHO still on, so input written before its line editor takes over is echoed by the line discipline in addition to the shell's own redraw. The server now waits for the shell's first output (the prompt) before sending the command and sentinel, which restores the single-echo assumption the cleaning step relies on. terminal_exec on a ready session is unaffected. Verified on the Android 15 emulator: exec_command returns clean stdout and real exit codes for id/uname/df/ls (including a failing command), and terminal_open keeps cwd across commands, pipes work and close is clean. The committed ghost.apk is stale and must be rebuilt before release; a rebuilt APK was used for this testing. Co-Authored-By: deepseek-flash |
||
|
|
915c587964 |
Feature: Support remote chat on Android hosts
The chat tools were Windows-only because the Android client had no COMMAND_CHAT handler: the server asked for a chat sub-connection and the command was silently dropped, leaving chat_open to time out. This adds the full path on the client and the matching server gating. Client: COMMAND_CHAT on the main connection spawns a chat thread that opens an authenticated sub-connection, sends TOKEN_CHAT_START and waits for the server to bind it. Incoming GBK lines are decoded and dispatched to ChatSession, which drives an in-app chat activity; when accessibility is available the activity is pulled to the front, otherwise a tappable notification is posted. Outgoing text is strictly GBK encoded so emoji and unmappable characters are rejected instead of becoming '?'. When the server ends the session the activity closes itself, matching the Windows client's DestroyWindow, and a new session starts from an empty log. Server: a new CLIENT_CAP_REMOTE_CHAT bit lets the server tell new APKs from old ones. ResolveHost now accepts Windows and Android hosts and rejects older APKs up front with -32005 rather than waiting for the command to expire. Tool platform masks, instructions, the docs matrix and mcp/tools.json follow the same change. Verified end to end on the Android 15 emulator: chat_open pops the activity, Chinese text from the server renders, a device reply reaches chat_wait, and ending the session from the master closes the activity instead of leaving a dead window. The committed ghost.apk is stale and must be rebuilt before release. Co-Authored-By: deepseek-flash |
||
|
|
29d7ee1a18 |
Feature: Support host uninstall on Android and expose uninstall_host
The server's "uninstall host" action is the single-byte TOKEN_UNINSTALL on the main connection. Windows clients have handled it for a long time; the Android client ignored it, so the menu entry silently did nothing there. Handle it in the Android client the only way Android allows: ask the system to uninstall the package. The client first replies with COMMAND_BYE and drops the connection, then opens the package installer's confirmation dialog through the accessibility service, or posts a notification that resumes the dialog from MainActivity when accessibility is off. The user still has to confirm on the device; if they cancel, the client has already left the server and must be reopened by hand. The manifest gains REQUEST_DELETE_PACKAGES, without which the installer activity refuses the request outright. New APKs advertise CLIENT_CAP_UNINSTALL so the server can reject old clients instead of sending a command nobody handles. The new MCP tool uninstall_host is gated on McpManage and McpReadonly=0, rejects Linux and macOS hosts, and offers the same wait=true verification as power_action, reporting went_offline once the host disappears from the online list. Verified on the emulator end to end: the tool returned went_offline after 200 ms, the system dialog appeared, confirming it removed the package. Co-Authored-By: deepseek-flash |
||
|
|
fd1b085279 |
Feature: Add remote lock screen for Android hosts
Implement the Ctrl+Alt+Del path on Android as a system lock screen. Android has no secure attention sequence, so COMMAND_SCREEN_CTRL_ALT_DEL is mapped in the client to GLOBAL_ACTION_LOCK_SCREEN and the server exposes it as the new MCP tool remote_lock_screen. The Android client resolves ControlService.lockScreen()/canLockScreen() in nativeInit and dispatches the command from the screen sub-connection through the usual attach/detach JNI path. The lock action is posted to the accessibility service handler because performGlobalAction must not run on the receiver thread. Login advertises the new CLIENT_CAP_LOCK_SCREEN bit only when the accessibility service is bound and the API level is 28+, so the server can reject old APKs and Windows/Linux hosts up front instead of reporting a lock that never happened. There is no receipt: a successful call only means the command was delivered, and the tool description tells the caller to confirm with get_screenshot. Server side adds the schema and handler next to remote_clipboard, audits the call, and gates it on client type plus the capability bit. Since it is the only APK-only tool, check_platform_table.py gains a documented exemption from the Windows baseline invariant, and make_tools_json.py learns an APK-only platform set. tools.json is regenerated from the live server and the plan document now counts 62 tools. Co-Authored-By: deepseek-flash |
||
|
|
0a0b709e8a |
Feature: Support remote clipboard and input on Android hosts
The MCP remote-control family (remote_open / remote_close / remote_mouse / remote_keyboard / remote_clipboard) previously stopped at Windows and Linux, even though the Android client already translated injected events into touch gestures and global actions. This wires up the missing piece and opens the five tools to APK hosts. Client side, the screen sub-connection now handles COMMAND_SCREEN_SET_CLIPBOARD: the native handler forwards the raw GBK bytes to CaptureService.onClipboardText, which decodes them, strips the trailing NUL that the human clipboard-sync senders append, and writes the system clipboard from a background app (allowed on Android 10+, only reads are restricted). Pasting cannot be a Ctrl+V combo, so VK_V is mapped to ACTION_PASTE on the focused node, falling back to the accessibility focus and then to the first editable node, since WebView and self-drawn inputs often do not flag FOCUS_INPUT or isEditable. A new capability bit CLIENT_CAP_SCREEN_CLIPBOARD (0x0800) tells the server the APK understands both paths, so builds without the handler get an explicit -32005 instead of a package that is silently dropped. action=type is rejected outright for APK hosts - physical key events would only turn 'v' into a paste - and the error points at remote_clipboard + key=V. The platform table, server instructions and the five tool descriptions now describe Android support, which keys actually act as global actions (ESC, HOME, APPS, PRINTSCREEN), and that injection needs the accessibility service while capture needs an authorized MediaProjection session, both without receipts. Verified on the API 35 emulator against a Debug server: ASCII and GBK Chinese text round-tripped through the clipboard into a focused Settings search field, type / expect_hwnd / window_hwnd returned -32005, and PRINTSCREEN produced a saved screenshot. check_platform_table.py and verify_tools.py --offline pass. Co-Authored-By: deepseek-flash |
||
|
|
d365a4f948 |
Feature: Report client run logs from the Android client
Before this change the Android client's run log went to logcat only: Logger's init tried to create a log directory, enable was true, and the in-memory ring that MCP's get_client_log reads was never fed, so the tool returned an empty log for APK hosts. Logger now has an Android branch that skips the directory and file writer and keeps only the ring, which is always written regardless of enable. Mprintf carries the source file and line as on Windows/Linux, and both android_log (Mprintf) and a new android_log_tag (platform LOGI/LOGE, LOGI_SH/LOGE_SH) print to logcat and append to the ring. A new ClientLogThread opens a sub-connection on COMMAND_QUERY_LOG and lets ClientLogHandler send TOKEN_REPORT_LOG plus the full ring as the first packet. It has to be a sub-connection: the server takes the first packet and calls CancelIO, which would drop the main connection. The server side allows get_client_log on kPlatApk and decodes the payload as UTF-8 like the other POSIX clients. Verified on the emulator against a local debug server: get_client_log returned 21 UTF-8 lines including [file:line] Mprintf output, LOGI lines, and the ClientLogThread handshake. Co-Authored-By: deepseek-flash |
||
|
|
36618b0ad0 |
Feature: Install Android APK updates pushed from the master
The master now sends COMMAND_UPDATE to Android hosts: it picks a "Build Client -> Android" APK, checks the ZIP magic and that the package carries this master's fingerprint, then sends [cmd][size][APK][xxh64]. The client verifies length and hash, writes filesDir/update.apk and commits a PackageInstaller session, so the system installer still asks the user to confirm - an app cannot replace itself silently. Write and hash failures come back over TOKEN_CLIENT_MSG, so the master sees why nothing happened instead of a silently dropped packet. Sending the wrong file is what the fingerprint check guards against: a template without the master id installs fine and then cannot connect back. "Send anyway" is offered only after spelling that out, and the client advertises CLIENT_CAP_APK_UPDATE (0x0400) so an old APK gets "install a new build once by hand" instead of a packet it would discard. Also report the real versionName/versionCode at login instead of the hardcoded v1.0.0, add android/tools/verify_update_apk.py (pre-send check of size, ZIP_STORED libs, ABI, package, versionCode and the decrypted CONNECT_ADDRESS, which it still locates after BuildDlg rewrote szFlag), and translate the nine new strings in en_US, zh_TW and de_DE. Verified on the emulator and against the live release server: generate, sign, send, install, and the device reconnects and re-grants screen capture. Language packs are GBK and were appended as bytes. Co-Authored-By: deepseek-flash |
||
|
|
5501889d33 |
Feature: Add window-relative remote_mouse coords and PTY pipes in terminal_exec
New Windows clients append an optional 20-byte WINDOWINFO_MCP_DESKTOP block (virtual desktop rect, magic 'VDCP') after the window list, so the server can map window-relative coordinates into the capture frame. remote_mouse accepts an optional window_hwnd; x/y and drag x2/y2 are then normalized against the intersection of the window and the virtual desktop, which is exactly the source rect of get_screenshot mode=window. The target window must be foreground by default, and window_hwnd/expect_hwnd must agree when both are given. structuredContent gains coordinateWindow and resolved (frame coords plus the basis rect), so callers can verify the mapping. terminal_exec now allows pipes, && and || in PTY sessions (ConPTY on Windows, POSIX PTY on Linux) because the sentinel runs on its own line; legacy non-PTY sessions still reject & and |. A read-only PeekTermSession lets the server reject unsupported syntax before BeginTermCommand. POSIX still rejects bare background & (&&, &>, 2>&1 stay allowed). Docs: Mcp_Design.md sections 12.1/20.2/22 and Mcp_Terminal_Design.md 4.4/4.6 are synchronized with the protocol, the new validation order, and the basis rect semantics. Co-Authored-By: deepseek-flash |
||
|
|
235a8a622c |
Feature: Add native region, window and monitor capture to get_screenshot
New Windows clients advertise CLIENT_CAP_SCREEN_REGION and accept a 24-byte ScreenPreviewReqEx appended to the existing 8-byte preview request, so get_screenshot can capture a region, a window or a single monitor at 1:1 resolution instead of only the scaled virtual desktop. Successful v2 responses append an optional ScreenCaptureMeta block reporting the source rect and scale, letting callers map coordinates back for remote input. Old clients and old servers keep the v1 byte stream unchanged. The 8192 px per-side bound only applies to native (1:1) capture, where it guards bitmap memory; scaled captures are unaffected so ultra-wide virtual desktops (for example triple 4K) still produce thumbnails and previews. max_width is clamped to [64,1920] as before instead of rejected, matching the documented schema. Co-Authored-By: deepseek-flash |
||
|
|
b2c0d81396 |
Feature: Add window info RPC for foreground checks and window activation
Add a capability-gated main-connection RPC (COMMAND_MCP_WINDOW_INFO=179 / TOKEN_MCP_WINDOW_INFO=180) that returns visible top-level windows with UTF-8 titles, screen rectangles, foreground flag and z-order, so MCP can verify focus before injecting input. New tool get_foreground_window; host_list_windows switches to the richer fields; host_control_window and operate_window gain action=activate; remote_keyboard and remote_mouse gain expect_hwnd, require_foreground and report_foreground. Old clients keep the previous behavior: the RPC is refused up front via CLIENT_CAP_WINDOW_INFO. The client caps a response at 96 windows (about 101 KB, under MAX_SEND_BUFFER). Signal the cut-off in the mode byte (0x80) instead of silently dropping windows: host_list_windows now reports truncated=true and says the list is incomplete, and activate verification reports state=unknown with reason=list_truncated rather than claiming the window is gone. expect_hwnd is checked only after the session is validated, so an invalid session_id no longer burns a window RPC and no longer reports a window error for a session that does not exist. Nullable output fields (foreground, window) are declared as ["object","null"] so strict clients do not reject responses. Co-Authored-By: deepseek-flash |
||
|
|
5eb44307ee |
Feature: Capture the virtual desktop for multi-monitor remote control
The MCP Observe/Act loop requires screenshots and mouse injection to share one coordinate space. Previously the client sent only the primary monitor while injection used virtual-desktop coordinates, so multi-monitor hosts were rejected outright. - Client: COMMAND_SCREEN_SPY param buffer[11] (wire index 12) now forces whole-virtual-desktop GDI capture; preview JPEGs also cover the virtual desktop including negative origins. - Server: advertise CLIENT_CAP_VIRTUAL_DESKTOP, gate multi-monitor remote control on that capability, and pass the flag when starting the session. Linux stays exempt (X root capture/injection are already consistent). |
||
|
|
2cbed0dcdf |
Fix: Report process uptime and harden the login reserved list
The "启动信息" elapsed time was computed by subtracting a client-formatted wall-clock string from the master's own local time. Windows clients send their local time, Linux/Android/macOS send Beijing time, so a host whose clock runs ahead of the master (UTC+8 clients on a UTC+1 master, a fast CMOS clock) gave a negative difference that was clamped to 0s — permanently, for that host. Add RES_UPTIME to the login reserved list: the client reports its process uptime in seconds, a difference between two readings of the same clock, so timezone and clock skew cancel out. The master adds the connection's alive time to get the current value, and keeps the old string path as the fallback for clients that do not send the field. That fallback now also treats MAC as Beijing time, which was simply missed. AddReserved() now goes through one bounds-checked append. The separator used to be written without any length check (an overflow aborts the client, which installs no invalid parameter handler), and an over-long value now leaves an empty slot instead of dropping its separator, so positional lookups cannot shift. Verified with an ASan/UBSan test over the encoding boundaries and Debug builds of the client and the master. The Linux/Android/macOS clients only append the same field at the end of the list; they were not compiled here. Co-Authored-By: deepseek-flash |
||
|
|
5f40f3726c |
Fix: React to slow-frame congestion and keep remote audio recoverable
The adaptive quality controller counted only complete frames per second, so when a single frame took several seconds to arrive the sample was 0 fps and the throughput criterion abstained forever: Ultra and High kept flipping while a foreground video played. The audio watchdog had the opposite problem: it rebuilt the WASAPI capture every three seconds on an idle endpoint, and its sleep detector measured the whole loop including a blocking send. Sample the last ten seconds in a ring buffer and feed the criterion a windowed rate, guarded so a scroll burst, a stale window or a few KB clock patch is not mistaken for congestion. Apply the same per-frame floor to the one-second fallback and to the post-downgrade local-bottleneck probe. Normalize delayed timer ticks by real elapsed milliseconds, and make the 40 second upgrade-failure window outlast the resolution cooldown it has to cross. On the client, rebuild only when an audio session is actually rendering, and rebuild immediately when the captured endpoint is no longer the default output; refresh the sleep timestamps on failed as well as successful init. Tests cover the window and fallback helpers directly; the full suite passes 845/845, and both the Debug server and Debug client build. Co-Authored-By: deepseek-flash |
||
|
|
2a97471b51 |
Feature: Share a Linux host to another master
Add COMMAND_SHARE (SHARE_TYPE_YAMA) with the Windows semantics: the record goes into share_list and a second connection is opened to the target master while the main link stays where it is. main()'s connection state is all global, so each record is served by a forked "--share <entry>" child that reuses the whole login, heartbeat and command path; the parent only starts, tracks and reaps them. COMMAND_SHARE_CANCEL clears the list and stops the children right away (Linux can; Windows does it on the next start). Transfer now opens its connection immediately too, matching the Windows fallthrough that spawns a shared instance, and that temporary connection is dropped once the main link has actually moved to the target or when the transfer expires. common/host_endpoint.h holds the ip/port/shine/transport word list the two commands share; common/host_share.h holds the share payload, share_list encoding and the per-master dedup. Config writes now take a cross-process flock and replace the file by rename. The parent and every child write the same config.conf from their own snapshot, and a truncating overwrite could drop the other side's keys. Children ignore the commands that only mean something on the main link: share, transfer, upgrade, TLS anchor and group. Verified in WSL against fake masters: share start, cancel and restore, re-sharing with a different transport, share plus transfer on one master, and the transfer child disappearing after the main link moved. Co-Authored-By: deepseek-flash |
||
|
|
3b3aed50e5 |
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 |
||
|
|
a190c21217 |
Feature: make remote desktop tuning per client
The tuning switches lived in the master's Advanced menu and were saved globally, so two hosts could not use different settings. The client already sends ScreenSettings when a remote desktop starts, so the state belongs there: the four items now sit in the remote desktop window's system menu, directly below Screen quality, and are saved per client. ScreenSettings had a 40-byte Reserved area at offset 56; four bytes became TuningFlags, keeping the struct at 100 bytes with Capabilities at 96. A new Capabilities bit marks a value written by a versioned master; old clients, and new clients never configured, report 0 and are not trusted. CMD_SCREEN_TUNING now ends with a version byte. A five-byte command comes from an older master that does not know the server-only adaptive bit: the client applies those three bits to the session but does not save them. A fresh client starts at 0, so an old master still gets pre-feature behaviour; the new master's 0xE default is persisted on its first session. The per-client master copy stays as the old-client fallback, and the old global [settings] Tuning* keys are honoured when neither exists, so an explicit opt-out survives the migration. Verified on the Debug server with the in-process test client: a fresh client stored 0xE on first use; toggling VBV wrote 0xF to both sides; after deleting the master copy and reopening, the menu restored VBV from the client report. Co-Authored-By: deepseek-flash |
||
|
|
4884b080e8 |
Improve: default the x264 bitrate cap off and label it for weak links
The cap is capped CRF (VBV): when a frame needs more bits than the profile's nominal bitrate allows, x264 has to raise QP to stay under the ceiling. Scenes with lots of change (video, scrolling, window dragging) therefore lose detail and look blurry, while static scenes stay sharp - the cap only bites on motion. That trade is worth it on intercontinental or otherwise constrained links, where an uncapped frame can take seconds to transmit and stall everything queued behind it, but it is a pure quality loss on a LAN. The tuning item now defaults to unchecked, so a master sends 0x3 (GDI no-sleep and send pacing) by default; machines that already stored TuningX264Vbv keep their explicit choice. The menu entry is renamed to "x264 码率封顶 (VBV,仅限洲际弱网)" and the en_US, zh_TW and de_DE translations were updated to match the new source string. Only newly opened remote desktops pick up the flag, since CMD_SCREEN_TUNING is sent when the session starts. Verified by rebuilding the Debug x64 server and client, and by finding the new menu and translation strings in the built binary. Co-Authored-By: deepseek-flash |
||
|
|
f77b18aa68 |
Feature: run a test client inside the master from the Advanced menu
The Advanced menu now ends with Run Test Program. It copies the kernel payload that was already read into memory, points its CONNECT_ADDRESS at 127.0.0.1:<listen port>, and loads it with MemoryLoadLibrary inside the master process, so this machine comes online as a controlled host -- no second machine is needed to try remote desktop or file transfer. A worker thread waits for the client to exit, then frees the module and re-enables the item. Only one instance runs at a time: the item is grayed while it does, and stopping it means uninstalling the test host from the online list. The loaded copy carries LOCAL_TEST_CLIENT_MAGIC in szFuture. The client uses that mark to refuse the commands that would otherwise hit the host process or the whole machine: uninstall (no self_del), update, run as admin, ban, share/assign, and shutdown/reboot/logoff. It also skips auth-kernel detection, which GetModuleFileName(NULL) would misjudge inside the master. Renames szFututre to szFuture and documents that the first 16 bytes of the reserved tail are now claimed, with a static_assert so it cannot silently shrink below the magic. Translations for en_US, zh_TW and de_DE, plus the HIDE_MENU_RUN_TEST feature flag and its row in the limits dialog. Verified on a Debug master: the item is last and has its icon, one click brings the host online, a second click is refused, uninstall stops it in about a second and the master survives, re-run works, and exiting the master with a live test client takes 2.6s (3.0s baseline). Co-Authored-By: deepseek-flash |
||
|
|
d6b04a98f0 |
Feature: throughput criterion for adaptive quality, plus anti-oscillation
Adaptive quality only looked at RTT, so a short RTT over a narrow pipe read as "excellent": at 20-40ms it picks Ultra/High (DIFF/RGB565), both with bitRate == 0, and never steps down. One 1080p RGB565 frame is 4.15 MB -- 1.66s of transmission on 20 Mbps. Adds GetTargetQualityLevelByLoad(): congestion needs both fps < 60% of baseline and bytes/frame still near the nominal bitrate, because a static screen has a near-zero byte rate on any link. Merged with the RTT result as max() -- averaging lets a good RTT mask a narrow pipe. Step-down is 3 confirmations and jumps straight to the level the throughput can carry (capped at +2); step-up stays RTT-only, so the criterion is one-way and the worst case is one level too low instead of a 30s/15s oscillation. Anti-oscillation, all inside the switch: RTT hysteresis (85%/115% dead band against the target level's threshold), failed step-up pinned for 3 minutes, cooldowns 3s -> 10s down / 15s up, counters interrupt each other, and a hard limit of 6 changes per 5 minutes. Server-only, no client change. m_ulBytesThisSecond had to be fixed first: it is accumulated before the switch, so file transfer, audio and clipboard counted as screen traffic; added m_ulScreenBytesThisSecond for the four frame cases. Also gates a real bug in the 10s post-step-down probe that disabled the criterion permanently on a static screen. Default on (same migration caveat as the other four). Unticking takes the original path unchanged. Verified on Debug: 27 hysteresis cases and the load cases pass, menu defaults correct; not yet measured end to end. |
||
|
|
ca4e85826f |
Feature: remote desktop tuning flags, on by default with per-item opt-out
Adds "Advanced -> Remote desktop tuning" with three independently checkable items, all enabled by default: x264 bitrate cap (VBV) TUNING_X264_VBV 0x1 GDI capture: no slice delay TUNING_GDI_NO_SLEEP 0x2 Send pacing FPS floor TUNING_PACE_FPS_FLOOR 0x4 Unticking an item clears its bit and restores the pre-commit behaviour exactly, so the escape hatch is one click per measure -- no rebuild, no config edit. Each bit is independent; a problem with one does not force turning all three off. Plumbing -------- Menu state -> [settings] Tuning* -> CMy2015RemoteDlg::GetScreenTuningFlags() -> CScreenSpyDlg::SendScreenTuning() (right after TOKEN_BITMAPINFO) -> CMD_SCREEN_TUNING = 178 [cmd:1][flags:4 LE] -> CScreenManager::OnReceive -> m_nTuningFlags -> ScreenCapture::SetTuningFlags Why it is safe to send to old clients: CScreenManager::OnReceive has no default branch in its switch, so an unknown command falls straight out (verified). 178 was unassigned (177 = COMMAND_SET_PROTO, 199 = TOKEN_DECRYPT), and the enum re-anchors explicitly so nothing auto- increments onto it. Flags are sent even when all-zero on purpose: the client's flag lives in CScreenManager, which survives closing and reopening the remote desktop window on the same connection. Without the zero send, unticking the menu would leave the previous flags in effect. Per-measure notes ----------------- VBV: capped CRF (peak = target, 0.5s buffer, init 0.9). The hardware paths already cap via rc_max_rate (1.5x, 1s buffer); this is tighter and only affects x264. After an IDR the buffer drains and takes up to 0.5s to refill, so a brief quality dip follows every keyframe -- if that shows up, relaxing to 1.5x/1s would match NVENC/QSV. GDI: keeps the 50-line BitBlt slicing (large single BitBlts hit driver limits) and only drops the 5ms sleep between slices -- 1080p is 22 slices = a forced 110ms per frame against a 50ms budget at 20fps. Pacing: clamps s0 to 2x the base interval instead of 4x (2fps -> 4fps), taken as max(2x base, 1000/MaxFPS) so it never exceeds the configured MaxFPS. The growth/decay code itself is untouched. This one works against the loop's own congestion signal, so it is the first to untick if a bad link feels laggier rather than smoother. SetTuningFlags only rebuilds the encoder when TUNING_ENCODER_BITS (currently just VBV) changes -- the GDI and pacing bits are read live by the capture and send threads, and rebuilding for them would drop an IDR and visibly flash the picture. Defaults: the on-by-default value lives in the third argument of THIS_CFG.GetInt(), which only applies when the key is absent. A machine that already has an explicit 0 keeps it, so the flip is not retroactive and a test machine can end up with a mixed state. Verified on the Debug build: with no Tuning* keys all three items start checked; unticking VBV alone leaves the other two checked and survives a restart; en_US/de_DE/zh_TW translations all resolve. Not yet measured end to end on a real remote desktop session. |
||
|
|
8b92f32c47 |
fix(config): stop reads from creating empty registry subkeys
iniFile/binFile::GetCachedKey used RegCreateKeyExA for every access, so a plain GetStr/GetInt on a missing section materialised an empty subkey. CScreenManager's constructor calls LoadQualityProfiles() unconditionally, which reads profile0.. profile5 x4 keys, so every client start left six zero-valued subkeys behind: 126 of them on the dev box, all with zero values. The server's HKCU\SoftwareYAMA\quality key is the same artefact. Split the helper by intent: writes go through RegCreateKeyExA, reads through RegOpenKeyExA. Both still ask for KEY_READ|KEY_WRITE, because the handle cache is shared and a read-only cached handle would make a later SetStr on the same section fail. Also fixes a second bug in SaveQualityProfiles: when a level matched the default it simply continued, so a level the operator reset to default kept the old custom values in the registry and the reset never took effect. Add SectionExists() (open-only, never creates) and write the defaults back when the section already exists. |
||
|
|
951b4072e5 |
Feature: Embed the master's TLS certificate in generated clients
When the server has TLS enabled, the builder can now bake its certificate into the client it produces, so a distributed client speaks TLS on its very first connection instead of waiting for the anchor to be pushed after a plaintext login. The dialog gets a checkbox (IDC_CHECK_TLS_ANCHOR) that is only enabled for payloads and protocols where an embedded anchor makes sense; the choice is remembered even when the control flips to disabled and back, so switching protocols cannot silently undo a deliberate opt-out. Every label variant stays short enough to fit the 196 DLU field, including the German ones. A template that predates the anchor block no longer aborts generation: it warns, clears the checkbox and produces a plain client, so a master upgraded without rebuilding the ghost/ServerDll resources does not block every build. The certificate lands in a fixed 4 KiB block (magic, version, length, FNV-1a hash, master address, PEM) carved out of the payload at build time. The client reads its trust anchor from four sources in order: the tls_disabled marker, the certificate the server pushed into the registry, a PEM file next to the executable, and finally the embedded block. The embedded block only applies to a connection whose target matches the master recorded at generation time, compared as an address set: an exact string match when only one address is configured, or an intersection of resolved IPv4 addresses otherwise. A transferred, shared or parallel instance falls back to the old plaintext first-connect path instead of pinning itself to a certificate it can never verify. That decision is made per connection, not per process: shared and parallel instances are threads inside a single client process, so a process-wide flag let whichever instance connected first decide for all of them, and the first load of the TLS state cached that answer for good. The TLS layer now keeps two cached states (embedded anchor allowed, and not allowed), picks one per handshake, and reports the anchor source of that handshake for the login capability bit. Matching by resolved address also keeps parallel mode working, where the connection goes to the single IP the domain pool selected while the configured master is a domain or a list. Server side, generated and updated payloads get the block written in place; the client reports the capability bit on login so the console can tell which hosts are already TLS-only on first connect. Loading the anchor decodes every PEM block in the chain rather than just the leaf, and an anchor that exists but fails to load keeps the old fail-closed behaviour. A pushed anchor only reconnects when the transport of the live connection actually changes, judged against that connection's own target rather than the process-wide switch. This was verified end to end against a freshly generated client with an empty registry: the first connection was a TLS 1.2 ClientHello 0.2 s after start, and a four-certificate fullchain loaded all four blocks. Re-verified after the per-connection rework with the anchor block patched into a debug client: with a matching master the first bytes are a ClientHello, with a foreign master the client logs the skip and sends plaintext, and a domain master resolves to the IP it connects to and still matches. A master domain that no longer resolves falls back to plaintext within a second and is not looked up again for a minute, instead of stalling every reconnect on a DNS timeout while holding the lock the certificate verification needs. Co-Authored-By: deepseek-flash |
||
|
|
c4021e1fc9 |
Feature: Ship a built-in TLS certificate so encryption works out of the box
A fresh install used to require openssl before the server could speak TLS: two empty paths in [tls] meant the identity failed to load and every ClientHello was refused. TLS is now on by default and, when no custom certificate is configured, the server generates its own self-signed one the first time it needs it -- RSA-2048, SHA-256, CN=yama-server, CA:TRUE, valid for ten years from one day before now. Plaintext clients are untouched, since the device port still splits plaintext from TLS by sniffing the first six bytes of a connection. The certificate and its PKCS#8 private key are stored side by side in the config under [tls] BuiltinCert / BuiltinKey as single-line base64 DER. Single line, because the server has two config backends -- the registry for Release, settings.ini for a Debug master -- and only a line without newlines means the same read/write code serves both. That in turn required fixing the registry reader: iniFile::GetStr copied into a 512 byte stack buffer, so a 1.5 KB value came back as a truncated or empty string. The two-phase dynamic read now lives in common/iniFile.h as ReadRegistryValueSz / ReadRegistrySz, and the copy that client/TlsChannel.cpp had been carrying for its own trust anchor is gone. This also makes the built-in certificate self-checking: Ensure() re-reads what it just wrote and fails loudly if the round trip did not survive. Import has to go through NCRYPT_PKCS8_PRIVATE_KEY_BLOB, matching the import path in BuildIdentityFromDer. NCRYPT_PKCS8_PRIV_KEY_INFO_BLOB, which most samples reach for, is not implemented by the Microsoft Software KSP and returns NTE_INVALID_PARAMETER; a probe confirmed it, and the export type that works is the one the importer already expected. Building an identity is now split into a file front-end (PEM, fullchain, PKCS#1 hints) and a shared DER core, so the built-in and file paths cannot drift apart. That key also exposed a second problem worth fixing here. The identity binds its private key to the certificate by name -- CRYPT_KEY_PROV_INFO with pwszContainerName -- and Schannel resolves that name on every handshake through CryptAcquireCertificatePrivateKey. With the fixed name "YamaServerTlsKey", two server processes under the same Windows user shared one key slot: whichever loaded last overwrote it, and the other process's next handshake picked up a private key that does not match its certificate. That is exactly the debug-plus-release pairing used here, and defaulting to a built-in certificate is what makes it reachable, since the debug instance no longer points at the same PEM as the release instance. The name is now the base name plus the first six bytes of the certificate's SHA-1 thumbprint, e.g. YamaServerTlsKey-c0d469eae8a4: different certificates get different keys, instances sharing one certificate still share one key. MCP picks this up too. The effective name goes to the trace log so a collision is visible without a debugger. A stale key from an older build may still sit in the key store under the old name; nothing references it and it is not deleted automatically, since a running instance of an older build could be using it. The trust anchor still has to be pushed. The client pins exactly one root through an exclusive-root chain engine and checks no host name, so a self-signed CA:TRUE leaf chains cleanly to itself -- but only if the client is told about it. That is the existing 启用 TLS / 切换到 WSS command, which now takes the PEM from ServerTlsIdentity::AnchorPem instead of re-reading the configured cert file, so it reports the same certificate the server actually serves for both sources. Losing the stored certificate (cleared registry, new Windows user) regenerates it, and every client must be re-pushed the anchor. Two places that used to fall back to [tls] CertPath now skip that fallback while the built-in certificate is active: the MCP HTTPS front end at startup and the prefill in its settings dialog. A self-signed certificate cannot pass validation at a public MCP client, and the retained CertPath is only a leftover from switching back to a custom certificate, so pretending to use it would fail later with a worse message. MCP HTTPS with empty paths already fails closed with a log line. The TLS dialog gains a 内置证书 checkbox, ticked by default and unticked when certificate paths are present; ticking it greys out the path rows without clearing them, and shows either "generated on first use" or the expiry date read back from the stored certificate. Saving writes four keys -- Enabled, UseBuiltIn, CertPath, KeyPath -- and an explicit UseBuiltIn keeps the paths from being used as an implicit switch. Every reader of [tls] Enabled now defaults to 1, so the menu check, the dialog and the loader agree on a fresh install. The status bar panes on 无 / 有 grew a third state, 内置, and the pane width is measured across all three. Translations were added to en_US, zh_TW and de_DE; skipping the German file would have left the new dialog text in Chinese there, as de_DE is loaded from disk rather than embedded. Verified with the debug server against openssl s_client. Both the generated built-in certificate (CN=yama-server) and an existing custom one (CN=localhost) complete a TLS 1.2 handshake with the pinned certificate, and their log lines show distinct key names, c0d469eae8a4 and 272f2adfb19c. An unmodified client still runs in plaintext without an anchor, an existing custom certificate deployment behaves exactly as before, and client and server both build clean at Debug x64. Co-Authored-By: deepseek-flash |
||
|
|
99db28e2e2 | Feature: Let the operator switch a live client's transport from the online list | ||
|
|
d4f312c9d8 | Feature: Tunnel the device protocol through a reverse proxy over WebSocket | ||
|
|
56a937fabb |
Fix: Three blocking defects found by the MCP tool survey
The survey in docs/Mcp_Test_Report_2026-10-29.md turned up three P0s, each
of which stopped a whole capability rather than degrading it. Two of them
were the same mistake: the input schema promised something the output
schema then rejected. The third was an output with no size limit, plus a
client that never implemented the command at all.
Batch calls could never succeed. A call carrying ids[] goes through
BuildBatchCall, which returns {tool, total, succeeded, failed, skipped,
results[]}; every tool declares only the single-host shape. The client
validates structuredContent against that declaration, so any batch call
failed with -32602: data must have required property 'host' - the input
schema advertises ids, the output schema kills it. Tools/call cannot fix
this one call at a time, so ApplyBatchOutputSchema runs at the end of
tools/list, next to ApplyToolAnnotations, and rewrites the schema of every
tool in the batch list to {type: object, anyOf: [single, batch]}. Placing
it at the end is what makes it cover all three registration points
(inline, McpMachine, McpChat) and any tool added later. IsBatchReadOnlyTool
moved from McpServer.cpp to McpInternal.cpp for the same reason: the list
is now read by tools/call and tools/list, and the two must not drift.
list_registry failed whenever path was omitted. The root-key branch
returns keys only, while the output schema listed values in required as
well, so the first usage the documentation describes - omit path, get the
five root keys - could not work. values is no longer required and the
schema says it is absent in that branch. The root branch also returns
path: "" now, so both branches carry the same field set and callers need
not branch.
get_client_log was unusable on both platforms, for two unrelated reasons.
Windows returned the whole 1000-line ring buffer, 90,473 characters, over
the client's result limit: fetched, then not deliverable. Linux and macOS
timed out because their clients never handled COMMAND_QUERY_LOG at all -
only client/ClientLogManager.cpp does - so TOKEN_REPORT_LOG never arrived.
Adding a limit alone would have left Linux broken; fixing the client alone
would have left Windows over the limit.
The server now takes limit (default 200, max 2000) and filter, and reads
backwards from the end: troubleshooting wants the last thing that happened,
not the first line after boot. A 64 KB byte budget sits under the line
count, because one line can be a stack dump; when the final line alone
exceeds it, the tail is returned and truncated says so. Responses carry
lines_total, lines_matched, lines_returned and truncated. The timeout
message now names the likely cause and two ways around it instead of
saying only "Timeout waiting for client log".
The POSIX clients get common/ClientLogHandler.h, a counterpart to the
Windows CClientLogManager, and one line each in linux/main.cpp and
macos/main.mm. It must open a sub-connection: MessageHandle's
TOKEN_REPORT_LOG branch takes the first packet and then calls CancelIO on
that connection, so answering on the main connection would close the main
connection and drop the client offline.
Verified against a server built at 21:17:21 with both clients rebuilt. A
batch get_host_detail over the two A6 records returns succeeded=2 with
per-host data; host_list_processes with ids returns 2 of 2, which exercises
the McpMachine registration point rather than the inline one; a mixed
Windows/Linux batch of get_client_log returns 2 of 2. list_registry with
no path returns the five root keys and path ""; with a path it still
returns its values. get_client_log on Windows goes from 1000 lines to 200
with truncated=true, and limit=3 with filter=ConnAuth yields 28 matched and
3 returned. On Ubuntu 24.04 it returns logs at all, and the client's own
log shows Enter ClientLogThread, TOKEN_REPORT_LOG, then Leave about a
second later when the server cancels the connection - paired, no leak.
The connector still caches an old input schema for get_client_log, so
limit and filter are rejected locally until it reconnects; the defaults
already cover the P0, and this is the same cache problem as the
copy_files_c2c.overwrite entry in the report's P1 list.
docs/Mcp_Design.md section 18 records the implementation and the reasoning;
section 7 of the test report carries the verification table.
Co-Authored-By: deepseek-flash
|
||
|
|
dc4fd792f6 |
Feature: Implement the Linux screen preview response
The Linux client now answers COMMAND_SCREEN_PREVIEW_REQ, so a host with an X11 desktop gets a thumbnail when it is double-clicked in the online list, a frame in the list's Preview column, and an image from the MCP get_screenshot tool. Previously only Windows clients advertised the capability and Linux hosts showed "预览不可用" after a four second wait. The client does not encode JPEG. Stock desktops ship libjpeg.so.8 whose struct layout is the distribution's ABI (JPEG_LIB_VERSION 80), while the in-tree jpeglib.h is libjpeg-turbo 3.1.1 (62), and libturbojpeg is not installed by default; dlopening the system library against that header fails with "Wrong JPEG library version: library is 80, caller expects 62". Instead the client sends raw pixels in a new screen preview format, SCREEN_PREVIEW_FMT_BGRX: top-down rows of B,G,R,X with no row padding, already scaled to the requested width. The server re-encodes to JPEG at the single ingress point, so the preview popup, the list thumbnail cache and the MCP tool keep consuming JPEG only. Capture follows the path ScreenHandler already uses: root window copied into an offscreen pixmap with an IncludeInferiors GC, then XGetImage, which avoids BadMatch under compositing window managers. The X11 type declarations and the dlopen loader moved out of ScreenHandler.h into linux/X11Loader.h so both users share one dlsym table. The full-size image is never materialized: a box filter reads straight from the XImage rows (honouring bytes_per_line) into the output buffer, scales to maxWidth without upscaling, and clamps the height to 1080 so a portrait 4K desktop cannot produce a 26 MB packet. Rows and columns come out even, which they are for JPEG anyway. The capability bit is now honest about the runtime. LOGIN_INFOR grows DefaultCaps()/SetCaps(), and the client recomputes the bits before every login and re-login: CLIENT_CAP_SCREEN_PREVIEW is set only when DISPLAY is present and the X server actually opens. A headless host therefore gets -32005 "Host does not support screen preview" from MCP instead of a timeout, and a host whose session appears after boot picks it up on the next reconnect. Requests are handled on a detached worker thread behind a single-flight guard (matching the Windows client), so a slow XGetImage never stalls the receive thread and a burst of requests degrades to "no preview" rather than queueing. If the worker thread cannot be created, the guard is released again, so one failure cannot leave every later request rejected as busy until the client restarts. The MCP design note claimed the capability was declared by Windows only, and the get_screenshot tool description said the same; both now say what the code does (Windows always, Linux when a display is reachable). Server side, NormalizeScreenPreviewPacket runs in MessageHandle before the MCP handoff and the PostMessage to the UI thread. It validates that width/height are within the values the server itself can ask for and that bytes equals width*height*4, converts with a stack Gdiplus::Bitmap over the packet's own pixels (no copy, and no DEBUG_NEW trouble), and rewrites the header to JPEG. The encoder output is read back by seeking the stream rather than GlobalSize, so the packet carries no heap-block padding after the EOI marker. Malformed packets are dropped; failure statuses pass through untouched so the existing code can report them. Tested against a Debug server with the WSL Ubuntu 24.04 build as the client. get_screenshot returned valid JPEGs at max_width 480 (480x142, 1.7 KB) and 1920 (1920x570, 17.9 KB), repeatably; the list showed a thumbnail for the GUI client and N/A for a second copy started without DISPLAY, which also answered -32005. The box filter and the BGRX to JPEG conversion were checked separately with quadrant fixtures: the browser over the synthetic B,G,R,X buffer recovers red/green/blue/white in the right channels and the downscale averages, handles non-integer ratios and row padding, and rejects 24bpp and upscaling. The captured frames come out black under WSLg because Xwayland keeps no root pixmap there; that is the compositor, not this code, and Xorg sessions capture normally. Co-Authored-By: deepseek-flash |
||
|
|
106ac2ff0f |
Fix: Resolve the Desktop, Downloads and home shortcuts on Unix clients
The file manager's remote shortcut buttons send "%USERPROFILE%\Desktop\" and friends, which the Windows client expands with ExpandEnvironmentStringsA. Unix clients had no such expansion, so the literal %USERPROFILE% was taken as a directory name: opendir() failed and the Desktop, Downloads and home buttons listed nothing at all. Add common/UnixPath.h, which expands the variables the server can send (%USERPROFILE%, %HOME%, %HOMEDRIVE%%HOMEPATH%, %USERNAME%) and maps $HOME/Desktop to the localized folder named in ~/.config/user-dirs.dirs (for example ~/桌面), falling back to the plain $HOME/<Name> path when that folder does not exist. Unknown %VAR% tokens are left untouched, so paths that really contain a percent sign behave as before. FileManager and the two Windows-to-Unix converters in FileTransferV2 now share that one conversion. Besides the listing itself, this fixes downloads into a shortcut directory, which used to be created under a literal %USERPROFILE% tree instead of the user's real desktop. Co-Authored-By: deepseek-flash |
||
|
|
3a158a241c |
Feature: Support upload_file and download_file on Linux and macOS hosts
Both tools used to reject LNX/MAC targets outright. The server now gates on the target client type instead: a POSIX target must pass an absolute POSIX remote path without a backslash or a ".." segment (-32602 otherwise), while Windows targets keep their exact previous behaviour. upload_file needed no new client command; the POSIX receiver already handles COMMAND_SEND_FILE_V2 and derives the destination from the packet name. It now also reports a real receiver_ack: the upload session records dstClientID/transferID, and OnC2CRecvResult matches the 176 acknowledgement from Linux targets, so a destination write failure becomes -32011 and a missing ack (with bytes in flight) becomes -32001. download_file needed two pieces on the POSIX side, both shared by Linux and macOS through common/FileTransferV2.h: a FileCompletePacketV2 per file with a streaming SHA-256 (new self-contained common/sha256_posix.h, since BCrypt is Windows-only) so the server can count completed files and verify digests, and a TOKEN_DOWNLOAD_ERROR reply when the requested paths do not exist or are denied, which the server maps to -32009/-32010 within milliseconds instead of waiting for the stall watchdog. Zero-byte files were lost when uploading to POSIX targets because the worker sends no data chunk for them and the complete packet carries no path, so the receiver had nothing to create. The server now injects a zero-length final chunk for each empty file, only for POSIX targets; Windows targets keep their existing behaviour. Also fixes a download completion edge case found while testing: the client decides entry order, so a directory may arrive after all files (an empty subdirectory, for example), and the directory branch only completed when the directory count alone covered totalFiles. The check is now filesDone + directoryCount >= totalFiles. Verified end to end against a WSL Linux client and a Windows client: upload and download of a tree with a 3 MB binary, a Chinese filename, an empty file and an empty subdirectory all round-trip with matching SHA-256; the documented error paths (-32602, -32009, -32011, -32001) and the Windows upload/download/C2C regressions were exercised as well. Co-Authored-By: deepseek-flash |
||
|
|
4146c73657 |
Feature: Make Linux a copy_files_c2c destination
The C2C file transfer tool required both ends to be Windows clients. A Linux client can already land the files: the Windows source worker builds every entry name by plain string concatenation of dst_dir and the relative path, so a POSIX dst_dir such as /tmp/recv arrives as "/tmp/recv\sub\file", which the POSIX receiver normalizes to "/" and writes below an absolute path. What was missing was the server gate and any way to tell whether the writes succeeded. The server now accepts LNX/MAC destinations instead of rejecting them, and validates dst_dir by destination type: an absolute Windows path for Windows targets, an absolute POSIX path without backslashes for POSIX targets. The paths and dst_dir arguments also reject embedded NULs, and a POSIX dst_dir is converted to CP936 exactly so unencodable characters fail loudly instead of silently becoming '?'. To make receiver_ack meaningful, a Linux client that receives a C2C transfer now reports what it wrote. It tracks the outcome per transferID, counting a directory entry, the last chunk of a file and the completion packet of an empty file as the three ways an item is settled, with done sets so that source retries and the trailing completion packet never double count. When every item is settled it sends one C2CSendResultPacket back on its main connection under the new TOKEN_C2C_RECV_RESULT (176), with the first errno in the win32err field and the mapped FEV2_* status. A dedicated token is used instead of reusing 175 because a host can be the destination of one transfer while being the source of another, and a destination result must never latch the source side's done flag. The server waits up to five seconds for that acknowledgement after the source reports success, and only for destinations advertising the new CLIENT_CAP_C2C_RECV_ACK capability bit (Linux only, macOS reports nothing). A failed acknowledgement becomes -32011 with the status, errno and received file count; a missing acknowledgement stays an error only for transfers that actually moved bytes, since a transfer of empty files alone gives the receiver nothing to learn totalFiles from. Windows destinations are unchanged and skip the wait entirely. Verified on the debug instance: Windows to Linux (WSL Ubuntu 24.04) with subdirectories, an empty directory, a Chinese file name and a 3 MB binary lands with matching SHA-256 and receiver_ack true; a Windows-style dst_dir returns -32602; an unwritable POSIX destination returns -32011; the existing Windows to Windows cases still pass with receiver_ack false and the same latency. Co-Authored-By: deepseek-flash |
||
|
|
4c0e86dcc5 |
Feature: Upgrade a Linux client from the server
The Linux client is a standalone ELF with no in-memory loader and no COMMAND_UPDATE handler, so the server's upgrade menu silently did nothing for an LNX host. It can now push a new binary and have the client replace and restart itself. The server grows an LNX branch next to EXE/DLL/SC. It takes the ELF from an explicit settings.ini LinuxClientPath, then ghost_linux_amd64 in the program directory, then res\ghost_linux, then IDR_LINUX_GHOST, the copy the server has always embedded for the client-build dialog, so a server with nothing on disk can still upgrade; a configured path that cannot be read is an error rather than a silent fallback. Only x86_64 ELF64 is accepted. The payload adds a 32-byte MD5 trailer to the existing [cmd][size:8][payload] layout, which the Windows branches keep unchanged. linux/ghost in the tree is still the build from before this change and is not updated here. It has to be refreshed before release: the embedded default is copied from it at build time, and a stale copy would install a client with no COMMAND_UPDATE handler, which can never be upgraded remotely again. The client verifies the declared size, elf magic, e_machine against its own ELF header and the MD5 before touching anything, so a miscopied or corrupted file never lands on disk. It then writes a same-directory temp file with fsync and 0755 (a running executable cannot be truncated in place), renames it over its own path atomically, keeps the replaced inode as .old, removes the PID file, forks a detached child that waits for the old process to exit and execs the new binary with the original argv, and finally exits with S_CLIENT_UPDATE. Doing the rename and the exec in that order avoids ETXTBSY, double connections under one client id, and a new instance that isAlreadyRunning() would refuse to start. Any failure (unwritable install directory, bad payload, fork) leaves the client running on the old version; the reason goes to the client log and to the server's message log through TOKEN_CLIENT_MSG, which required moving that struct out of the Windows-only block in common/commands.h. The shared client source had also stopped compiling off Windows: the unknown-header diagnostic in IOCPClient::OnServerReceiving printed TlsEnabled() and m_tls.IsReady() unconditionally, but TlsChannel and m_tls only exist on Windows. That diagnostic now keeps the TLS details where the channel exists and prints just the buffer dump everywhere else. Verified end to end in WSL against the Debug server, foreground and -d daemon: the PID changes, the installed file matches the pushed MD5, the host reconnects, and ghost.old holds the previous binary. A read-only install directory reports "cannot create ...: Permission denied" in the server log with the client still online. With an invalid file at ghost_linux_amd64 the server refuses it and names that path, which shows the disk source wins; with nothing on disk the update goes through from the embedded ELF. Co-Authored-By: deepseek-flash |
||
|
|
c271911fcb |
Feature: Add copy_files_c2c to transfer files between clients directly
Adds the 54th MCP tool, copy_files_c2c, which asks the source client to push a set of files straight to another online client. Previously the only way to move files between two clients was to download them to the server machine and upload them again, so the data crossed the wire twice and needed free disk on the server. With C2C the server only relays packets and never parses or stores the payload. Protocol. Two new ids in common/commands.h: COMMAND_C2C_SEND_FILES (174), carrying the destination directory followed by a NUL-separated path list, and TOKEN_C2C_SEND_RESULT (175), a fixed 45-byte result packet sent back over the same sub-connection the transfer used. Clients advertise support with the LOGIN_INFOR capability bit CLIENT_CAP_C2C_PATHS (0x0008), exposed server side as Context::SupportsC2CPaths(). File transfer V2 already knew how to push to dstClientID, so the destination side needed no change at all; existing V2 receive paths keep working, and older clients simply do not advertise the bit and are rejected with a clear error instead of hanging. Client. OnC2CSendFiles expands environment variables, collects directories recursively, opens its own sub-connection (with sub-connection auth), and runs FileBatchTransferWorkerV2 in a detached thread, then reports the result on that same connection. Every early exit now reports a structured failure rather than staying silent. The worker needs the process-level InitFileUpload call that the receive path performs lazily, and a source client may never have opened a file manager or received an upload, so the initialization is factored into EnsureV2TransferInited() and called from both paths. Server. copy_files_c2c mirrors the existing upload tool: gates, id parsing, capability checks, path validation, then a session keyed on the source host that WaitC2CDone polls until the result packet arrives. The C2C relay branch used to attach a CDlgFileSend progress dialog to the source's sub-connection; NotifyProc then routed every later packet on that connection to the dialog, which parsed the result packet as a V1 file chunk and dropped it, so the tool always timed out even though the files had arrived. IsC2CTransferPending() now suppresses dialog creation for MCP-driven transfers only, leaving manual Ctrl+V transfers untouched. Errors map to -32001 for a source-side transfer failure, -32010 for access denied, -32009 for a missing path and -32002 for an offline destination. Both hosts must be Windows: the destination is restricted too, because the source embeds dst_dir in each V2 chunk name as an absolute Windows path and only the Windows receiver applies it literally. A Linux or macOS receiver never gets a target directory here (the clipboard flow sets one with COMMAND_C2C_PREPARE, which this path does not send), so it would strip the drive letter and write under / instead. Supporting that needs a prepare packet carrying an explicit path plus an upgrade of those clients, so for now the tool rejects them with -32005 rather than writing somewhere wrong. Verified end to end on the Debug build: three files including a non-ASCII name, an empty directory and a 3 MB binary arrived with matching SHA-256 in 3.2 s, a non-existent destination directory was created, and the negative cases returned the documented codes. mcp_smoke.ps1 passes 41/41 with two new assertions and 27/27 in -SkipHost mode. Design notes, error table and limitations are in docs/Mcp_FileTransfer_Design.md section 14 and docs/Mcp_Design.md section 15. Co-Authored-By: deepseek-flash |
||
|
|
315a0855dc |
Feature: Let the client report structured failures for MCP tools
Four new client-to-server tokens carry a win32/LSTATUS code when a command fails instead of returning empty data: TOKEN_SERVICE_ERROR (170), TOKEN_FILE_LIST_ERROR (171), TOKEN_REG_ERROR (172) and TOKEN_DOWNLOAD_ERROR (173). They sit on byte values that were unused, so existing numbering is untouched. The three data paths that used to collapse "failed" and "empty" into the same packet now distinguish them: OpenSCManager failures, directory enumeration failures and RegOpenKeyEx failures all report the code that was actually returned, and UploadToRemoteV2 reports why it found no file to transfer before the transfer sub-connection is ever created. Every failure branch still sends the packet the old server expects (TOKEN_FILE_LIST, the empty TOKEN_REG_PATH/KEY pair, the ClientMsg popup), so a new client talking to an old server degrades to exactly today's behaviour instead of timing out. Success paths are byte-for- byte unchanged. Co-Authored-By: deepseek-flash |
||
|
|
b637c94e24 | Feature: Allow user to select an installation location for client | ||
|
|
8eab26c1f6 |
Feature: Web screen wall for multi-device live monitoring
Add a third view to the web UI, the screen wall, which shows several devices at once in one tab with 1x1 / 2x2 / 3x3 / 4x4 / 5x5 layouts and a device sidebar on the left. Tiles are monitoring-only; clicking one enlarges that device into the existing single-screen page for control, and Back returns to the wall. The same device can be added several times: all tiles of one device share a single decoder and a single stream. The wall decodes at most 9 streams on desktop and 4 on touch devices. Tiles beyond the budget keep receiving frames but have their decoder closed and show the last frame plus a Paused badge; they are promoted automatically when a live tile goes away. Subscriptions are reference counted on the client (streams map with owner sets), so a stream is only connected on the 0 -> 1 transition and disconnected on 1 -> 0, and the wall and the single-screen page can share one device without tearing the stream down. Server side, WebClient now holds a set of watched devices instead of a single id. A new multiWatch command flag selects set semantics, while clients without it keep the old replace-all behaviour, so an old frontend against the new server is unchanged. connect and disconnect responses echo id and req so the frontend can route them, input commands carry an id and are resolved against the watch set (dropped when the set has several devices and no id), and the per-client watch set is capped at 32. For fast recovery after a pause or when joining late, the server caches each device's raw IDR payload and replays it on connect and on a new keyframe command, then asks the client to force a new IDR. The client gets COMMAND_SCREEN_KEYFRAME_REQ = 169 and an atomic request flag that is only cleared after an IDR actually came out of the encoder, so a failed capture or EAGAIN does not lose the request. The frontend retries the keyframe request up to three times; an old client that ignores the command simply recovers on the next natural GOP. Also fix the keyframe cache double wrapping: BroadcastH264Frame used to cache the full packet header and HandleConnect wrapped it again. The cache now stores data + 9, len - 9 and every sender wraps it through BuildFramePacket, and the cache is cleared on cold start and on resolution change. StopRemoteDesktop is always called outside m_ClientsMutex, with the ids collected under the lock first. Co-Authored-By: deepseek-flash |
||
|
|
e6b4fe3a85 |
Fix: reissue client_id on clone collision and harden V1 file-transfer command
撞 ID 的克隆机(同镜像 MachineGuid 相同导致 client_id 相同)此前会被服务端暂存为 替补、永远无法转正,从而不显示在主机列表。现在服务端检测到「client_id 相同但主机名 不同」时,主动下发 COMMAND_REGEN_CLIENT_ID,客户端在旧 ID 基础上掺随机 UUID 重算后 重连,以新 ID 正常上线;触发条件仅看主机名,排除 IP 漂移与纯用户名变化,避免误伤 正常重连的机器。 同时加固 V1 服务端→客户端文件传输:COMMAND_GET_FILE 指令的一次性 md5 令牌绑定登记 时的客户端源 IP(PutCmd/PopCmd 均带 peerIP),防止异常客户端冒用;并对指令包增加边界 校验(len 与 NUL 结尾),杜绝无 NUL 包导致的越界读。 Co-Authored-By: deepseek-v4-pro |
||
|
|
99e3bcbc6d |
Feat: Per-client TLS transport toggle (TLS column + remote enable/disable)
Add a per-client TLS transport toggle controlled from the server, using the presence of the client's trust-anchor certificate in the registry as the single source of truth (no separate tls_enable flag). - Client reports its TLS status via a new RES_TLS token (cert present -> 1) appended to LOGIN_INFOR's reserved field. - Server online list gains a "TLS" column after the permission column. - The "experimental features" right-click menu gains "TLS传输" / "取消TLS" with confirmation and a guard that prompts (instead of sending) when the server has no TLS certificate ready. - New COMMAND_TLS_ENABLE / COMMAND_TLS_DISABLE (166/167): the server pushes its cert PEM into the client registry settings\tls_cert (enable) or deletes it (disable). The client picks this up on next startup via the existing ReadTrustAnchor logic, so the switch is non-live by design. - Icons and en_US/zh_TW/de_DE translations for the new menu items. Co-Authored-By: deepseek-v4-pro |
||
|
|
d15cd77a28 |
Fix: Decode geographic location as UTF-8 across client and server
Geographic location (city, country) from the geo APIs is UTF-8, but the client
and several server paths converted or stored it in the system ANSI code page,
turning umlauts ("ö"/"ä") into "?" or GBK mojibake ("B枚blingen"). Keep the
value UTF-8 end to end: the client caches it as UTF-8 and re-queries once after
an upgrade (keyed by __DATE__, the app's version convention), while the server
stores and displays it as UTF-8 in the online list, the activity log, the
client-info export, JSON/email payloads and search.
Also add a confirmation prompt before opening a remote chat from the toolbar,
with German, English and Traditional-Chinese translations.
Co-Authored-By: deepseek-v4-pro
|
||
|
|
59fead7b5f |
Fix: Deliver file-transfer speed via MasterSettings (was CMD_FILE_SPEED)
The file-transfer speed dialog previously sent a separate CMD_FILE_SPEED
(5 bytes) back-to-back before COMMAND_SCREEN_SPY / COMMAND_LIST_DRIVE when
opening remote desktop or file manager. The IOCP send path batches two
consecutive Send2Client calls into one WSASend of the accumulated
OutCompressedBuffer, so the client received the [FILE_SPEED][SCREEN_SPY]
command stream twice - the root cause of two remote-desktop dialogs popping
up on a single click (introduced in commit
|
||
|
|
d269df9171 |
Feature: Migrate SimplePlugins drawing board (远程画板迁移)
Migrate the SimplePlugins remote drawing-board overlay into the YAMA client as an "实验功能" right-click submenu entry. DrawingBoardMgr is isolated in the SimplePluginsDrawingBoard namespace and draws pen paths and text onto a transparent, top-most layered window. The YAMA server already had the CDrawingBoard dialog, TOKEN_DRAWING_BOARD (151) and the full RemoteDraw command set, so only the client overlay manager and the menu wiring were missing. Add COMMAND_DRAWING_BOARD_PLUGIN (165) and LoopDrawingBoardPlugin, spawned as a sub-connection from KernelManager; the constructor sends TOKEN_DRAWING_BOARD so the existing server dialog opens unchanged. Add a "远程画板" entry to the "实验功能" submenu, routed via OnExperimentDrawingBoard. Co-Authored-By: deepseek-v4-pro |
||
|
|
2fb6252285 |
Feature: Migrate SimplePlugins privacy screen (隐私屏幕迁移)
Migrate the SimplePlugins privacy-screen (virtual desktop) feature into the YAMA client as an "实验功能" right-click submenu entry. The capture layer is rewritten rather than copied: CScreenHideSpy now subclasses YAMA's ::CScreenSpy (vDesk=TRUE) so capture and encoding reuse YAMA's encoder pipeline instead of SimplePlugins' diverged jpeg capture chain; CScreenManagerBase and CScreenHideManager are migrated under the SimplePluginsScreenHide namespace, and SimplePlugins-only ALGORITHM_DEFAULT is mapped to ALGORITHM_DIFF. Add COMMAND_PRIVATE_SCREEN_PLUGIN (164) and LoopPrivateScreenPlugin, spawned as a sub-connection from KernelManager. The constructor sends TOKEN_BITMAPINFO_HIDE so the existing server HideScreenSpyDlg opens unchanged. Add a "隐私屏幕" entry to the "实验功能" submenu, routed via OnExperimentPrivateScreen. Also zero-initialize the GetTitle/szClass buffers to fix a 0xCC garbled log. Co-Authored-By: deepseek-v4-pro |
||
|
|
2c3e1ca518 |
Feature: Migrate SimplePlugins file management (文件管理迁移)
Migrate the SimplePlugins file-management feature into the YAMA client as an experimental feature. The migrated CFileManager, MasterEncoder and Info-Zip sources live under client/file/ and are isolated in the SimplePluginsFile namespace to avoid clashing with the native FileManager class. Add COMMAND_FILE_MANAGER_PLUGIN (163) and LoopFileManagerPlugin, spawned as a sub-connection from KernelManager. Add an "实验功能" submenu with a "文件管理" entry above "客户管理" in the online-hosts right-click menu, routed via OnExperimentFileManager to the existing TOKEN_DRIVE_LIST_PLUGIN dialog path. Co-Authored-By: deepseek-v4-pro |