Add the v1.0 design for the Go-side minimal MCP server (nine read-only
tools over hub, audit log, terminal and file channels) and the staged
plan that turns it into eight commits.
Record the five decisions settled before construction: extract the audit
query scanner into server/go/auditquery, inject version and commit via a
buildinfo package plus go-winres, treat mcp/tools.json as the only tool
schema contract, verify against a real client, and expose seven tools in
readonly mode.
Add the M0 findings: TestRun.exe cannot log in, because it needs
ServerDll.dll loaded through MemoryDllRunner and the release build deletes
itself when started outside its install path. A Debug ghost.exe came
online against a local Go server in trial signer mode within ten seconds.
Co-Authored-By: deepseek-flash
OnTerminalClosed now erases the shell route and nulls the session pointer
before OfflineProc returns that context to the pool, and WaitTerminalReady
re-looks-up the session on every wake, failing with cleanup when it is gone,
closed, or has no sub-connection. Before, a waiter could CancelIO a recycled
context, or a late cleanup could unroute a connection that reused it.
terminal_close only set closed and expected a waiter to clean up, so after a
caller timeout the remote shell kept running and the slot stayed busy for an
hour. A waiters counter now separates the cases: with a waiter the close
hands off, without one it erases the session and cancels IO at once.
WaitTermCommand's closed branch keeps a truncated tail pollable instead of
dropping it, cancelling IO immediately, and the drained poll cleans up.
The write side had the same hazard. exec_command, terminal_exec and
http_probe wrote the command line after the prompt wait without rechecking
the sub-connection; IsTermSubCtxLive now skips the write when the shell has
died, and WaitTerminalDone reports closed on every failure path so callers
never CancelIO a pointer that may be back in the pool.
list_hosts, read_file and http_probe were missing from kToolHints and got
destructive defaults; the first two are now read-only/idempotent, http_probe
stays writable because its method can mutate the probed service.
Verified on the isolated Debug instance: the truncated tail drains without
gaps (12514 lines), a waiterless close frees the slot in 0.1s, and the
terminal, exec_command, http_probe, 8a/8b/8c and verify_tools checks pass.
Co-Authored-By: deepseek-flash
operate_window / host_control_window and control_service / host_control_service were two
implementations of the same intent. tools/list now exposes exactly one of each pair,
chosen by McpMachine: the host_control_* names when host management is enabled, the
main-connection names when it is not.
The advertised tool accepts the union of actions. host_control_window routes close/show
to the main-connection implementation, which stays the only path with close/show
semantics and requires McpManage; the machine path keeps its post-action verification
for restore/hide/maximize/minimize/activate. host_control_service routes
set_auto/set_manual the same way and rejects dry_run for them instead of pretending to
run one. Both old names remain callable aliases, and service_name is accepted as an
alias for the machine tool's name parameter.
The manifest generator treats the two main-connection tools as !machine entries, so the
two-capture union still covers both states. tools/list is 49 entries when everything is
on (was 51) and 47 when host management is off; the response shrinks from 193,008 B to
168,634 B (-12.6%), short of the 15% estimate because state-conditional tools must stay
in the manifest. The plan document records that measurement and the reason.
Verified with a dedicated two-state test: visibility matrix, close/show and
set_auto/set_manual routing through dry_run and validation paths, alias dispatch, and
-32006 for host_* names when host management is off. Step 8a/8b regressions and
verify_tools --live still pass.
Co-Authored-By: deepseek-flash
host_inspect now covers processes, windows and services, so with
McpMachine=1 the older list_processes / list_windows / list_services
entries only competed with it: same intent, two names, two long
descriptions to read before choosing. They no longer appear in
tools/list while host management is enabled, but their names still
dispatch, so callers that cached them keep working.
They must stay visible when McpMachine=0: that is the default state and
the only way such a server can list processes, windows or services, so
the entries sit behind !IsMachineEnabled() rather than being removed.
list_network_connections is deliberately not folded in: it reads the
connection-manager view (IPv6 rows, killable flag, numeric state) which
host_inspect's IPv4-only network aspect does not provide.
tools.json is now generated from two captures, all-switches-on plus
McpMachine=0, because neither state contains the whole surface; the
off-state entries are marked gate "!machine" and verify_tools.py skips
them when comparing against an all-on server. tools/list went from 54
to 51 entries and from 183,336 B to 171,929 B (-6.2%).
Co-Authored-By: deepseek-flash
The ten read-only host-management tools (host_list_processes, windows,
network_state, software, browser_history, favorites, win32_services,
driver_services, scheduled_tasks, host_get_hosts_file) each carried a
name, description and schema for what is one connection to the host,
one tab id per aspect and one paged list shape. Ten entries made
tools/list hard to scan and took a large share of the description
budget.
They are now one tool, host_inspect(aspects[], ...), where aspects is a
required, deduplicated array of the ten former names. A single aspect
returns exactly what the old tool returned (same builder, same code
path), so output is byte-identical; several aspects are fetched over
separate managed sessions and merged into results.<aspect>, with
failures isolated in errors.<aspect> and isError only when every aspect
failed. Filters (pid/name/arch/title/url/publisher/folder/status/
start_type/process/protocol/ports/state/max_bytes) are still applied
server-side before paging and are ignored by aspects they don't apply
to.
The old names stay as dispatch aliases so existing callers keep working
but no longer appear in tools/list; the platform table, batch read-only
list, tool hints, instructions, generator tables and the captured
mcp/tools.json move to the new name (63 tools -> 54).
The description also notes that win32_services / driver_services need
an elevated client: a non-elevated one cannot open SCM and never
answers, so the call times out after ~12 s.
Co-Authored-By: deepseek-flash
get_client_log reads the YAMA client's own in-memory ring buffer, but its
description could easily be read as "the logs of whatever program runs on
the host". That misreading sends callers looking for business logs into
the wrong tool and back out empty-handed.
The description now opens by saying this is not the business program's
log, points at read_file with offset=-N for reading files on the host,
and states that this tool is for client/connection troubleshooting.
read_file's description gains the same explicit offset=-N hint at the
tail where log-reading is recommended.
Descriptions only - no behavior change. mcp/tools.json regenerated from
the live capture.
Co-Authored-By: deepseek-flash
list_online_hosts, search_hosts and list_all_hosts differed only in
whether offline hosts were included and in which filter fields they
accepted, which made the host-list surface confusing and duplicated
three handlers over the same CollectAllHosts snapshot.
They now share one tool, list_hosts(query?, online?=true,
include_offline?=false, group?, os?, client_type?, limit?, offset?).
The old names stay as aliases routed to the same handler, so existing
callers keep working, but tools/list exposes only list_hosts. The
legacy "offline" boolean of list_all_hosts is still honored, and
list_all_hosts keeps its online+offline default.
With offline history included the list is now ordered online-first:
the host library holds thousands of records, so the default page of
100 would otherwise be all stale entries and the online hosts a caller
can actually operate on would be buried behind paging.
instructions, every id-description string, the platform table, the
tools.json generator and the captured mcp/tools.json are updated to
the new name (65 tools -> 63).
Co-Authored-By: deepseek-flash
Run an HTTP/HTTPS request inside a shell on a managed host and return a
structured result: status code, headers, body (UTF-8 or base64), size and
elapsed time, so interface health on the host or its subnet can be checked
without a full remote-control session.
The safety boundary is hard-coded on the server, not in the shell script:
only http/https and IP literals (or localhost); only loopback and private
ranges (127/8, ::1, 10/8, 172.16/12, 192.168/16) are accepted; redirects
are not followed; the body is capped at 64KB; TLS certificates are
verified. Domain names are refused on purpose - resolving them on the
server would probe the wrong network.
Windows runs a single-line PowerShell 2.0-compatible script based on
HttpWebRequest. Accept/User-Agent/Referer are mapped to their dedicated
properties because .NET rejects them through Headers.Add. Linux uses curl
with temp files.
Payloads cross the terminal channel as 56-character base64 chunks with a
declared byte length. ConPTY re-emits the boundary character of lines
wider than 80 columns, so single-line base64 arrives corrupted; the length
check converts any remaining loss into an explicit error rather than
silent garbage.
The tool reuses an existing persistent terminal session. Sessions it
creates itself are closed after the command and kept only when the probe
timed out while still running. Platform gating: Windows and Linux only.
Co-Authored-By: deepseek-flash
read_file fetches a single remote file through the existing V2 download
channel into a per-call temp directory, decodes it, and deletes the temp
files on every exit path. It returns the file size, detected encoding, EOL
style, total line count, the requested slice (negative offset counts from
the end), a truncation flag and the whole file's SHA-256.
Encoding auto-detection follows BOM -> UTF-8 validity -> GBK fallback, and
utf-8/gbk/gb18030/latin1 can be forced. Files above 2MB and directories are
rejected from the first chunk, so nothing is written to disk for them.
The tool is gated by McpFileTransfer only: it never writes to the remote
host, so it stays available in readonly mode.
The V2 receive path now serves both download_file and read_file.
Co-Authored-By: deepseek-flash
terminal_exec no longer requires session_id. Given a command and no
session_id, it reuses the host's persistent terminal session or opens one
through the same path as terminal_open, and reports session_id, is_pty and
reused in the result so the caller can keep using it. Polling still
requires the session token.
terminal_open now returns the existing session with reused:true instead of
-32003 when one is already active. An implicitly created session is
invisible to the caller, so rejecting would silently lock the host's single
terminal slot and leave exec_command failing with a busy error. A session
that is still starting, or one owned by a one-shot exec_command, still
answers -32003.
The server instruction line that told models to always pair terminal_open
with terminal_close is updated accordingly.
Co-Authored-By: deepseek-flash
terminal_exec used to destroy the persistent session on timeout, so long
commands (robocopy, upgrade scripts) could never be observed: the collected
output was thrown away and the shell was killed. Waiting is now decoupled from
the command:
- WaitTermCommand delivers [delivered, ...) and no longer erases on timeout.
It returns done:false plus the output produced so far; the session stays
busy and polling continues until done:true with exit_code.
- Calling terminal_exec with only session_id polls (no command); command is
optional and the result gains session_id / done / truncated / dropped_bytes
/ elapsed_ms.
- Request cancellation still destroys the session (-32800 path); shell exit
and terminal_close deliver the remaining output and then clean up.
- Chunks are capped at max_output_bytes (default 64KB, newline-aligned); the
per-command buffer is capped at 8MB and reports dropped_bytes; busy sessions
are force-reclaimed after an hour so a host cannot stay busy forever.
- A finished command with undrained output returns -32003 with a drain hint
instead of silently losing it when the next command clears the buffer.
Verified on an isolated Debug instance against a Windows host: a 3s timeout on
an 8s ping returns done:false + partial output and two polls finish it; a
277KB dir listing needs 5 polls and then accepts a new command; 200 echo lines
delivered in 12 chunks arrive exactly once in order; cancel returns -32800 and
destroys the session. tools.json regenerated (63 tools, PASS).
Co-Authored-By: deepseek-flash
exec_command's read-only default whitelist only listed `sc query`, so service
configuration inspection was rejected even though `sc qc` is a read. Add
`sc qc`, `sc enumdepend` and `sc sdshow`; `sc start/stop/config/create/delete`
stay rejected because matching is prefix based, and a comment says so.
verify_tools.py --live now prints the tools/list response size plus the
description / inputSchema / outputSchema breakdown, so shrinking tools/list can
be measured against a running server.
Verified on an isolated Debug instance (port 6555, local test client): sc
qc/enumdepend/sdshow/query succeed; powershell, icacls, net user, net
localgroup, sc start and `&` chaining still return -32007/-32012; tools.json
still matches the live tools/list (63 tools, PASS).
Co-Authored-By: deepseek-flash
The v1 plan was written without measuring the live server. Re-measure and fix
it against the code:
- tools/list response is 193,008 B (tools array 136,692 B; description 31,874 /
inputSchema 44,192 / outputSchema 49,320), not 103,158 B; the >=15% goal now
refers to this baseline.
- TermSession::sentPos is the sentinel offset, not a delivered cursor, so
P0-2 introduces a real `delivered` cursor instead of reusing it.
- The whitelist additions icacls / net user / net localgroup are writes under
prefix matching; only sc qc / enumdepend / sdshow qualify.
- "file too large" uses -32602, not the invented -32011 (destination write
failure).
- P0-3 gains four prerequisites (size pre-check, McpFileTransfer gate, RAII
cleanup, sha256/lines_total semantics); P0-1 spells out the default-session
slot hazard; the stage order is P0-4 first since it is the cheapest win.
Appendix B records how the baseline was measured (verify_tools.py --live).
Co-Authored-By: deepseek-flash
`build server-linux` now builds the Go server as a Linux/amd64 binary at
Bin\server_linux_amd64 instead of the Windows YamaGo_x64.exe, so the
artifact can be copied to a Linux host as-is. It reuses the go-server
flow: web asset sync, Release builds strip with -s -w (debug keeps
symbols), and the caller's GOOS/GOARCH/CGO_ENABLED are restored
afterwards so a direct .\build.ps1 run does not leak the cross-compile
environment into later builds.
UPX compression is skipped for Linux output (the script only ships
upx.exe for the Windows build) and logs a warning instead.
Verified: the generated binary is a stripped static ELF that runs under
WSL and prints its flags.
Co-Authored-By: deepseek-flash
The Go server answered TOKEN_HEARTBEAT with a 33-byte CMD_HEARTBEAT_ACK,
while the Linux and Android clients gate the ACK on 1 + sizeof(HeartbeatACK)
(1025 bytes) and silently drop anything shorter. Their application-level ACK
watchdog therefore never got fed and disconnected the main connection every
60s. Each re-login replaced the whole hub.Device, wiping the screen/shell
sub-conn bindings that ride their own TCP connections, so a web terminal kept
receiving shell output while every keystroke was dropped — the "terminal goes
unresponsive after a while" symptom — and the shell could no longer be torn
down (orphan bash + leaked sockets).
Clients now accept the 32-byte old ACK (Windows already did), and the server
sends the full 1024-byte struct. Hub.Register carries the sub-conn session
state across a re-login, and the disconnect cleanup is pinned to the
connection it belongs to so a stale OnDisconnect cannot tear down a
registration that has already replaced it. A shell sub-conn that can no
longer be bound now tells the viewer instead of leaving the pane waiting.
Verified on aa: RTT restored, zero "Heartbeat ACK timeout" lines, main-conn
port stable; Go build/vet/test pass. Server deploy to the Go host is still
pending, so un-upgraded clients will keep reconnecting until then.
Co-Authored-By: deepseek-flash
The master's voice monitoring menu sends COMMAND_AUDIO; the client opens a
ConnAuth sub-connection with TOKEN_AUDIO_START, the server opens CAudioDlg
and answers COMMAND_NEXT, then audio flows both ways. The protocol matches
the Windows client, so the server needs no changes.
The server's ACM format was read from Audio.cpp and AudioDlg.cpp first:
WAVE_FORMAT_GSM610, 8000 Hz mono, 65-byte blocks of 320 samples (40 ms),
about 1625 B/s. libgsm 1.0.13 (AOSP external/libgsm mirror) is vendored
under cpp/gsm and built with -DSASR -DWAV49 so its MS-GSM packing is
byte-identical to ACM GSM610. Encode and decode use separate gsm states
because frame_index/frame_chain live in the state.
Uplink packets are always exactly 1000 bytes: CAudio::PlayBuffer copies
1000 bytes from the buffer start regardless of packet length, so a short
packet would over-read. Since 1000 is not a multiple of 65, blocks
straddle packets; the stream is continuous and codec state carries over.
AudioMonitor.kt owns AudioRecord (8 kHz/16-bit/mono, 320 samples a read)
and AudioTrack playback of decoded downlink PCM. RECORD_AUDIO is requested
with POST_NOTIFICATIONS before the projection dialog, and CaptureService
adds the microphone FGS type only when held, falling back on failure. An
8-second dialog wait or missing microphone reports a tip to the master
instead of failing silently.
Verified on an Android 15 emulator against the Debug server: dialog
opened, uplink started, server receive counter grew at ~1.6 KB/s.
Downlink playback was not exercised (the test machine has no recording
device); that path is code-reviewed only.
Co-Authored-By: deepseek-flash
The Android client dropped CMD_QUALITY_LEVEL, CMD_FPS, CMD_QUALITY_PROFILES
and CMD_SCREEN_TUNING as log lines, and hardcoded ScreenSettings.QualityLevel
to Good. Because the server initializes adaptive quality from the client's
reported level, that hardcoded value pinned every Android session to a fixed
profile: adaptive quality could never start.
ScreenTuning.kt now owns the state in SharedPreferences (level, max fps and
the master's six-row profile table), and C++ only parses the wire format.
The level is persisted when the master sets it explicitly, including -1
adaptive and -2 disabled, and is reported back in TOKEN_BITMAPINFO on the
next screen session. A concrete level switch applies the profile bitrate at
runtime via MediaCodec.setParameters(PARAMETER_KEY_VIDEO_BITRATE), which is
smooth and needs no encoder rebuild.
Frame rate is stored as-is (255 = unlimited, matching Windows) and only
reaches KEY_FRAME_RATE at the next capture start, since surface encoders
have no runtime fps cap. Ultra and High default to a zero bitrate because
their Windows algorithms are DIFF/RGB565, so Android falls back to the
previous 4000 kbps. CMD_SCREEN_TUNING stays log-only: all four flags belong
to the Windows capture/x264 path and Android does not claim
SCREEN_CAP_TUNING_FLAGS. CMD_SCREEN_SIZE is ignored; the server's pending
resolution-change mark self-heals after one second.
Verified on the emulator: a seeded Level 5 starts capture at 800 kbps/8 fps
and the server title shows Minimal; a master-side switch to Good changes the
live bitrate to 3000, and a restart picks up fps 30 from CMD_FPS.
Co-Authored-By: deepseek-flash
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
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
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
WaitChatMessages decided overtime after the drain loop had already
emptied the session inbox. Whenever a reply arrived during the wait the
loop moved every queued message into the result and then evaluated
timed_out on the now-empty queue, so a successful wait was still
reported as a timeout. Callers that key off timed_out would either
retry needlessly or treat the answer as noise.
The arrival state is now captured before draining and the deadline flag
is computed from that snapshot. A wait that returns messages is never
marked timed out, while an empty wait still reports timed_out so the
caller can distinguish silence from a closed session.
Verified end to end against the Android emulator over the MCP debug
endpoint: after a device reply chat_wait returned one message with
timed_out=false, and a follow-up wait on the empty inbox returned
timed_out=true, preventing a regression in the other direction.
Co-Authored-By: deepseek-flash
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
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
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
Five review findings from the screen-preview work, all in the same
connection plumbing.
The main client handle is now a shared_ptr taken through GetMainClient().
ScreenPreviewThread, ActivityReportThread and sendClientMsg run detached
and can outlive ConnectionThread's teardown, so a raw pointer snapshot
could dereference freed memory; the copy they hold now keeps the client
alive until the send is done. sendClientMsg also uses one handle for
both the connected check and the send instead of reading the global
twice.
The reconnect loop now checks its connection generation in every
condition, so a thread that was asked to stop can no longer reconnect
after a quick nativeStop -> nativeInit reset g_bExit and g_running into
"running again", which produced two main connections with the same
client ID.
ActivityReportThread gets the same try/catch and RAII in-flight counter
as the preview thread: an exception used to call std::terminate, and one
failure left the counter above zero, silently dropping every later
get_activity_history.
nativeStop now stops the activity sampler, and Stop() clears m_started
so a service restart can start it again. Sub-connections (remote screen
and client log) now inherit g_SETTINGS.protoType like the main
connection; without it they silently dialed plain TCP even when WS/WSS
was configured.
Verified on the emulator against a local debug server: get_screenshot,
get_activity_history and get_client_log all still answer, and the log
sub-connection completes the TLS handshake.
Co-Authored-By: deepseek-flash
get_screenshot and the server's online-list and hover thumbnails were
gated to Windows and X11 Linux. The Android client now answers
COMMAND_SCREEN_PREVIEW_REQ on the main connection with
TOKEN_SCREEN_PREVIEW_RSP plus a JPEG, and advertises
CLIENT_CAP_SCREEN_PREVIEW at login only when it can really capture.
Capture goes through AccessibilityService.takeScreenshot (API 30+),
enabled by canTakeScreenshot in the service config. MediaProjection is
deliberately not reused: its VirtualDisplay already feeds the H.264
encoder and Android 14+ refuses a second one from the same projection,
while accessibility capture runs alongside the live stream. The JPEG is
scaled to maxWidth and encoded in Kotlin; native only copies the bytes
and drops a request while one is in flight. Only mode=screen is
supported, and capabilities are re-evaluated on every login so turning
the service off withdraws the capability.
Also fix two review findings: a screenshot callback that lands after
the 3 s timeout now recycles its bitmap instead of leaking it, and the
server's failure hint lists the possible Android causes instead of
asserting disabled accessibility.
Verified on the emulator against a local debug server: get_screenshot
returns 640x1422 and 720x1600 JPEGs, the 120-wide list thumbnail works,
and both MCP tool-table checkers pass with apk added for get_screenshot,
get_activity_history and get_client_log.
Co-Authored-By: deepseek-flash
RecalcLayoutAndResize only clamped the window position, so a portrait
capture (an Android phone's 1080x2400 arrives as 480x1067 at the desktop
default width) plus the info text made a tip taller than the screen,
with its bottom half off it.
The tip now also shrinks the image to the work area's height and width
budget before placing the window. Text wraps to the image width, so the
measurement is redone after each pass; two passes are enough because
every pass only shrinks.
Verified with the emulator's 1080x2400 client against a local debug
server: the tip is 521x1016 inside a 1920x1032 work area and the image
kept its portrait aspect.
Co-Authored-By: deepseek-flash
get_activity_history was gated to Windows and Linux. The Android client
now answers COMMAND_QUERY_ACTIVITY with a TOKEN_REPORT_ACTIVITY snapshot
on the main connection, the same RPC shape as the other platforms; the
server takes the first packet without CancelIO, so no sub-connection or
request correlation is involved.
The sampler reuses linux/LinuxActivityHistory.h, whose ActivityHistory
class and formatters are platform-neutral, and is fed by a probe that
asks the new ControlService.currentActivityTitle() once per second over
JNI. The accessibility service already tracks the foreground package
from TYPE_WINDOW_STATE_CHANGED; the title is "label (package)" with the
label resolved once and cached, "Home" for the launcher, and idle for
lock or screen-off, so no permission beyond the service users already
enable is needed. Without the service the report says so instead of
recording placeholder "Android" entries.
Also scope the connection teardown to its own generation: a
ConnectionThread that exits late (CaptureService restart) no longer
clears the new run's g_running or g_pMainClient, and the report thread
takes one local snapshot of the main client pointer.
Verified on the emulator against a local debug server: five records
(Settings, Chrome, launcher, Home) came back newest-first with dwell
times, and disabling accessibility produced the permission hint.
Co-Authored-By: deepseek-flash
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
Reuse the Linux OpenSSL TlsChannel implementation (platform guard widened
to __linux__); the trust anchor lives in the app-private filesDir, injected
via TlsSetAnchorDir in nativeInit before the connection thread starts.
COMMAND_TLS_ENABLE/DISABLE save/remove the anchor, hot-reload and reconnect
only when the transport actually changes, so the master menu takes effect
within seconds without restarting the app. Login reports RES_TLS, refreshed
before each re-login. The reconnect flag is consumed before the drop check
and cleared before reconnecting so a switch racing a disconnect cannot
cause an extra reconnect/login cycle.
Cross-compile OpenSSL 3.5.0 per ABI with build_openssl_android.sh (NDK
clang + MSYS2 perl/make), integrated into build_android_libs.ps1
(-OpenSslOnly). Static libs and per-ABI headers are tracked like the
existing libzstd/libsign prebuilts; --exclude-libs keeps OpenSSL symbols
private to libyama.so, isolated from the Java-layer Conscrypt.
Co-Authored-By: Qoder <noreply@qoder.com>
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
Pass the target HWND through the COMMAND_SCREEN_SPY token and send
COMMAND_SCREEN_ROI after session start, so MCP remote control can stream
just the target window or region instead of the scaled virtual desktop.
The session records the target kind, remote_mouse refuses a redundant
window_hwnd basis, and the cached resolution is refreshed per action so
resized windows keep mapping correctly. Cold starts now clear the stale
resolution cache used by the region handshake.
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
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
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
Hidden web/MCP screen sessions never receive TOKEN_FIRSTSCREEN and never run
the local decode path, so m_bIsFirst stayed TRUE and every keyframe or scroll
frame after a resolution change was dropped, leaving the browser black. The
same black screen appears whenever the client runs a non-H.264 quality level
(Ultra/DIFF, High/RGB565): DrawNextScreenDiff forwards to the web only inside
the ALGORITHM_H264 branches while the MFC window renders every algorithm, and
the existing web clamp cannot run in fixed-level mode because EvaluateQuality
returns early when adaptive quality is disabled.
Clear m_bIsFirst once an IDR decodes and forward keyframe/nextscreen frames
for hidden web sessions. Clamp web sessions to QUALITY_GOOD in OnInitDialog,
re-push the level when the client reports a lower one in BITMAPINFO, and nudge
a flapping client back to H.264 at most three times. The browser now receives
stream_algorithm/web_supported notices and shows an explicit hint in both the
focus view and the wall instead of a silent black frame. Resolution-change
recovery moved into OnTimer(4) so hidden sessions flush the decoder and request
a fresh IDR too.
Also bound the client-supplied block offsets and scroll parameters in the
DIFF/GRAY/RGB565 decoders, which could otherwise write outside the destination
DIB, and share one keyframe-request throttle between the resolution path and
the web console. Verified with a Debug x64 server build and node --check on the
page script; the Go server does not emit the new notices yet and degrades to
the old behavior.
Co-Authored-By: deepseek-flash
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).
A browser or native controller can lose a keyup (window blur, tab switch,
browser shortcut, in-app dialog, disconnect). The remote OS then keeps
Ctrl/Shift/Alt down, later keystrokes turn into shortcuts, and only
pressing the modifier again clears it.
The web console now tracks the keys it sent down and releases them on
blur, visibilitychange, pagehide, dialog, control off, device switch and
disconnect; the next keydown/mousedown/wheel reconciles tracked modifiers
against the event's real modifier state. Keys held when the socket drops
are stashed and released once the screen session is confirmed after
reconnect, tagged with the device so they never reach another host. The
Ctrl+V bridge flag is reset wherever its physical keyup can be lost.
The Windows client tracks injected keys by VK + scan code + extended bit
so right-hand modifiers release the key that was pressed, and releases
them on session teardown and reconnect; the Linux agent does the same
on teardown with XTestFakeKeyEvent.
Verified with a 20-scenario headless Chrome harness, group filter
regressions, node --check, go build/vet/test, a Debug client build and
the WSL Linux build. Not exercised against a real controller and host;
the macOS agent is unchanged.
Co-Authored-By: deepseek-flash
Operators running several groups had to scan the whole fleet. The device
list now has a group filter: desktop renders the groups as chips in the
Total row (click to toggle any number), while touch devices get a compact
dropdown with checkbox rows plus Clear/Done. An empty selection means
"all groups"; multiple selections are OR-ed and combined with the search
box. Hosts without a group appear as "Ungrouped".
Groups are derived from the current device snapshot (no admin-only
get_groups call, so restricted users can filter too), and the selection
persists in localStorage for the browser. The offered list follows the
Offline toggle, while a selected group whose devices are temporarily
gone stays visible with count 0 instead of being silently dropped.
Logout clears the selection so the next account does not inherit it.
The Wall view keeps its own search and is unchanged.
Verified in headless Chrome at desktop and phone widths: multi-select,
counts, dropdown open/close/clear, stale-selection retention, search
focus, long names and persistence across reloads. go build and
go test ./web/ pass.
Co-Authored-By: deepseek-flash
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
GDI and DXGI each kept their own static monitor index, and DXGI
committed the index before its initialization had succeeded. When a
quality change restarted capture and DXGI fell back to GDI, the next
DXGI attempt read the failed attempt's index and jumped to the other
monitor. Both backends now share one process-wide index with separate
peek and commit steps, and the commit only happens after the backend
is actually up.
Manual switching is made a one-shot request: InitScreenSpy consumes
the flag and RestartScreen only sets it, so an adaptive restart that
lands in the middle of a switch no longer drops the request or
re-applies it on every later rebuild. Window capture no longer
touches the index at all, so leaving window mode returns to the
monitor that was on screen.
Also: restart capture on a bitrate change only when the target level
is still H.264 (switching to RGB565/DIFF never uses the bitrate), and
bound the DXGI output fallback so a session without any enumerable
output cannot spin forever in InitDXGI.
Co-Authored-By: deepseek-flash
Implement COMMAND_QUERY_ACTIVITY -> TOKEN_REPORT_ACTIVITY with two backends
picked at startup. With a desktop, a sampler thread reads the foreground
window every second and books dwell time like the Windows client: under
five seconds is dropped, five idle minutes close the window, the last 500
records stay newest first, each line being "[YYYY-MM-DD HH:MM:SS] [title]
duration". It uses its own ActivityChecker because an Xlib connection
cannot be shared with the heartbeat thread, and it is stopped before main's
locals go away.
A reachable X server is not enough: the window backend is only chosen when
the root window carries _NET_SUPPORTING_WM_CHECK, so Xvfb or a bare X
without an EWMH window manager falls back to the headless backend instead
of sampling a window id that never appears.
Without a desktop the answer is computed on demand: logins from
"last -n 100 -F" plus bash/zsh history of root and /home/*, tagged [登录] or
[命令] after a [来源] header. Both halves are merged and sorted by
timestamp; three fifths of the budget goes to logins and reboot records are
capped at ten, since a WSL or container writes one reboot per start.
activity_commands=0 drops the command half.
A single detached thread builds and sends it, only while the main link is up.
The MCP gate now admits Linux for get_activity_history and documents both
shapes. test/unit/linux covers the parsers, ordering and UTF-8 truncation;
15 cases pass.
Co-Authored-By: deepseek-flash
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
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
The handshake loop retried SSL_do_handshake on SSL_ERROR_WANT_READ and
nothing else. IOCPClient arms the socket with SO_RCVTIMEO for the
handshake, and a read timeout surfaces as EAGAIN, which OpenSSL reports
as WANT_READ rather than a syscall error. A peer that accepted TCP and
then went silent therefore put the loop into an endless retry: the
handshake never finished, never failed, and logged nothing, while the
main loop sat inside the read. Even SIGTERM could not stop the process,
because the exit flag is only observed between heartbeats.
Observed on a Linux client moving back to 443 when a transfer expired:
frps had the connection ESTABLISHED, the server had sent a partial
flight, the client's Recv-Q was empty and its log stopped dead at the
reconnect line. Reproduced locally against a TCP server that accepts and
never replies: one connection in 75 seconds and no output at all.
Give the whole handshake a 30 second budget, longer than the 15 second
read timeout so a single wake-up still fits, and treat expiry as a
failure the caller can retry. The stalled peer now logs
"[TLS] handshake timed out after Ns (peer silent), aborting" and the
reconnect loop keeps running.
Co-Authored-By: deepseek-flash
The address label was 81 dialog units wide at x=8 while the combo box
starts at 93, and the prompt set at runtime - an IP:PORT hint that also
mentions the optional wss:// prefix - is far wider than that. The static
clipped it at its edge, so the rest of the hint looked hidden behind the
input field; with the English or German translation almost the whole
sentence disappeared. The days label had the same 81-unit width.
Move both labels onto their own full-width rows above their controls
and shift the combo box, days field, checkbox and buttons down to fit.
The dialog grows from 105 to 128 units and the days field narrows from
201 to 80 units, so every translation stays on one line. The share
variant still hides the days row, leaving the same gap it had before.
The share and transfer dialogs share this template, so both are fixed.
Co-Authored-By: deepseek-flash
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
The Linux client always reported zero for ScreenSettings.FullScreen and
RemoteCursor and dropped CMD_FULL_SCREEN / CMD_REMOTE_CURSOR on the
floor, so a controller could never reopen a host in the state it was
left in. The Windows client has done both for a while.
Store both fields in ~/.config/ghost/config.conf next to QualityLevel,
report them through the TOKEN_BITMAPINFO ScreenSettings, and update them
whenever the controller toggles either option. The controller already
applies the reported FullScreen in OnInitDialog, so no protocol or
master-side change is required.
CustomCursor is deliberately not persisted: Linux clients never send
cursor images, so the flag would be inert.
Co-Authored-By: deepseek-flash
OnSize only refreshed the cached client rect, letterbox offsets and zoom
factors; it never asked for a repaint. Windows invalidates a window only
when the client area grows, so restoring a maximized viewer marks nothing
invalid. Since the dialog stops erasing its background after the first
frame and has no periodic repaint timer, the sole remaining repaint source
is a change on the remote screen. A static remote desktop therefore kept
the maximized picture - cropped, not following the window - until something
moved on the far end.
Call InvalidateRect(NULL, FALSE) at the end of OnSize whenever the client
area is non-empty, so every size change (restore, fullscreen transitions
and interactive resizing) recomputes the layout and repaints once. It is a
no-op while the window is hidden; CHideScreenSpyDlg::OnSize calls the base
handler, so it inherits the same behaviour.
Verified on a Debug build against a live test client: the maximized client
(1920x1009) renders 63/64 px side bars and the restored one (717x355) 43/43
px, matching ComputeAdaptiveLayout (renderW=631, offsetX=43).
Co-Authored-By: deepseek-flash
With the toolbar unpinned, CheckMousePosition() runs from the full-screen
timer every 50ms and slides the bar out once the cursor leaves the edge
band. The quality menu drops from the button's bottom edge, so its first
item already sits past the monTop + m_nHeight + 10 threshold: the bar
retracted the moment the user moved onto the menu, taking the menu with it.
A m_bMenuOpen flag now suspends the retract decision while TrackPopupMenu
is running. The menu's modal loop still dispatches the parent's WM_TIMER,
so without this the bar animates away under it. The flag is set and cleared
around the call, so behaviour is unchanged once the menu closes or is
dismissed with Esc.
Only the quality menu opens a popup, so nothing else needed the flag.
Verified: debug server build, 0 errors, ToolbarDlg.cpp rebuilt. UI not
exercised.