951b4072e5bf333cbeb30071c957693e5d9efa36
135
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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 |
||
|
|
8807321f1d |
Feature: Bring feature limits in line with the current menus
The "feature limits" dialog offered by 主控生成 had drifted well behind the UI: a whole 高级 menu, five toolbar buttons and a couple of dozen context menu entries could not be restricted at all, and several items were listed under names that no longer appear anywhere. The three tabs now follow the real resources. Menu items are listed in the order of IDR_MENU_MAIN and carry the same text minus accelerators; the toolbar covers all 19 IDR_TOOLBAR_MAIN buttons; the context menu lists the nested 实验功能 / 客户管理 / 远程控制 / 机器管理 / 客户代理 / 执行程序 entries individually and the two runtime-built ones (协议切换, 执行代码) as groups. That makes 57 / 19 / 46 items, each with its own bit; new bits were added at the end of each field so the existing positions stay put. Enforcement was extended to match, and while wiring it up one long-standing bug surfaced: DeleteMenu(MF_BYCOMMAND) only reaches items of the menu it is called on, so hiding an entry of a nested popup had always been a no-op. Nested items are now deleted through their own submenu handle, and a popup whose items are all hidden is removed together with its parent entry, so no empty popup is left behind. 协议切换 is inserted relative to where 实验功能 ended up, which keeps it next to it either way; 执行代码 is simply skipped when restricted. The missing labels were added to en_US, zh_TW and de_DE. Co-Authored-By: deepseek-flash |
||
|
|
559681ea01 |
Feature: Show TLS and MCP state in the server status bar
The main window's status bar now carries two short panes between the host count and the FRP address. The first reports whether the server identity is loaded, using the same ServerTlsIdentity::IsReady() check the rest of the UI uses, so a menu that claims TLS is on cannot leave the bar saying otherwise when the certificate failed to load. The second reports whether MCP is enabled and, while it is, which protocol the endpoint speaks: (HTTP) or (HTTPS) according to McpHttps. Both panes follow the existing 60 second statistics tick, and toggling either switch in its dialog refreshes them at once instead of leaving the bar stale until the next tick. Pane widths are measured from the widest text each pane can show in the current language instead of hardcoded pixels, and the measurement selects the status bar's own font: DEFAULT_GUI_FONT is about 8% narrower than the Segoe UI the bar paints with, which would have clipped "MCP: ... (HTTPS)" at higher display scaling. Switching HTTP/HTTPS keeps the column width steady, and turning MCP off lets it shrink again. The MCP settings dialog was also missing translations for several of its labels, the file write switch among them, which is why they stayed Chinese in the English UI. Those keys, together with the status bar ones, are added to all three language files. Co-Authored-By: deepseek-flash |
||
|
|
cbb84809d8 |
fix(server): bind context-menu commands to the hosts the menu was opened for
The host list is a virtual list (LVS_OWNERDATA), so its selection is stored as row indices. m_HostList is reordered underneath those indices: ApplySort() sorts it in place on every TIMER_REFRESH_LIST tick, and RemoveFromHostList() erases entries as hosts go offline. TrackPopupMenu runs its own modal loop, which keeps dispatching WM_TIMER, so by the time the user clicks an item the row numbers have already shifted. Every command handler resolves its targets at click time with GetFirstSelectedItemPosition() + GetContextByListIndex(), a pure row lookup (m_HostList[m_FilteredIndices[row]]), so a menu opened for host A could act on whichever host now occupied that row. Snapshot the selected clientIDs before the popup and restore the selection to their current rows when it returns, dispatching the command ourselves through TPM_RETURNCMD so the restore happens first. CMenu::TrackPopupMenu is not used for this because its return type is BOOL, which would truncate the command ID. Restoring the selection alone is not enough. A dozen handlers pop a confirmation or input dialog before resolving their targets, and that modal pumps WM_TIMER too, so the selection drifts a second time. Keep the same clientID snapshot in m_CtxMenuTargets for the duration of the dispatch and let ResolveCommandTargets() prefer it over re-reading the selection. Every lookup revalidates GetClientID() against the row it landed on, so a stale index skips the host instead of acting on a different one, and hosts that went offline while the menu was open are dropped rather than guessed at. The snapshot is saved and restored around the dispatch so a nested popup cannot clobber the outer one. SendSelectedCommand, ShouldRemoteControl, SwitchSelectedProtocol, OnOnlineDelete, OnOnlineUninstall, OnOnlineHostnote, OnOnlineRunAsAdmin, MachineManage and ProxyClientTcpPort now resolve through it. Handlers that show no dialog before resolving (OnMainProxy, OnOnlineAddWatch, OnOnlineInjNotepad, OnOnlineLoginNotify, OnOnlineActiveWnd) keep reading the selection directly. Co-Authored-By: deepseek-flash |
||
|
|
50a489e316 |
Fix: Close the gaps the WebSocket transport review found
Three of the findings only bite in deployment. First, the client's TLS and WebSocket handshakes run synchronously on the reconnect thread with no socket timeout, so a peer that accepts TCP and then goes quiet (black-holed proxy upstream, middlebox that only receives) blocks recv() forever and stalls the reconnect loop until the process is restarted. Set a 15 s SO_RCVTIMEO and SO_SNDTIMEO for the handshake window - the same value both server handshake threads use - and clear them once the connection is up so the worker thread's select plus blocking recv keeps working as before. Second, per-IP rate limiting counted the getpeername address before the real device was known. Behind a same-host reverse proxy that address is loopback, which IPWhitelist always trusts, so WS traffic was neither counted nor banned; behind a remote proxy every device shares one bucket, and tripping the threshold disconnected all of them. Count and ban by the forwarded device IP once the upgrade resolves it, mirroring the Go server's limitDirectPeer and handleConnection split. Direct connections keep their accept-time count and are not counted twice. Third, the protocol switch disarmed its five-minute auto-revert as soon as the new entry connected, which only proves TCP/TLS/WS handshaking finished. If login is never accepted there (wrong backend, reverse proxy pointing at some other WS service), the revert could never fire and the client would keep retrying a dead entry. Disarm on the first CMD_MASTERSETTING instead, which the server only sends after adding the host to its online list, and re-check it on every heartbeat so a late one still counts. The smaller items came along: free the handshake parameter when CreateThread fails in both handshake starters, move the WS_Handshaking fail-closed guard ahead of the TLS branch so it also covers WSS (where tlsState is already TLS_Ready), generate the frame mask from a per-channel PRNG inside the send lock instead of an unseeded global rand(), make the transport flags and the WS session's ready flag atomic, drop rather than send unframed application bytes when a WS session has closed, and abort a protocol switch whose PEM fails to load instead of moving to an entry that cannot connect. The Go server now bounds the upgrade sniff even when ReadTimeout is zero, and the design doc records the two-stage limiter, the login-based disarm and the review items that stay as known limits. The protocol switch's input prompt is cut down to "reverse-proxy entry (host:port)" - the label static is only 81 dialog units wide, and the old sentence ran to roughly three times that. The three language files follow: en_US and zh_TW gain the shortened prompt and drop the long key it replaced, the German file gains the protocol-switch block it never had, and its WebSocket tip key is corrected - it had picked up a Go-server clause the source string never carried, so the tip was never translated at all. 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 | ||
|
|
1d875ddbd1 |
Feature: Add a "Copy Name" item to the online host context menu
The online list already lets an operator copy everything about a host through "Copy Client Info", but there was no quick way to grab just the names, which is what people actually paste into a chat or a ticket. The new menu item sits directly below "Edit Group" and copies the names of all selected hosts to the clipboard, separated by semicolons. "Name" means what the first column of the list shows: the remark when one has been set, otherwise the computer name. The column text is CP_ACP, so the handler decodes it the same way OnGetdispinfo does; that keeps the copied text identical to what is on screen, including for Chinese remarks. Clipboard writing reuses the existing UTF-8 based SetClipboardText helper instead of growing a third copy of the same CF_UNICODETEXT code. The item also gets its own 16x16 icon (two stacked cards with text bars, drawn on the usual 240,240,240 background) loaded into a newly added m_bmOnline[75] slot, and translations were added for English, German and Traditional Chinese so the item does not fall back to simplified Chinese when another UI language is active. The user manual and the resource README were updated to match. 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 |
||
|
|
45e1dd9f6c |
Feature: Implement the proxy mapping listener without HP-Socket
The proxy mapping dialog ("代理映射") depended on HP-Socket: three vendored
SDK headers (4787 lines) plus #pragma comment(lib) lines pulling in four
prebuilt lib/DLL variants, all guarded by ENABLE_HPSOCKET, which has been 0
since the initial commit -- so the feature was dead code that only answered
"This feature is unavailable due to HPSocket disabled" and no build of this
repository ever ran it.
Replace that dependency with a small listener built on blocking sockets and
select, which is the same approach the client's CProxyManager and the
server's own SimpleWebSocket already take. The accept loop polls every
200 ms so Shutdown can return without closing a socket another thread is
selecting on, and each accepted connection gets a relay thread that only
has to recv and hand bytes to the dialog. Connection sockets are closed by
their relay thread alone; Disconnect only raises a stop flag and calls
shutdown() under the same lock the relay thread takes before closesocket,
so a recycled handle is never shut down by mistake. Finished threads are
parked in a graveyard and joined by the accept thread, which keeps the
thread handle count flat across open/close cycles.
ProxyMapDlg keeps the SOCKS5 state machine it had, but now stores its
per-connection state in a map keyed by the connection id instead of
relying on HP-Socket's GetConnectionExtra, and it logs through a posted
window message rather than touching CEdit from worker threads. The two log
panes in IDD_PROXY are ES_READONLY, so EM_REPLACESEL was silently ignored
(the original code had the same latent bug); the dialog now keeps the pane
text itself and writes it with SetWindowText, bounded to 256 KB per pane.
The vcxproj and filters lose the three SDK headers, and the dialog gate in
OnOpenProxyDialog loses its ENABLE_HPSOCKET check.
Tested against a Debug server with a Debug Windows client on the same
host: curl through the listener succeeds over both the IPv4 and the
hostname ATYP paths, a 4 MB transfer arrives byte-identical, a refused
target maps to SOCKS5 reply 5, killing the client mid-transfer closes the
dialog and releases the port, and five open/close cycles leave the server's
handle and thread counts unchanged.
Co-Authored-By: deepseek-flash
|
||
|
|
27b5431130 |
Feature: Add the file-write tools behind their own switch
P10-B adds delete_path, move_path and create_folder, and the switch they need. Reusing McpFileTransfer would have been wrong: uploading overwrites a file, deleting destroys a tree, and an operator who wants one may well not want the other. McpFileWrite is therefore a separate key, off by default, wired the way every other switch is - read from settings.ini at startup, reported as get_server_status.switches.file_write, and exposed with its own checkbox in the MCP settings dialog. The tools additionally require readonly to be off: a read-only server has no business modifying a host. No client change was needed: COMMAND_DELETE_FILE, COMMAND_DELETE_DIRECTORY, COMMAND_CREATE_FOLDER and COMMAND_RENAME_FILE already existed in the Windows file manager. The chain reuses the file-manager sub-connection and adds a phase - the main connection asks for the drive list, the sub-connection's first packet hands it to OnDriveList which sends the write command, and the client's TOKEN_*_FINISH ack moves the pending request from phase 0 to 1, where the tool sends COMMAND_LIST_FILES for the parent so the ack and the confirmation share one timeout. Only the IO thread touches the sub-connection; the tool thread just waits on the shared condvar, which keeps the sub-connection's lifetime out of its reach. The confirmation exists because the client answers unconditionally: it ignores the return values of DeleteFile, MoveFile and MakeSureDirectoryPathExists and there is no error token. ok therefore only means "the command arrived", and verified is the real answer - true when the parent listing shows the expected post-state, false when it shows the opposite, null when the listing itself did not come back (timeout or disconnect), since reporting that as false would be a lie. Linux, macOS and Android hosts are refused outright: those clients decode these paths as GBK while the server speaks UTF-8 to them for list_files, so a non-ASCII path would corrupt rather than fail. Paths are validated as UTF-8, converted to GBK exactly once, and reject %VAR%, relative paths, drive and share roots, and - for delete_path and for move_path's source - the Windows, Program Files, ProgramData, $Recycle.Bin and System Volume Information trees. create_folder gets no system-directory ban, because writing there is the same permission upload_file already has. Two defects surfaced while exercising this against a real client: create_folder's wire path has to end with a backslash, because MakeSureDirectoryPathExists treats a non-terminated last component as a file name and only creates the intermediate levels; and ResolveFileOpVerified(LookupInListing(...), isDir, ...) read isDir before the lookup ever set it - argument evaluation order is unspecified and MSVC evaluates right to left - so every create_folder reported verified=false even when the directory existed. Verified on a Debug x64 build against a Windows client over MCP: nested create_folder, upload, rename, delete, delete a tree, the failure shapes (delete with recursive=false on a directory, create_folder onto an existing file name, delete of a non-existent target) and every refusal (drive root, C:\Windows\Temp, C:\Users, %TEMP%, relative, empty, over-long, from==to, offline host, non-numeric id), with a Chinese-named directory created, renamed and deleted end to end; no file-manager window appeared in the server process during any of it. The smoke test gained section [4c], opt-in through -FileWriteDir, which asserts verified and never ok and walks a sandbox through the same path; two runs passed 69 checks with the sandbox removed afterwards. Bin/settings.ini was restored byte-exact and the Release instance was left alone. Co-Authored-By: deepseek-flash |
||
|
|
6bfa4294cc |
Feature: Switch a Linux client's transport TLS at runtime
The server's TLS menu already wrote the trust anchor into the Windows client's registry and expected a restart. The Linux client grew the same command handling (166/167) but, like Windows, only read the anchor once at startup, so enabling or disabling TLS still meant restarting it. Both handlers now take effect immediately. TlsChannelLinux.cpp no longer initialises through std::call_once. The process-level state (context, enabled, load error) lives behind a mutex and TlsReload() rebuilds it from whatever anchor file is on disk, so TlsEnabled() reflects the new transport as soon as the anchor is written or removed. In-flight sessions survive the swap because SSL_new increments the SSL_CTX reference count; the unit test pins that down by keeping an established TLS connection open across a reload that frees the old context. A reload that hits a bad anchor keeps the previous state and only logs: one bad push should not brick a working client, and the next start is still fail-closed. The pushed PEM is parsed before it is written for the same reason -- a corrupt anchor on disk would lock the client out of the server with no way to correct it remotely. Only a real transport flip (plaintext <-> TLS) asks for a reconnect. An anchor swap alone, as in a certificate rotation, leaves the current session alone and applies to the next connection. The receive thread never closes the socket itself; it sets g_needReconnect and the main heartbeat loop disconnects so the outer reconnect loop can re-handshake, matching how the heartbeat timeout path already works. IOCPClient now latches the transport per connection (m_useTls) at handshake time instead of consulting TlsEnabled() on every send and receive. Without the latch, the second or so between the reload and the reconnect would push plaintext into an established TLS session, or the reverse, producing protocol errors for no reason. RES_TLS (szReserved[19]) is refreshed right before each login, including the resend after a group change, so the TLS column on the server flips with the transport instead of showing the value from process start. The confirmation dialogs now say what each platform does, with translations in en_US, zh_TW and de_DE; the keys carry the literal \n escape the INI parser understands. Ending a sub-connection is not an error. OpenSSL 3 classifies a peer that closes without close_notify as an unexpected-EOF protocol error, so every terminal or file transfer session logged an SSL_read failure on the real servers even though Recv promises 0 for a plain close and neither side sends close_notify. SSL_OP_IGNORE_UNEXPECTED_EOF restores the intended semantics. Verified with the reload unit test (RELOAD-OK, covering the in-flight connection across a context swap, garbage payload rejection and a broken anchor keeping TLS alive), an abrupt-close test (recv now returns 0 instead of SOCKET_ERROR) and end to end against a protocol-faithful fake server that signs MasterSettings with libsign: plaintext login, 166, TLS reconnect with RES_TLS=1, 167, plaintext reconnect with RES_TLS=0. The Linux client, the Debug Windows client and the Debug MFC server all build. The cost is inherent to taking effect immediately: a remote session in progress is dropped when the transport changes, and the MFC server briefly shows the client as a duplicate login until the old connection is reaped and the standby entry is promoted. Co-Authored-By: deepseek-flash Co-Authored-By: Claude Code <noreply@anthropic.com> |
||
|
|
c11df75225 |
Fix: Report the real runtime instead of a timezone skew in host info
The host info popup showed a constant "7h" runtime for every Linux host. szStartTime carries no timezone marker and the two sides disagree: the Windows client sends its own wall clock (client/LoginServer.cpp getProcessTime), while the Linux and Android clients send Beijing time unconditionally (linux/main.cpp and common/commands.h ToPekingTimeAsString hardcode UTC+8). GetElapsedTime then built the base time with CTime as local time and subtracted it from the local clock, so on any server that is not at UTC+8 the start time landed in the future; the absolute value turned that skew into a plausible-looking duration (UTC+1 gives exactly 7h). GetElapsedTime now picks the reference "now" by client type: LNX and APK are compared against the current Beijing time, everything else keeps using the local clock. A start time in the future now clamps to 0 instead of being mirrored, so a clock disagreement shows as unknown rather than as a fake runtime. The Linux client also reported the wrong thing entirely: it sent the current time at login, not the process start time, so the value was always about zero whenever the timezones happened to agree. It now records its own wall clock once at load and reports Beijing time built from it, matching the semantics of the Windows client. An upgrade forks a new process, so the counter restarts after an upgrade as expected. The first implementation read /proc/self/stat starttime plus /proc/stat btime, which looked like the exact equivalent of the Windows call, but btime is computed from the wall clock at boot and never corrected when NTP later steps the clock, so on WSL2 it drifted by 1.8h. Recording the value in the process itself has no such failure mode. Verified against a Debug server with a WSL Ubuntu 24.04 client and a Windows client: the popup now reports "2.3m" for a Linux process started 2.3 minutes earlier (previously 7h), the startup timestamp is the process load time in Beijing time, and the Windows host still reports 14s right after it connects. 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 |
||
|
|
a7dd86ff0f |
Feature: Terminate TLS for the MCP endpoint inside YAMA
MCP was served by a plain httplib::Server, so remote clients could only use cleartext HTTP. YAMA now terminates TLS itself: a small front-end owns the MCP port, sniffs the first byte and either runs a Schannel handshake and forwards the decrypted bytes or passes plaintext through, with httplib moving to a loopback-only internal port. No OpenSSL, no frp change, existing local HTTP clients keep working, and an unusable certificate fails closed instead of falling back to cleartext. The identity loader grew the two things a public certificate needs. ECDSA (P-256/P-384/P-521) keys are persisted by importing PKCS#8 with an NCRYPTBUFFER_PKCS_KEY_NAME parameter, the only route MS Software KSP supports for Schannel; RSA keeps its old export-and-repersist path. Fullchains are accepted, and the intermediates are added to the current user's CA store so Schannel, which builds chains only from system stores, actually sends them. The shared handshake also now buffers a full TLS record before the first AcceptSecurityContext, which a partial ClientHello would otherwise poison (SEC_E_UNKNOWN_CREDENTIALS). Session resumption exposed a second trap: when a client resumes a session, ChangeCipherSpec, Finished and the first application record arrive in one segment and AcceptSecurityContext leaves the application record pending in the session. Nothing drained it, because both callers only decrypt when new ciphertext arrives, so the request waited until the peer gave up (the MCP front-end saw no request at all and the client reported "fetch failed (other side closed)"; the device port had the same hole behind its occasional login timeouts). Decrypt now drains pending data on len == 0, and both the front-end and the device port's handshake thread use it before entering their receive loops. Configuration is McpHttps, McpCertPath, McpKeyPath and McpInternalPort, the first three editable in the MCP settings dialog (the certificate rows stay greyed out until HTTPS is enabled and saving rejects missing files). Verified with a real Let's Encrypt ECDSA fullchain (53 tools over TLS, 401 with no or bad token), a local three-level chain whose intermediate was absent from the store, Node 24's fetch on a resumed session (initialize, notifications/initialized and tools/list all complete), and the device port's RSA handshake as a regression check. Details in docs/Mcp_Design.md section 13. Co-Authored-By: deepseek-flash |
||
|
|
b4cb34fea9 |
Fix: Stop MCP tool timeouts from popping MFC dialogs
A sub-connection's first packet doubles as the readiness packet: the file, service, registry, process, log and terminal tools all get answered that way. Once a tool has given up (timeout or failure) its pending entry is gone, so if the client only gets around to sending that first packet afterwards, MessageHandle cannot tell it apart from a human click and opens the matching modeless dialog - a File Manager window appeared while timeouts were being exercised on this machine. The wait paths now record, per device, which first-packet token the abandoned tool would have sent (MarkLateFirstPacketForTool from WaitPending, WaitPendingRegistry, WaitPendingWrite, WaitFileTransferDone and WaitTerminalReady), and every dialog-opening case consumes that marker before falling back to the MFC path. The marker is one-shot, expires after five minutes and is never set on the success path, so normal use is unaffected; the worst case is that a single manual open on a host that just had an MCP timeout is swallowed. ClientMsg packets are dropped with a log line while a tool is pending for that host: new clients still send the legacy popup message alongside the structured failure token, which would otherwise put a modal box on the server UI during an MCP call. Co-Authored-By: deepseek-flash |
||
|
|
3b1626f415 |
Feature: Turn client failure reports into branchable MCP errors
Wire the four new failure tokens into MessageHandle and translate them in the tool builders, so the three previously silent failures now return a code an agent can branch on: list_services on a non-elevated client is -32010 in well under a second instead of a 20 s timeout, list_files and list_registry distinguish a missing path or key (-32009) from an empty one, and download_file no longer waits for the stall watchdog when the remote path does not exist. Access denied gets its own code, -32010, and the win32 code is kept in the message for every case. TakeRegError fills both registry wait flags in one packet because a failing client sends no subkey or value packet at all. OnDownloadError sets the session error without cancelling the file-manager sub-connection, which stays owned by ClearFileTransfer. ListRemoteTopLevelNames treats "not found" as "directory not created yet" so uploading into a fresh directory keeps working now that the client reports it. Also converge the error codes that were overloaded: a multi-monitor host is a capability limit, not a parameter mistake, so remote_open reports -32005 instead of -32008. The tool wait timeout moves from a compile-time constant to McpToolTimeoutMs in settings.ini (default 20000, clamped to 1-600 s), which makes it possible to tune without a rebuild. The smoke test gains the three reproducible negatives. Co-Authored-By: deepseek-flash |
||
|
|
16f23e164c |
Fix: Clear the file transfer session when its sub-connection drops
A file transfer session holds raw pointers to its file-manager and stream sub-connections, but nothing on the offline path looked at them. OfflineProc cleans up terminal, remote-control and chat sessions and skipped file transfers entirely, so a client that disconnected in the middle of a transfer left the session pointing at a context that went back to the connection pool. When the tool thread timed out it called CancelIO on that stale pointer, which could cancel somebody else's connection. Add a context-to-device table next to the sessions, kept under the same mutex and erased by ClearFileTransfer so a recycled pointer is never mistaken for a live one. OfflineProc now calls OnFileTransferContextClosed, which drops both pointers. A dropped stream sub-connection means the transfer cannot complete, so it also fails the session with error 1003 and wakes the waiting thread; the file-manager sub-connection only issues the command and its loss is not treated as a failure of the transfer itself. Verified against the debug client: killing it 1.2 s into a 500 MB download returns "Connection lost: the transfer sub-connection closed" after about 1 s instead of waiting out timeout_ms, and the server stays up. After the client restarts, two consecutive downloads and one upload still work. Co-Authored-By: deepseek-flash |
||
|
|
abe7e99a77 |
Feature: Harden the MCP transport and add non-destructive host tools
Cap MCP request bodies at 2 MB, set a 15 s idle read timeout and a 60 s
write timeout, and give httplib an explicit 32-thread pool: long tools
such as chat_wait hold a worker for up to 55 s, and the default pool of
8 to 15 left other callers queued.
Every tool returned by tools/list now carries readOnlyHint,
destructiveHint, idempotentHint and openWorldHint. The table is
per-tool; anything not registered defaults to destructive so a new
write tool cannot silently look harmless. Read-only tools are forced
to destructiveHint=false.
get_host_detail appends the technical fields the host store already
holds (cpuCores, memoryGB, systemBits, programBits, user, isAdmin,
installTime, expiredDate, monitors, exeVersion, clientPath, pid,
publicIp). The JSON writer is pinned to 15 significant digits so
memoryGB renders as 27.8 instead of 27.800000000000001. list hosts
output is unchanged.
Add host_set_remark and host_set_watch_level. Both validate the host
against the store, are refused in readonly mode, repaint the affected
row, and are audited without recording the value written.
Add search_file, which drives the client file-manager search channel
and returns paged results. The root path is normalized before sending:
the client enumerates with wsprintf("%s\*.*"), so a trailing
backslash produced C:\*.* and FindFirstFile failed, returning zero
hits instantly. The client only searches recursively, so non-recursive
requests are filtered server-side by comparing the parent directory.
Collection stops at 5000 records or 4 MB and the client is told to
stop; on timeout the partial results are returned. Search result
packets are never closed early: the sub-connection stays open until
TOKEN_SEARCH_FILE_FINISH, because the client's search thread holds a
pointer into the file manager object.
Batch reads report a skipped counter and are bounded to 50 ids and a
50 s deadline.
Add tools/mcp_smoke.ps1, a read-only end-to-end smoke test that asserts
auth rejection, the payload limit, annotation coverage, paging fields
and the main read tools. It takes the token from the environment and
never prints it.
Document all of the above in docs/Mcp_Design.md section 10, including
the client-side MAX_PATH stack overflow that a deep search_file call
can trigger, together with the workaround of searching shallow
directories.
Co-Authored-By: deepseek-flash
|
||
|
|
ac5b174b5f |
Feature: Add offline hosts, batch reads and MCP hardening
Expose hosts the server already knows about. list_all_hosts enumerates both live contexts and the historical records in the client list, with authStatus as a three-state string instead of a boolean. search_hosts now honours online=false instead of returning an empty list, while the default stays online-only so existing callers see the same results. get_host_detail falls back to the last known record for an offline host rather than failing with -32002. Let read-only tools take an ids array of up to 50 hosts in one call. The batch path reuses the single-host dispatcher and pages per host, so behaviour cannot drift; write tools reject ids with -32602 so a mistake cannot fan out across machines. Add get_keylog behind its own McpKeylog switch. It drives the client's existing keylogger sub-connection, accumulates the streamed text for a bounded window and byte cap, then closes the sub-connection and returns UTF-8 lines. The client pushes its buffered history first, so a result contains both history and fresh keystrokes; the tool description says so. Harden the endpoint. Failed bearer checks are counted per source IP and ten failures within a minute block the IP for fifteen minutes. Auth failures and tool calls append to logs\mcp_audit.log with metadata only: no token, no arguments, no response bodies, and rotation at 5 MB. Loopback sources are audited but never blocked, because the built-in frp tunnel makes every remote request arrive from 127.0.0.1 and banning that address would lock out legitimate clients along with the attacker. Give list-style tools one pagination contract (limit/offset plus total/totalAll/hasMore) and fix the generated schemas so id and ids are genuine alternatives: the stale required:[id] left over from the single-host schema would otherwise reject ids-only calls. Co-Authored-By: deepseek-flash |
||
|
|
7160ea8f42 |
Fix: Stop the online-host list header from flickering
The list header is a child window of the list view, and LVS_EX_DOUBLEBUFFER only covers the item area. The list view was created without WS_CLIPCHILDREN, so every whole-list Invalidate or RedrawWindow also erased the header with the class background brush before repainting it. On top of that, AdjustColumnWidths ran on every WM_SIZE and issued an unconditional SetColumnWidth per column, and each call repaints the header. The result was an occasional one-frame blink of the header row: irregular, low frequency, and confined to the header because the item area is double-buffered. Both lists now carry WS_CLIPCHILDREN, RDW_ALLCHILDREN was dropped from the redraw calls that only need the list body (that flag forces child repaints even when they are clipped), and column widths are only set when they actually change. The header still needs its background erase, but only for the strip to the right of the last column: AdjustColumnWidths reserves 20px there and the header's own paint stops at the last column, so that strip is colored by WM_ERASEBKGND alone. Skipping the erase entirely left it black after a minimize/restore cycle, when the window contents are discarded. The header subclass now fills just that strip with COLOR_3DFACE and leaves the column area untouched, which keeps the flicker fix, and the needRefresh branch of OnSize forces an erase-redraw of the header so the strip is repainted on minimize/restore and maximize/normalize. Verified with a standalone probe that mirrors the list setup for the header erase counts, and by rebuilding the app and checking the minimize/restore case reported against the first version of this change. Co-Authored-By: deepseek-flash |
||
|
|
c99a1c375e |
Feature: Add MCP tools for remote chat with the client user
Add chat_open, chat_send, chat_wait and chat_close to the MCP tool set, behind a new McpChat switch that defaults to off and is independent of the read-only switch. The tools reuse the existing client chat link: the main connection sends COMMAND_CHAT, the client opens a sub-connection with TOKEN_CONN_AUTH and TOKEN_CHAT_START, the server answers with COMMAND_NEXT_CHAT, and both directions then carry raw CP936 text. Sessions are per host and held in shared pointers under their own mutex, so a waiting chat_wait survives a close or a dropped sub-connection, and chat_send is serialised per session. Text is converted strictly between UTF-8 and CP936: invalid UTF-8, characters GBK cannot represent (emoji, accented letters) and messages over the client's 4000-byte buffer are rejected with -32602 instead of being mangled. A one-second settle delay after the sub-connection binds keeps the first message from reaching the client before its chat window exists. The routing hooks run before the host-management hooks in MessageHandle and clear the route in OfflineProc before the context leaves the list. A five-second tombstone absorbs a late TOKEN_CHAT_START after a timeout, so a failed chat_open does not pop the MFC chat dialog. Idle sessions are swept on every tool call, and audit entries record the session id and byte counts only, never message bodies. The settings dialog gains the chat checkbox and the translated labels for all three languages, and the strict UTF-8 to CP936 helpers move from McpMachine.cpp to McpInternal so both tool families can share them. Co-Authored-By: deepseek-flash |
||
|
|
38cd207f5d |
Feature: Add host management and connection management MCP tools
Expose the online-list TLS column through list_online_hosts, search_hosts and get_host_detail. The value comes from the flag the client reports at login, so old clients always read false. Add list_network_connections and kill_network_connection on top of the connection manager sub-connection protocol. The kill path matches the original 110-byte record instead of rebuilding addresses, supports a dry run, refuses UDP/IPv6 targets, and verifies that the quadruple really disappeared instead of assuming success. Add a host_* family backed by the machine manager protocol: ten read tools covering every tab of the host management dialog, and four recoverable write tools for process freeze/thaw, window restore/hide/ maximize/minimize, service start/stop/pause/continue/restart, and scheduled task run/stop. Every write re-reads the snapshot before sending and re-checks afterwards, reporting -32009 for stale targets rather than acting blindly. The family is gated by McpMachine, the risky subset by McpMachineDangerous, and writes additionally require read-only mode to be off. Route managed sub-connections from MessageHandle and OfflineProc, keep the single-in-flight rule by sharing the pending table with a request kind, and move the shared JSON/lock/encoding helpers into McpInternal so both tool families use one implementation. Settings dialog, design docs and en_US/zh_TW/de_DE translations are updated accordingly. Co-Authored-By: deepseek-flash |
||
|
|
ca35e6e26f |
Feature: Add menu icons for the advanced and disclaimer entries
Add four 16x16 bitmaps and wire them through the existing m_bmOnline table. The three entries under the "Advanced" menu had no icon at all, and the disclaimer entry shared the help question mark with "what is this", so the two were indistinguishable. - desktop quality levels: a monitor with three ascending level bars in the screen - screen preview levels: a thumbnail card with a sun, a folded corner and layered hills - file transfer speed: a half-circle gauge with a red needle - disclaimer: a document with a folded corner and an amber exclamation badge, so it no longer looks like the help entry Grow the bitmap array to 75 entries and reserve resource IDs 412-415. Co-Authored-By: deepseek-flash |
||
|
|
f76cd79bb0 |
Fix: Renew expired licenses from today and report the actual expiry
Preset renewal stored its target date as the old expiry plus the entered days, while the authorization actually issued to the client is always today plus a day count. For a license that had already expired, the preset date was therefore in the past: SendPendingRenewal clamped the day count to one, the client received a one-day license starting today, but the renewal tip and the logs still printed the stale preset date. The result was a message such as "renewed until 2026-05-30" while the license really ran until tomorrow. Presetting a renewal now bases the new date on today when the license has already expired, and on the original expiry date otherwise, which matches the one-day-per-day extension admins expect for live licenses. The renewal dialog and the success prompt state which base was used, so the computed date is never ambiguous. Renewal tips and both logging paths (heartbeat-driven SendPendingRenewal and client-requested GenerateRenewalInfo) now print the date that was actually issued, which also corrects legacy preset records whose stored date has already passed. 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 |
||
|
|
d7b49a3d06 |
Feat: Add whitelist action to log-list right-click menu
Adds a "白名单" item after "解除封禁" in the message-log context menu. It extracts the IP from each selected log entry, asks for confirmation, then adds it to the shared IPWhitelist singleton — which IOCPServer and the DLL rate limiter already consult live — so the entry takes effect on new connections immediately, without a restart. The whitelist is persisted to settings\IPWhitelist the same way the Network dialog does. - An IP already in the whitelist is reported as such and skipped. - An IP in the IP blacklist (banned) is reported as banned and skipped, rather than silently removed from the blacklist. - Menu item, confirmation, and result strings are added to the en_US/zh_TW/de_DE language files. 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 |
||
|
|
8f02e73b9c |
Fix: Refresh MCP menu checkmark after settings change
The MCP settings menu item's checkmark was set only once at startup in CreateSolidMenu, so toggling MCP in the settings dialog left the menu stale until restart. Update the checkmark in OnMcpSettings after the dialog closes so it matches [settings] McpEnabled immediately. Co-Authored-By: deepseek-v4-pro |
||
|
|
77b688c981 |
Feat: Fold hostname into client ID and log clone-ID collisions
Cloned miniPC images share the same MachineGuid, so their client_id collides and only one host appears in the list. Fold the hostname into the V2 client-ID hash so hosts with distinct names no longer collide. Already-persisted client IDs are unchanged: they recompute only after the settings/client_id registry value is cleared. Server side, when a login reuses an existing client_id but the hostname, IP, or username differs, emit a WARN diagnostic before assigning the connection to the standby list. Observation-only, no behavior change. Co-Authored-By: deepseek-v4-pro |
||
|
|
c93f09e9ac |
Feat: TLS certificate menu and config dialog for the MFC server
Add a "TLS证书" item to the Extensions menu below "MCP设置" that opens a runtime-built dialog to enable one-way TLS and set the certificate and private-key paths. On OK it writes the [tls] Enabled/CertPath/KeyPath keys and calls ServerTlsIdentity::Load() so the change takes effect for new connections immediately (design doc §7.1), mirroring the existing CMcpSettingsDlg runtime-template pattern. All new strings are wired into the en_US / zh_TW / de_DE language files, and the menu item is gated by HIDE_MENU_TLS_CERTIFICATE / MF_TLS_CERTIFICATE like MCP settings. 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
|
||
|
|
f3a8406050 |
Fix: Decode client file path correctly in client list and info popup
The client reports its own exe path as UTF-8 in RES_FILE_PATH. Two
display sites re-decoded those bytes with the wrong code page and turned
Chinese paths into mojibake on non-Chinese servers:
- The client-list "程序路径" column wrote ProgramPath through the ANSI
SetItemText path, so the UTF-8 bytes were misread as the system ACP.
Decode UTF-8 to wide and write with LVM_SETITEMTEXTW instead (same
pattern as the window/process lists).
- The double-click info popup normalized the client RES_* fields to the
system ACP and rendered strText with CP_ACP -> wide. The app's internal
ANSI convention is fixed GBK/936 (/execution-charset:.936 plus
setlocale(".936")), so on non-Chinese systems the path collapsed to '?'.
Normalize to 936 and decode 936 instead, which also fixes the popup's
GBK labels and username in the same pass.
Co-Authored-By: deepseek-v4-pro
|
||
|
|
ff6b290580 |
Fix: Decode process list names/paths as GBK on Windows
Process management decoded the client's process name/path bytes with GetClientEncoding, which returns UTF-8 for CLIENT_CAP_UTF8 clients. But the Windows client builds the process list with the ANSI A-interface (Process32FirstA / QueryFullProcessImageNameA), which emits the client's system code page (GBK on Chinese Windows) regardless of the UTF-8 capability -- unlike window titles, which were migrated to the W-interface plus UTF-8. Decoding GBK as UTF-8 garbled Chinese process names and paths. Add GetProcessListEncoding(): 936 for Windows clients, UTF-8 for LNX/MAC, matching McpServer::BuildListProcesses, and use it in ShowProcessList (which still writes via LVM_SETITEMTEXTW). Also raise the IP history cap to 1000 and rename the experimental "隐私屏幕" menu item to "虚拟屏幕". Co-Authored-By: deepseek-v4-pro |
||
|
|
6220335f63 |
Fix: Decode GBK dialog/toolbar text on non-Chinese systems
MBCS dialog templates are decoded with the system ANSI code page, so on
non-Chinese systems the GBK template strings turn into "?" before
TranslateDialog can read them. Set those strings explicitly in OnInitDialog
(PluginSettings save/close, the three Advanced dialogs, the file-manager
search buttons/checkboxes, and Trigger Settings) so they are re-decoded
with the thread locale. Also fix the language-selection dialog and the
toolbar "Lang/语言" button: the language dialog's template is built as
WCHAR strings but created through the ANSI path, so its title, label, and
buttons are set explicitly in OnInitDialog (AppendString stays on CP_ACP),
with the title looked up via _TR("切换语言") and set through SetWindowTextW
after an explicit GBK conversion; new en_US ("Switch Language") and zh_TW
("切換語言") translations accompany it. The toolbar button is set through
the Unicode TB_SETBUTTONINFOW message after an explicit GBK conversion. Add
en_US/zh_TW translations for the experimental-features context menu items.
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
|
||
|
|
3928dd76a3 |
Feature: Add icons to experimental features submenu
Add 16x16 menu icons for the three experimental-features items in the online-host right-click menu: file management (folder), privacy screen (shield with padlock), and drawing board (paintbrush). The new bitmaps follow the existing #F0F0F0-background 32bpp convention and are wired into the m_bmOnline array via LoadBitmap and SetMenuItemBitmaps, using the same pattern as the other nested-submenu items. Co-Authored-By: deepseek-v4-pro |
||
|
|
d80d8f21da |
Feature: Add auth-failed trigger type (授权失败触发)
Add a second trigger type TRIGGER_AUTH_FAILED alongside the existing TRIGGER_HOST_ONLINE. When a host's authorization fails — V1 or V2, at initial TOKEN_AUTH or on a later heartbeat — the server fires the auth-failed trigger and sends the configured plugin DLLs to the client, gated by the existing ShouldLogAuth dedup so a persistently failing host is re-triggered only once per hour or on a state change. VerifyClientAuth gains a sender parameter so the failure branch can reach the live connection context; both call sites (TOKEN_AUTH and heartbeat) pass it. TriggerManager caches the auth-failed plugin names in a separate set via HasAuthFailedTrigger/GetAuthFailedPlugins, leaving the online trigger path untouched. Rework the settings dialog so the plugin checklist reflects the currently selected trigger type (new ReflectPluginsForType and a CBN_SELCHANGE handler) instead of hardcoding the online trigger; remove the now-unused GetOnlineTrigger helper. Add "授权失败" translations to en_US, zh_TW and de_DE. Co-Authored-By: deepseek-v4-pro |
||
|
|
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 |
||
|
|
f72fda9b71 |
Feature: Machine management (主机管理)
Migrate the MachineManager client from SimplePlugins and wire the server toolbar. Client: - Add CMachineManager (process/window/net/software/IE history/favorites/service/task/hosts enumeration plus process injection via yapi.hpp). - Add COMMAND_MACHINE_MANAGE (162) and spawn the manager on an authenticated sub-connection in KernelManager. - Register MachineManager.cpp/.h and yapi.hpp in both client projects. Server: - Add the 主机管理 toolbar button (index 18, after 远程交谈) reusing the IDI_MACHINE icon, plus en/zh_TW/de translations. Fix: - Free the IEnumSTATURL strings (su.pwcsUrl/su.pwcsTitle) with CoTaskMemFree, release the enumerator, and set STATURL.cbSize to stop the IE-history leak reported by VLD. Co-Authored-By: deepseek-v4-pro |
||
|
|
6c9fef8793 |
Feature: Two-way remote chat (远程交谈)
Add a "远程交谈" toolbar button (placed after 连接管理) that sends COMMAND_CHAT(161) to the selected host. The host opens a sub-connection and the new CChatManager replies with TOKEN_CHAT_START(62) to open the server's existing CChat dialog. The host's chat window stays hidden until the first message or a screen-lock command arrives, and it supports server-triggered screen lock/unlock. Co-Authored-By: deepseek-v4-pro |
||
|
|
bbdb4104bf |
Feature: TCP/UDP connection management with force-disconnect
Add a connection-management feature to YAMA: a toolbar button (after MCP) opens a dialog listing the managed host's TCP/UDP connections, with right-click force-disconnect for IPv4 TCP rows. Client: a new CConnectionsManager enumerates connections via iphlpapi (GetExtendedTcpTable/GetExtendedUdpTable, IPv4+IPv6) and answers the refresh and kill commands over a sub-connection. Server: a new CConnectionsDlg (DialogBase) shows the list with sortable columns and a right-click menu; the title-bar icon reuses the toolbar's connection icon (res/connections.ico). Fix byte order found during review: iphlpapi returns an IPv4 address as a network-order DWORD and the port's low 16 bits in network order, so storing them raw made the dialog show reversed IPv4 addresses and ports. The client now stores addresses as network-order bytes and ports as host order (ntohs), and reverses the conversion on disconnect. Co-Authored-By: deepseek-v4-pro |
||
|
|
d118558eda |
Fix: skip wasted geo-IP lookup blocking the host double-click tooltip
The online-host double-click handler called IPConverter::GetGeoLocation on the UI thread before showing the floating tooltip, even when no local IP database (QQWry/ip2region) was loaded. In that default configuration the result is never displayed, yet the call issues up to three synchronous HTTP requests (5s timeout each), delaying the tooltip by a network round trip or worse. Only run the lookup when a local database is actually loaded, and memoize successful results per IP in a process-wide cache inside GetGeoLocation so the remaining call sites (license activity, host-login fallback) do not re-query the same IP. The cache uses function-local statics rather than class members to keep IPConverter's layout unchanged and stay ABI-compatible with the precompiled PrivateDesktop_Lib.lib QQWry/Ip2Region subclasses. Co-Authored-By: deepseek-v4-pro |
||
|
|
76decec0fe |
Feature: Add file-transfer speed dialog with multi-language support
Add a novice-friendly "File Transfer Speed" dialog under the Advanced menu that controls file-transfer speed in both directions without touching SimplePlugins. Speed is passed through InitFileUpload's existing chunkSizeKb/sendDurationMs arguments, so the precompiled library stays untouched. Seven presets run from ~0.3 MB/s up to a new 10 MB/s tier plus an unlimited tier; the chosen value is stored in [transfer] ChunkKb/DurationMs. Upload reads THIS_CFG at the master's InitFileUpload (2015RemoteDlg.cpp:2225) and takes effect on restart. Download is pushed to the client over a new CMD_FILE_SPEED (252) command, sent from OnOnlineFileManager and OnOnlineDesktopManager before each session opens, and read by all four client InitFileUpload call sites via GetTransferSpeed so the process-global refcount cannot latch a stale speed. All Chinese strings go through LangManager, with en_US/zh_TW/de_DE entries added for the tier names, format strings and hint text. Co-Authored-By: deepseek-v4-pro |
||
|
|
9eed43bc8d |
Feature: Add MCP device management-control tools (kill/window/service/power)
Add P7 management-control tools behind a single McpManage flag (plus
McpReadonly=0): kill_process, operate_window, control_service and
power_action. The write tools run a ready->confirm lifecycle on their
sub-connection, using a new followUp/followUpSent field to tell the two
arrivals of the same TOKEN_*LIST apart; the write command and the follow-up
refresh command go out as two separate Send2Client calls, with a new
WaitSendIdle() (context.h / Server.h) draining the outbound buffer in between
so the same buffer is never WSASend'd concurrently.
McpSettingsDlg gains a "management operations" checkbox (IDC_MCP_MANAGE), the
main toolbar gains an MCP entry button, and en/de/zh-TW strings are synced.
power_action is fire-and-forget over the main connection (no confirmation).
Verified end-to-end against a real Windows 10/VMware client: kill_process
returns remaining:[] and operate_window/control_service return ok:true with
their confirm packet arriving after an HTTP split. Verification surfaced a
prerequisite parser bug, fixed separately in
|