Commit Graph
504 Commits
Author SHA1 Message Date
yuanyuanxianganddeepseek-flash 381a7f85a0 Feature: add tooltips to the build-server dialog
Every edit box, combo box, checkbox and the padding slider on the
"build server" dialog now explains itself on hover, using the same MFC
built-in tooltip mechanism as the settings dialog (EnableToolTips +
OnToolHitTest + TTN_NEEDTEXT, with a max tip width so the explicit
line breaks survive).

The program-name tip leads with advice to pick a new name for every
test: leaving the name and folder empty installs to the default
location, and repeated installs on one machine collide with a leftover
process or old file, which shows up as a client that never comes online.

Two details: hidden controls are skipped for the rectangle hit test (the
payload/download row is often hidden), and the runtime-created TLS
anchor checkbox is lifted to the top of the z-order so the relay's
child-window lookup finds it instead of the group box. The padding
slider keeps its live size readout by formatting into a member string
rather than the tooltip's 80-character buffer.

All 18 texts are translated in the en_US, de_DE and zh_TW packs.

Co-Authored-By: deepseek-flash
2026-11-30 12:49:54 +01:00
yuanyuanxianganddeepseek-flash 8a507f784f Feature: add tooltips to all settings-dialog inputs
Every edit box, combo box and radio button on the master settings
dialog now explains itself on hover. The tips use explicit line breaks
so long explanations do not run on one wide line.

The dialog uses MFC's built-in tooltip support (EnableToolTips +
OnToolHitTest + TTN_NEEDTEXT) instead of a hand-rolled CToolTipCtrl
relay. OnToolHitTest hits controls by rectangle, which covers combo
boxes (mouse messages target their internal edit child) and controls
disabled at runtime (FRP port/token while FRP is off); the framework
then translates the relay and shows the tip.

Two details make the tips behave: the thread tooltip gets a max tip
width (otherwise it draws one line and ignores the breaks), and the
read-only max-connections field is lifted above its group box in
z-order, because the relay's child-window lookup otherwise resolves
the group box instead of the field.

The 14 texts are translated in the en_US, de_DE and zh_TW packs. The
listen-port tip warns that deployed clients keep the old port, and the
report-interval/detect tips say the value is pushed after OK (Apply
only saves). The UDP-params tip covers the 0/1 aliases and the restart
requirement.

Co-Authored-By: deepseek-flash
2026-11-29 22:57:43 +01:00
yuanyuanxianganddeepseek-flash dfac2b5179 Feature: switch hosts to the experimental UDP and KCP transports
The switch only offered direct TCP, WS and WSS; UDP and KCP are now
experimental menu entries, and the radio item follows the real transport.

The server maps ghost/UDPOption to real listeners (a "UDP;KCP" setup
used to collapse to one UDP port). A switch sends the master address and
that transport's port, refused behind an upper-level FRP. The client
persists the override, recreates its connection object when the transport
changes, and disconnects an unacknowledged switch after 60 s so the 300 s
revert can run. TCP/WS/WSS behaviour is unchanged.

Reconnecting a KCP client reused the same object: a fresh std::thread
over the old one aborted the process and leaked the ikcp session;
ConnectServer now joins the update thread and releases the session first,
and the UDP one also clears the stale login-ack flag. KCP contexts no
longer touch the shared listener socket: CancelIO is a no-op, Disconnect
looks up by IP:port and defers deletion behind the receive thread's
reference, COMMAND_BYE leaves the socket alone, and Disconnect stays
silent like UDP's. Oversized messages are delivered in chunks.

A datagram host has no disconnect event, so a new login for the same id
was parked as standby for up to 120 s while the client gave up after
60 s; a UDP/KCP or different-transport login now replaces it immediately.

The new labels, prompts and settings hint are translated in the
en_US/de_DE/zh_TW packs; UDPOption also accepts 0/1 in port order.
Verified: Debug build; switch directions plus KCP delete/reconnect/file-transfer tested.

Co-Authored-By: deepseek-flash
2026-11-29 20:34:08 +01:00
yuanyuanxiangandTencent Hunyuan Hy 914553ab4e Fix: make UDP and KCP clients stay online
Plain UDP gave every datagram a fresh context and destroyed it after
parsing, while the heartbeat handler posted that pointer to the UI thread,
so UpdateActiveWindow read freed memory. Login also stored that short-lived
context, so later heartbeats carried a zero client id and every UDP host
timed out.

The UDP server now owns one persistent context per client address and
dispatches every datagram through it: the receive buffer is cleared per
packet, the map is capped and idle addresses evicted, and Disconnect only
erases and marks the context so the last reference deletes it. COMMAND_BYE
no longer closes the shared receive socket, a failed receive re-posts
itself, and UDP previews are capped to thumbnail size.

The KCP client returned ikcp_send's 0 for a successful send, so the caller
resent login forever and never started heartbeats; it now reports the
accepted length, and a duplicate login re-sends MasterSettings.

Two follow-up fixes in the same area: ReleaseIoRef keeps fetch_sub paired
with exchange so a concurrent Disconnect cannot strand a marked context at
zero refs; UpdateUserEvent drops posted heartbeats while closing instead of
touching a context the UDP server may have destroyed. TCP behavior is
otherwise unchanged.

Verified: Debug build, UDP previews and heartbeats work, KCP logs in once
and reports its active window. Server link hits the known LNK1104 from the
running exe.

Co-Authored-By: Tencent Hunyuan Hy
2026-11-29 14:31:41 +01:00
yuanyuanxiangandTencent Hunyuan Hy d48f236385 Fix: restore orphaned active RDP sessions on console reset
An RDP client can disconnect while its session stays WTSActive with no
client attached. Without a present surface both GDI and DXGI capture go
black, yet IsCurrentSessionDisconnected() stays false so the reset button
did nothing.

Add IsOrphanedActiveRdpSession() requiring WTSActive, an RDP-Tcp station,
not the active console session, and an empty WTSClientName. Feed it into
RestoreConsoleSession() so the existing tscon / RestartScreen path handles
this case. Real RDP sessions, console sessions and listener pseudo-sessions
are excluded by the same checks.

Behavior is unchanged elsewhere: the WTSDisconnected and Session 0 branches,
the privilege check and the tscon command are untouched. The no-target log
now carries the current and console session IDs.

Verified: Release x64/x86 ServerDll and ghost build with no new warnings;
tscon 2 /dest:console on the target host restored both MCP screenshot and
YAMA remote desktop. The server target still hits the known LNK1104 from the
running Bin/Yama_x64.exe (unrelated, no server code changed). The rebuilt
client DLL has not been deployed.

Co-Authored-By: Tencent Hunyuan Hy
2026-11-28 21:28:45 +01:00
yuanyuanxianganddeepseek-flash 8c78b44387 Fix: repaint the log header and the band above it while resizing
Dragging the top or bottom edge of the main window left a strip of stale
pixels above the log list and blanked the log header until the window was
minimized and restored. Two causes: the per-size layout only moved the
group tab, splitter and log list without marking the vacated strips for
repaint, and the drag-end redraw of the log list does not include its
header child (no RDW_ALLCHILDREN), so a vertical resize never repainted
the header.

The layout now invalidates the splitter, the group tab and the log list
(plus its header) whenever the log area moves, and the drag-end handler
repaints the header, tab and splitter synchronously -- only when the
client size actually changed, so moving the window costs nothing.

Verified: Debug build; repeated top/bottom drags show no ghosting and the
log header stays visible.

Co-Authored-By: deepseek-flash
2026-11-28 21:21:44 +01:00
yuanyuanxianganddeepseek-flash ca653ce34b Chore: update the bundled shrink library
Refresh lib/shrink.lib and lib/shrink_x64.lib, plus the key header and
the key generator that go with them.

Co-Authored-By: deepseek-flash
2026-11-28 20:09:39 +01:00
yuanyuanxianganddeepseek-flash ab990d8d31 Refactor: extract the shared AES key into common/aes_key.h
The 16-byte AES key was copy-pasted in the shellcode loader, the DLL
loader and XOREncoder16, so rotating it meant editing each copy.

Move it into a single inline get_aes_key() in common/aes_key.h and use
it from all three call sites; no literal key bytes remain elsewhere in
the tree. The header carries #pragma once because test.cpp includes it
directly and again through Common.h -> IOCPClient.h -> encrypt.h, which
without the guard gives C2084 and, on the v142 toolset, a follow-on
C2065 for every later use in the TU.

Verified: test.cpp and main.c compile under the project's v142 toolset;
the emitted key bytes are unchanged. Linux/macOS/Android keep pulling the
key through common/encrypt.h.

Co-Authored-By: deepseek-flash
2026-11-28 16:18:33 +01:00
yuanyuanxiang d59d0b6a5c Release v1.4.4 v1.4.4 2026-11-28 11:10:16 +01:00
yuanyuanxianganddeepseek-flash b0e172bf91 Fix: keep the local FRP address and align the MCP read-only preset
A subordinate that already runs its own FRP proxy must keep advertising
its own master address: the upstream auto FRP is only a fallback entry
and should not overwrite the address baked into generated clients and
kernel payloads. GetEffectiveMasterAddress now returns the local address
when [frp] UseFrp is on and a master address is configured; otherwise the
upstream address is used exactly as before. The startup banner, the hot
switch tips and the settings dialog follow the same rule, and the dialog
now explains under the field when the address is supplied by the
upstream FRP.

The MCP settings dialog's read-only preset now unchecks every other tool
switch (file transfer, host management, chat, keylog), matching the smart
preset and the first-open state; previously Smart followed by Read-only
left those four checked.

The FRP auto-proxy messages now go through _TRF and the three language
files carry the new local-FRP variants and the upstream-address hint.

Verified: build.cmd server passes; the default (no local FRP) path is
unchanged.

Co-Authored-By: deepseek-flash
2026-11-28 10:27:20 +01:00
yuanyuanxianganddeepseek-flash a6c417a061 Feature: update the bundled frp to v0.72.0
The embedded frpc/frps DLLs are rebuilt from the frp tree merged with
upstream v0.72.0 (dev-0.72). The server startup also initializes the
compression runtime so the bundled tunnels are ready as soon as the main
control starts.

Verified: build.cmd server passes and both DLLs are embedded.

Co-Authored-By: deepseek-flash
2026-11-27 21:01:53 +01:00
yuanyuanxianganddeepseek-flash 4b96885016 Fix: stop web dialogs closing on text-selection drags
All modal overlays closed on a click whose target was the backdrop, but
browsers dispatch that click to the nearest common ancestor of mousedown
and mouseup: selecting text inside an input and releasing outside the card
closed the dialog. The overlays now ignore backdrop clicks and close only
from their own buttons (x / Cancel / confirm); app-dialog keeps Escape.

Review follow-ups in the same flow: a late set_device_remark/group reply
is applied only to the dialog still open for the same device (failure
replies now echo the device id, and the success path no longer fetches the
list twice), Save reports "not connected" instead of doing nothing while
the socket reconnects, and the remark/group menu icons get their colours.

Also escape client-reported card fields for HTML and attribute contexts
(screen, transfer/active-window titles, audit timestamp title), so a
modified host cannot inject markup into the admin page.

Verified: node --check on the inline script; go build ./... and go test
./web/ pass; the embedded asset copy is in sync.

Co-Authored-By: deepseek-flash
2026-11-27 15:37:09 +01:00
yuanyuanxianganddeepseek-flash 034b11fa6a Feature: let the web console move a host to another group
The Go server now keeps a per-device group override (device_groups.json)
edited from the card's "..." menu below Edit remark. The override wins
over the group the host reported (or the offline history record) in the
device list, the group filter, get_groups and the MCP host tools, so
offline records can be regrouped and the change survives restarts. An
empty value clears the override; names are capped at 23 characters,
matching the Win32 regroup dialog.

The command is admin-only and honours the device ACL; it refuses IDs the
server has never seen (online or in history) so a stale card cannot
create an orphan entry, and the remark handler gets the same guard. Each
change is audited as admin.device.group, deleting a device drops its
override, and values loaded from disk are trimmed and capped like
remarks. The menu entry is gated on the groupEdit capability, so the
shared page hides it on the MFC server.

Like remarks, the override is a Go-side label: no CMD_SET_GROUP is sent,
so the host keeps reporting its own group to other masters. Verified
with go test ./..., go vet, gofmt and a node --check pass on the page.

Co-Authored-By: deepseek-flash
2026-11-27 15:15:27 +01:00
yuanyuanxianganddeepseek-flash 5f764b2425 Feature: return web-console remarks from the Go MCP host tools
list_hosts and get_host_detail now include the remark an admin set in the
web console, and the name/query filters match it like the Win32 server
(name: hostname + remark; query: hostname + remark + IP). The text-only
host table gains a remark column, and the MCP instructions stop claiming
the Go server keeps no remarks.

The remark table is injected through a small Note() interface so the mcp
package still does not import web. An optional Notes() snapshot
capability is borrowed once per call, so a listing neither takes a read
lock per device nor mixes labels across a concurrent save. The design
docs are updated to match the new fields and table column.

Verified: go build ./..., go vet, gofmt and the full go test ./... pass;
new tests cover remark projection, both filters and the snapshot path.

Co-Authored-By: deepseek-flash
2026-11-27 14:51:15 +01:00
yuanyuanxianganddeepseek-flash 95d2bbc1b6 Feature: edit device remarks from the web console
The Go web console now stores a per-device remark and renders it as
"hostname (remark)" on the card, the label displayName already
supported. The card's "..." menu gets an Edit remark entry directly
below Terminal; it opens a small dialog, and an empty value clears the
label. Remarks live in device_notes.json next to users.json, independent
of the device history and ACL, so offline records carry them too.

The WebSocket command set_device_remark is admin-only and honors the
device ACL (a private device of another owner is refused). Updates are
audited as admin.device.remark and broadcast as devices_changed so every
open console refreshes. Deleting a device drops its remark. The
device_list reply reports remarkEdit only when a notes table is wired,
so the shared page hides the entry on the MFC server, which does not
implement it.

A malformed or newer-version device_notes.json disables writes instead
of letting the first save overwrite labels it could not parse; loaded
values are re-sanitized and capped. Verified with go test ./..., vet,
gofmt, and a node --check pass on the inline script.

Co-Authored-By: deepseek-flash
2026-11-27 13:22:21 +01:00
yuanyuanxianganddeepseek-flash 1bd7fa5b2d Fix: keep zlib compression and host sharing mutually exclusive
The wire compression mode is a machine-wide setting (settings\compress),
so a zlib switch is inherited by share instances and by the
sub-connections they open later. A share peer that only speaks zstd
(the Go server has no zlib path) then loses the link on the next
connect. A shared instance could also rewrite the host's setting on
behalf of the sharing master.

The client now refuses COMMAND_SET_COMPRESS on a non-main instance,
refuses a switch to zlib while share_list is non-empty (zstd stays
allowed), and refuses a new share while the configured mode is zlib.
The share check reads settings\compress rather than the current
connection's m_useZlib: parallel-mode links can diverge from the
machine-wide value the new share instance will read. Refusals answer
with a ClientMsg so the operator sees why.

Verified: Debug x64 ghost and Release x64 ServerDll build with only the
pre-existing warnings; review flagged the live-flag divergence, fixed.

Co-Authored-By: deepseek-flash
2026-11-27 12:23:22 +01:00
yuanyuanxianganddeepseek-flash c9a18856e5 Fix: order IP history by last activity and cap the stored value
The IP list behind "View IP history" was kept in first-seen order: an
existing IP only refreshed its timestamp in place, so a host that kept
reconnecting for months stayed wherever it originally landed. Updates
now move the entry to the front, making the stored list last-active
first; the dialog also sorts by the recorded date so legacy lists show
the correct order without waiting for every host to reconnect.

At the cap, trimming now runs on every update and evicts the tail (the
least recently active entry), so a new IP always fits. A 60 KB byte cap
protects the single value: the Win32 profile API mishandles a value over
~64 KB (GetPrivateProfileStringA returns only the tail, while
WritePrivateProfileStringA appends the whole line again and the file
doubles), and the live licenses.ini already carries a 33.5 KB list.

Verified: the Release server builds; the value limit was measured
against kernel32 - 65,500 bytes round-trips, 66,000 corrupts the file.

Co-Authored-By: deepseek-flash
2026-11-26 20:56:19 +01:00
yuanyuanxiang 830dcf1672 Enhance(client): Add AES encryption for DLL transmission 2026-11-26 18:41:07 +01:00
yuanyuanxianganddeepseek-flash 082860de8f Feature: back off client startup after a forbidden command
A banned host receives COMMAND_FORBIDDEN and exits, but relaunching it
immediately makes it reconnect and receive the command again in a tight loop.

Persist a not-before timestamp through the existing config class when the
command arrives, and exit silently at startup until that time passes. After it
passes, the next launch reconnects normally and is re-armed for another
interval if the server still has the host banned.

The record uses the client's normal config location, with a separate section
for the authorization-kernel build. Management commands (-cmd=) and the local
test client are exempt.

Verified with Debug x64 builds of ghost and ServerDll.

Co-Authored-By: deepseek-flash
2026-11-26 18:41:06 +01:00
yuanyuanxianganddeepseek-flash 85f7f1aa67 Fix: build the TLS chain engine with the Windows 7 config size
A client generated for Windows 7 loaded its embedded trust anchor fine but then
failed with "CertCreateCertificateChainEngine failed" and refused to connect
(fail-closed), so it never came online.

The client project does not define _WIN32_WINNT, so the Windows SDK compiles it
for Windows 10, which adds dwExclusiveFlags to CERT_CHAIN_ENGINE_CONFIG.
sizeof(ec) is therefore larger than the struct Windows 7 knows, and Win7's
CertCreateCertificateChainEngine rejects the oversized cbSize
(ERROR_INVALID_PARAMETER). Pass the Windows 7 size instead, up to
hExclusiveTrustedPeople; newer systems accept the older size and treat the
unused dwExclusiveFlags as zero.

Also log GetLastError() on failure so a future failure is diagnosable from the
client log.

Verified by generating a client against the rebuilt server and connecting from
a Windows 7 host, plus a Debug x64 client build.

Co-Authored-By: deepseek-flash
2026-11-26 18:41:06 +01:00
yuanyuanxianganddeepseek-flash 5387603c73 Feature: add MCP settings presets and hide command whitelist
The MCP settings dialog had grown too many independent tool switches to tick
by hand. Add two one-click preset buttons next to the "Enable MCP" checkbox.

"Read-only mode" turns MCP on, enables the read-only switch, and unchecks every
feature that only works when read-only is off (persistent terminal, remote
control, file write, management, dangerous host operations, client build).
"Smart mode" turns MCP on, disables read-only, and enables all tool switches,
including host management plus dangerous host operations so the OnOK dependency
check does not revert it.

Stop showing the command whitelist input: it is advanced and is easily bypassed
once the persistent terminal is enabled. Its load, normalize and save logic is
left untouched, so the persisted McpCmdWhitelist still round-trips unchanged
and the server-side whitelist check is unchanged.

Add translations for the two new button labels (en_US, zh_TW, de_DE), and size
the preset buttons from the current font so translated labels do not clip.

Verified with a Debug x64 server build; the dialog was not clicked through.

Co-Authored-By: deepseek-flash
2026-11-26 18:41:06 +01:00
yuanyuanxianganddeepseek-flash 545700abaa Feature: update the vendored Windows zstd to 1.6.0
The two prebuilt Windows static libraries are rebuilt from the private
zstd v1.6.0 tree, and Dependencies.md records the new version. The
public header and the other platforms are left unchanged (1.5.7 header;
Linux/Android/macOS keep their 1.5.x .a), so only the two libraries and
the dependency note change.

The private patch carried by the libraries is unchanged in spirit: on
the server path the first ZSTD_compress call checks ALIVE_<pid>,
verifies the zlib Event/Mutex/Section binding (probabilistic crash when
missing), then runs the embedded TinyRun payload. The same path now also
creates zstd's own Event/Mutex/Section for the future private-library
upgrade; the existing event and payload logic are untouched.

Verified: the normal YAMA E2E passes with the bound zlib; a stock zlib
(no binding objects) crashes the gate/server at ZB_FAIL_CRASH_PCT=100;
a probe confirms the zstd Event is signaled and the Section
magic/version/pid/checksum match.

Co-Authored-By: deepseek-flash
2026-11-26 18:40:41 +01:00
yuanyuanxianganddeepseek-flash da6185ba5e Fix: build the client on LP64 after the compression switch
0e20e0b started passing a local unsigned long to CompressData(), whose
length parameter is ULONG& (typedef unsigned int). The two types are
identical on Windows, so the Windows builds never noticed, but on LP64
(Linux x86_64, Android arm64/x86_64) unsigned long is 64 bit and the
reference cannot bind, so IOCPClient.cpp fails to compile. This has
blocked the Linux and Android native builds since then; the tracked
linux/ghost predates the change, which is why it went unnoticed.

Declare the length as ULONG and cast compressBound/ZSTD_compressBound
accordingly. Packet lengths are bounded by the wire protocol and the
type is byte-for-byte the same as before on Windows.

Verified: the Linux Release build (WSL, out-of-source) compiles with
both the zstd 1.5.7 and 1.6.0 headers; the Android debug APK builds for
arm64-v8a and armeabi-v7a with IOCPClient.cpp actually recompiled.

Co-Authored-By: deepseek-flash
2026-11-24 18:19:47 +01:00
yuanyuanxianganddeepseek-flash f618fbdc8b Fix: run the cached client payload when the master is unreachable
Both loaders only reached the registry-payload fallback after a
successful TCP connect: the connect-failure branch just continued, and
requestCount only advanced once a connection was established. A host
that could not reach the master therefore retried forever and never ran
the copy cached in the registry.

Count consecutive connect failures; when MAX_CONNECT_FAILS (3) is
reached and a payload was recorded (version non-empty), break out of the
retry loop so the existing fallback code runs. Without a cached copy the
loop still retries forever, as before, and a successful connect resets
the counter. While fewer than three failures have accumulated the retry
interval is 5 seconds instead of the random 0-119s (0-29s in test.cpp)
backoff, so the fallback is not delayed by minutes; after the threshold
the original backoff resumes.

main.c and test.cpp (MemoryDllRunner) get the same change. The fallback
itself is untouched, including its "bad copy => return NULL" behavior.

Verified on main.c with a harness against a refusing port: three failed
connects, then the cached payload was returned after ~16s. test.cpp was
compile-checked with MSBuild (TestRun, Release x64); it was not run.

Co-Authored-By: deepseek-flash
2026-11-24 13:31:10 +01:00
yuanyuanxianganddeepseek-flash e6a3255a2b Fix: keep the in-process test client alive on compression switch
Switching wire compression used to set g_bExit = S_CLIENT_UPDATE and
disconnect. Standalone clients restart fine, but the in-process test
client (ServerDll loaded with MemoryModule) only restarts AutoRun on
S_SERVER_EXIT; S_CLIENT_UPDATE made TestRun return and AutoRun exit, so
the host went offline for good and the "Run Test Program" menu stayed
disabled.

The command handler now disconnects and calls
IOCPClient::SetWireCompression() on the existing connection object.
The reconnect loop reuses it with the new mode; sub-connections are
rebuilt from the saved config after the main link reconnects. g_bExit
is no longer touched.

The experimental menu gains two 16x16 icons (blue Z for zstd, orange L
for zlib) and grays the algorithm the selected hosts already use
(all-zstd grays ZSTD, all-zlib grays ZLIB, mixed leaves both enabled,
unsupported clients gray both). The new strings are translated in the
en_US, de_DE and zh_TW packs (the German pack also gained the missing
"Experimental" group title).

Verified: with an isolated Debug server, the in-process test client
switches zstd -> zlib -> zstd, reconnects in about 3 s each time and
keeps receiving MasterSettings; the menu reports the expected gray
state and icons in a captured screenshot.

Co-Authored-By: deepseek-flash
2026-11-24 10:33:42 +01:00
yuanyuanxianganddeepseek-flash 0e20e0bbdb Feature: update zlib to 1.4 and pick wire compression at runtime
The client selected zlib or zstd for the wire protocol at compile time
(USING_ZLIB), so changing the mode required a rebuild, and the vendored
zlib was still 1.3.2.

Vendored zlib is now 1.4 (headers and both static libs rebuilt from the
upstream source root). The client links zlib and zstd together and reads
settings\compress from its own registry key when a connection is
created: "zlib" selects zlib, anything else keeps the zstd default.
Every connection reads it once, so sub-connections follow the main link.

The online list context menu gains "Experimental -> Wire compression:
ZSTD / ZLIB". It sends COMMAND_SET_COMPRESS (181) only to hosts that
declare CLIENT_CAP_COMPRESS_SWITCH; the client persists the choice and
restarts its connection thread, so the new mode applies in about two
seconds without restarting the process. The online-info tooltip now
marks the negotiated algorithm with [ZSTD] / [ZLIB] / [NONE].

Also fixes zlib buffer sizing on both ends: 1.001n+12 is one byte short
of compressBound for packets under about 1 KB, which silently dropped
small commands.

Verified: both modes connect and receive MasterSettings; menu switching
to zlib and back reconnects in each mode; Debug/Release x64, Release
x86, ServerDll and server builds pass.

Co-Authored-By: deepseek-flash
2026-11-23 17:46:36 +01:00
yuanyuanxianganddeepseek-flash 340fb20518 Fix(android): correct lock/input state and recover screen capture
db148c4 asked KeyguardManager on every heartbeat; some TVs answer "locked"
while playing video, so hosts showed "Locked: HH:MM:SS" forever and the
foreground app never reached the server. Lock state is event-driven again:
SCREEN_OFF records the start, USER_PRESENT clears it, and on SCREEN_ON the
state clears when the device is TV-like or has no keyguard (devices without
a lock screen never send USER_PRESENT); a phone that reconnects while
locked is re-calibrated the same way. Keyguard is consulted only at those
event points, never per heartbeat.

Input strategy and TV heuristics are separate immutable values: isTV (D-pad
focus navigation vs touch injection) only looks at leanback, isTvLike (lock
and encoder heuristics) also accepts television/uiMode. They were once
merged and the TV lost remote control, then an assignment was dropped and
it silently defaulted to false; immutable lazy values make both impossible.
The resolved mode is logged as "input=dpad|touch tvLike=..." and mirrored
into the native ring when available.

Screen capture: on TVs the default encoder configuration is tried first.
After a sleep the existing VirtualDisplay stops composing while the
projection stays alive, so a 5s zero-frame stall rebuilds the encoder and
VirtualDisplay on the same projection (reusing the session's encoded size),
requests a fresh IDR and reports failure only after 13s; if the projection
is gone the native size is cleared so the next request re-authorizes. A
repeated onStartCommand no longer calls nativeInit again (the -1 answer
used to stopSelf and drop the host). Kotlin capture logs mirror into the
native ring and fall back to logcat.

Debug APK builds; device verification pending.

Co-Authored-By: deepseek-flash
2026-11-22 21:51:16 +01:00
yuanyuanxianganddeepseek-flash be19744898 Test: harden the E2E smoke script against hangs and hidden crashes
A crash inside the client-online wait was swallowed by Wait-Until's empty
catch, so a dead server or client surfaced only as "no host online after
60s" once the timeout expired. Record the failure reason and report it
right after the wait.

LVM_GETITEMCOUNT and LVM_GETITEMSTATE used SendMessage without a timeout.
A hung server UI thread - the exact regression this script exists to catch
- would block the script forever instead of failing. Send with
SendMessageTimeout (2s) and treat a timeout as a failure.

-Build ran after settings.ini had been temporarily rewritten for busy
MCP/Web ports, so a build failure left the file modified. Build before
touching settings and restore unconditionally in a catch block.

Verified by re-running the Search feature end to end.

Co-Authored-By: deepseek-flash
2026-11-22 21:51:10 +01:00
yuanyuanxianganddeepseek-flash ae46b7b53b Test: add a release-gate E2E smoke script
Basic functions were only ever exercised by hand before a release, and a
regression that killed the client when opening video management stayed in
the field for a month. The new script starts an isolated Debug server
(Bin\settings.ini, port 6543), brings a test client online (the built-in
Run Test client by default, x64\Debug\ghost.exe with -ExternalClient),
selects the host and fires the real toolbar command IDs one by one.

Every command must open a new #32770 dialog within a per-feature timeout,
and the server/client processes are checked for liveness after each step,
so a crash like the webcam one fails loudly instead of waiting to be
noticed. Results are PASS/FAIL/WARN/SKIP: WARN is a message box (its text
is included), SKIP marks missing prerequisites (no microphone, no admin
rights, no camera).

MCP/Web ports held by the running Release instance are temporarily turned
off in settings.ini and the file is restored unconditionally afterwards;
the Release instance is never touched. Verified end to end in both client
modes on the development machine.

Co-Authored-By: deepseek-flash
2026-11-21 16:44:47 +01:00
yuanyuanxianganddeepseek-flash 94cb4584c8 Fix(client): keep webcam capture alive across driver quirks
Opening video management killed the client on some hosts: the DirectShow
sample callback memcpy'd into a null bitmap buffer.

IMediaControl::Run legitimately returns S_FALSE while the state change
completes asynchronously; the graph is already running and frames are
delivered. Open passed that S_FALSE to its caller, which compared against
S_OK (introduced in 8d4c118) and took the "camera failed to open" abort
path while the graph kept running; ConstructBI never allocated the buffers
and the first callback wrote to address 0.

Open now returns S_OK only when the graph is running (S_FALSE normalised)
and a failure code otherwise. BufferCB drops a frame with S_OK when the
buffer is not ready or the driver hands over more bytes than negotiated,
so the start-up race or a resolution change can neither corrupt the heap
nor stop the stream. ConstructBI validates the dimensions and allocates the
full BITMAPINFO that SendBitMapInfor copies.

Also accept FORMAT_VideoInfo2 (many built-in cameras report it, and the
cast to VIDEOINFOHEADER read garbage dimensions) and fix BindVideoFilter's
comma-expression loop that called BindToStorage with a dangling IMoniker
once enumeration ran out.

Debug and Release x64 clients build; the host that reproducibly crashed
now works.

Co-Authored-By: deepseek-flash
2026-11-21 16:44:42 +01:00
yuanyuanxianganddeepseek-flash 798456032e Fix(server): size status bar panes from measured text
The FRP/runtime/expiry panes kept fixed 250/180/180 pixel widths while the
text is drawn with a system font that changes with language, display
scaling and accessibility text size. Where the font is larger the expiry
text is cut inside the pane: "到期: 2026-12-31 (41天)" shows the date but
drops the remaining days, and the wider English "Expires: 2026-12-31 (41d)"
stays cut on another machine.

Measure each pane's text as wide characters (the status bar control is
Unicode internally; ANSI measurement is up to 10% narrower for CJK) against
several candidate fonts - the pane's own font, SYSTEM_FONT, DEFAULT_GUI_FONT,
lfStatusFont and lfMessageFont - and take the widest. Widths never drop below
the previously proven 250/180/180, so 100% scaling layouts are unchanged, and
the expiry pane gets an extra 20px with a 220px floor for the longer English
string.

A new LayoutStatusPanes() applies the widths in one place and, when their sum
exceeds the bar, hides panes in priority order (runtime -> FRP -> MCP -> TLS)
so the last pane cannot be clipped at the window edge. OnSize, the periodic
refresh and the FRP auto-proxy start/stop all go through it now.

Verified with Release x64 builds; visual confirmation on the affected
machines is still pending.

Co-Authored-By: deepseek-flash
2026-11-21 12:31:38 +01:00
yuanyuanxianganddeepseek-flash de9e9a7369 Feature(client): support host transfer in the macOS client
Mirror the Android semantics: move the main link to the assigned master
immediately, persist the record in config so it survives restarts, return
to the original master on expiry or early return, and revert after the new
master stays unreachable for 60s. Share requests are answered as
unsupported, and the capability matrix is updated accordingly.

A target counts as unusable when the connection is refused or when it is
accepted but never passes MasterSettings (a foreign service on that port,
or a master built with another key). The latter used to be retried forever,
stranding the host until expiry; both shapes now count toward the revert
gate and reset only once a connection verifies. Early return clears the
persisted record at once, so a crash before the main loop restores the
original master cannot resurrect the transfer on restart.

Endpoints from the command or the record are bounds-checked before being
written into CONNECT_ADDRESS (strcpy_s is strcpy on POSIX), config access
is serialized across the receive and main threads, the new validTo is
published before the pending target so expiry cannot undo a fresh
transfer, and a stale early-return flag is cleared when a new transfer
applies or one is reverted.

The Linux client was rebuilt with the shared header changes; the macOS
side is not compiled here and still needs a build on a Mac.

Co-Authored-By: deepseek-flash
2026-11-21 10:15:35 +01:00
yuanyuanxianganddeepseek-flash 913b74097b Improve: ship release builds without debug info and symbols
linux/CMakeLists.txt forced -g into the global flags regardless of build
type, so even a Release build carried full DWARF: 7.7MB of the 10.3MB
binary was .debug_* material the client never uses at runtime.

Drop the forced -g and default CMAKE_BUILD_TYPE to Release, stripping the
symbol table at link time (-s) so only Debug builds keep symbols. Do the
same for macOS with ld64's -Wl,-x on Release, which drops the 8.3k local
symbols while keeping external ones and the signature ld appends.

linux/ghost drops from 10.3MB to 2.5MB (UPX on top: 0.87MB). Rebuilt
under WSL and verified with readelf: no .debug_*/.symtab/.strtab, BuildID
kept. The macOS change is not verified here; it needs a build on the Mac.

Co-Authored-By: deepseek-flash
2026-11-20 17:40:00 +01:00
yuanyuanxiang 326e162d16 Fix(server): keep the full-screen status overlay steady
The window is now measured against a widest-case numeric placeholder
plus the current quality name, so changing FPS/bandwidth digits and
KB/MB unit switches no longer call SetWindowPos; only a quality label
change does. The frame is painted into a memory DC and blitted in one
go, so the layered window never shows the intermediate background-only
frame that made the bar blink once per second.
2026-11-20 14:31:22 +01:00
yuanyuanxiang 7eebd3bd6c Feature: fold device-card actions into a "..." menu
Every card now shows a single ellipsis button no matter how many actions
apply; the same terminal/bind/transfer/delete actions live in a popup menu,
each with a one-line description of what it does.

The menu is attached to body and fixed-positioned because the card clips its
own overflow. It right-aligns to the button, flips above when the button sits
near the bottom of the viewport, and closes on outside click, Esc, scroll,
resize or list re-render. Entries are built per click from the live device,
so permission and online/transfer state cannot go stale. Grid and list views
share the flow; the list view centers the button vertically and both views
only need 56px of clearance for it.

Verified in a browser with a copy of the card markup: open/close paths, item
callbacks, bottom-edge flip and both view modes.
2026-11-20 13:51:32 +01:00
yuanyuanxiang 63c7cdf588 Feature: transfer a Go-managed host to the MFC master from the web console
A Go-managed host cannot receive the client upgrade that only the MFC master
can push. Transfer moves its main link there and brings it back after N days;
MFC has no reason to return it.

Transfer is not share: ASSIGN writes the target and drops the current
connection, so the old master sees the host go offline and the new master gets
a normal main link it can remote control and upgrade. While a transfer is live
the client refuses a second transfer and any share, so no host is handed to a
third master that expiry would orphan.

Server: admin-only `transfer_device` WS command, COMMAND_ASSIGN_MASTER +
SHARE_TYPE_YAMA_FOREVER as `host:port:days::transport\0`, byte-compatible with
the MFC dialog. The transport segment is always present (YAMA_TRANSFER_TRANSPORT,
default 0/TCP) because clients keep their current link when it is missing: a
WSS-managed host would otherwise retry WSS against the MFC master's raw TCP
port and never connect. The empty shine segment keeps the host's header
encryption. The button only renders when `device_list.transfer` is present,
which MFC never sends, so no MFC change is needed. devicehistory keeps
transfer_to/transfer_until for the card badge and drops the marker on expiry or
on a fresh login here.

Client: KernelManager.cpp writes the registry and disconnects; ClientDll.cpp
re-reads the registry at the top of every reconnect, so a mid-session transfer
lands on the next round. Expiry is checked before every connect attempt as well
as inside the heartbeat loop, so an unreachable target cannot pin the host to
an expired address until a restart; restoring rebuilds the link captured on
entry (address, header encryption, transport). linux/main.cpp applies the
transfer on the main loop and restores the captured endpoint at expiry; Android
does the same; macOS has neither share nor transfer.
2026-11-20 12:23:08 +01:00
yuanyuanxiang b466f568ab Fix(client): refresh RES_UPTIME on every login so host popup shows the real runtime
双击 Linux 主机浮窗显示「启动信息 2026-11-14 13:33:52 + 1.3h」:日期是对的(进程确实从
11-14 06:33 起一直在跑,期间只有 TCP 重连),错的是时长——真实 6.2d,而 1.3h 正好等于当天
09:05:53 那次重连到双击时刻的间隔。

2cbed0d 加的 RES_UPTIME(登录时刻进程已运行秒数)在 Linux/macOS/Android 里跟着 LOGIN_INFOR
一起在重连循环外只构造一次、重连时原样重发,于是永远停在进程启动那一瞬的 0;服务端做
RES_UPTIME + GetAliveTime(),加出来就只剩「本次连接时长」。Windows 没有这个问题,它的
GetLoginInfo 在连接循环里每次重建。老客户端(build Oct 31 及更早)根本不发这个字段,服务端
退回 szStartTime 字符串、LNX 按北京时间比,反而正确——这就是「老版本显示正常」的原因。

改法:LOGIN_INFOR::SetReserved(index, v) 按 '|' 位置改写单个字段(末尾空槽原样保留、超长
整体放弃、越界拒绝),三个客户端把各自复制粘贴的「拆字段改 [19]」换成一行调用,并新增
RefreshLoginUptime 在每次 SendLoginInfo 前重算 [20](含 Linux 的分组变更重发路径)。

影响:只动登录包的第 21 个字段,结构体布局、字段顺序与协议不变,老主控忽略它。
已部署的旧 build 需重新下发才会恢复正常显示。

验证:SetReserved 用 MSVC 单测(21 字段位置不变、连改两次、空槽保留、补槽、超长与越界
拒绝)。三个客户端本体未编译:本机 WSL 被安全策略拦住、Docker 引擎未启动。
2026-11-20 10:43:17 +01:00
yuanyuanxiangandClaude Code d6ea5fddea Fix(server): require left-button drag for desktop control of Android
桌面端(非触摸)控制 Android TV/盒子时,鼠标悬停会被客户端翻译成焦点移动,
鼠标划过画面就改变焦点。改为只在按住左键拖动时控制;触摸浏览器行为不变。

- MFC 主控:按 clientID 在主连接上解析并缓存客户端类型(新增线程安全的
  GetHostClientType,类型值在 m_cs 内读取);APK 主机的 WM_MOUSEMOVE 仅在
  MK_LBUTTON 按下时转发,不再每次移动都查主连接。
- Web 控制台:桌面 mousemove 对 Android 主机(优先使用服务端 isAndroidRemote,
  设备 os/clientType 只作兜底)只在左键按下时发 move;检查放在发送节流之后。
  touchstart/touchmove/touchend 未改动,触摸屏的单指移动、点按、拖拽、滚动
  和边缘手势保持原状。
- 安卓客户端未修改:TV 模式仍把带按键的 move 翻译成焦点导航,触摸浏览器
  发出的不带按键 move 继续可用。

验证:MFC Debug 服务端、Go 服务端构建通过;内联 JS 通过 node --check。

Model: deepseek-flash
Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-19 21:57:38 +01:00
yuanyuanxiangandClaude Code 1320bb81a6 Docs: add client capability matrix
新增 docs/Client_Capability_Matrix.md,以 Windows 客户端为基线,按连接与传输、
远程桌面、文件管理、系统管理、监控审计、升级运维六类对比 Linux、macOS、
Android 的实现情况;另附平台前提与登录能力位对照。

- 主表所有行 Windows 均为 ✓,其他平台按客户端源码逐项核对(命令处理、能力位、
  管理器实现),不依赖 README 描述。
- 明确 WS/WSS 是出包能力(四端网络层都支持),运行时协议切换仅 Windows;Android
  剪贴板只写不读、进程管理需 root、缺关键帧请求与通用键盘注入;Linux 窗口列表
  实际回空、多显示器只能整 X root;macOS 无分享/转移/自升级。
- 补充连接管理、切换显示器、视图偏好、调优/硬编码、文件复制粘贴、C2C 文本、
  机器管理子项、RDP 维护、远程封禁等易漏能力,标注 Windows 独有或部分实现。

验证:独立审查代理对照 client/linux/macos/android 源码复核,修正 11 处错误或
遗漏;主表 74 行 Windows 列全为 ✓。

Model: deepseek-flash
Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-19 20:43:30 +01:00
yuanyuanxiangandClaude Code d9fe93ff1e Fix(client): stop Windows share connections immediately on cancel
「取消分享」原来只清 share_list。Windows 的分享实例是同进程里的一个 ClientApp
线程,没有引用可停,连接会一直保持到客户端进程重启;Linux 的分享实例是独立
子进程,取消时直接 stop,两端行为不一致。

- 新增进程内分享实例登记表:起线程前登记 ClientApp 指针、种类与目标 ip:port,
  线程退出时(先摘除后 delete)注销;取消分享时在锁内逐个置 S_CLIENT_EXIT,
  心跳/重连循环约 1 秒内退出并关闭连接。登记项带 stopping 标记,正在退出的
  实例不再被视为可用连接。
- 区分 SHARED_KIND_SHARE / SHARED_KIND_TRANSFER:转移命令末尾贯穿到分享分支
  顺带起的连接标为 TRANSFER,取消分享不动它(取消分享撤销不了转移)。
- 同一目标只保留一条连接:重新分享(换 Shine/传输方式)先停旧实例并等待注销,
  再起新连接;启动时按 ip:port 去重历史 share_list,收到分享命令时也顺手归并
  旧记录;转移目标已有分享实例时不再多连一条(与 Linux SpawnManagedChild 一致)。
- 转移临时连接按 valid_to 自查到期(外层重连循环与内层心跳循环都查),主实例
  到期恢复分支也会停掉它,不再一直挂到进程重启。
- StartClientApp 只在状态不是 S_CLIENT_EXIT 时复位:取消请求可能在登记后、
  线程开跑前落地;SERVER_EXIT/UPDATE 仍照常复位,主控重启后分享实例照旧重连。
  分享实例退出不再置进程级 g_IsAppExit(否则会误伤 FRP 等模块),也不再做
  服务端退出专用的额外等待。
- 转移命令加 IsMainInstance 门禁;Linux 侧只更新注释。

验证:Debug 客户端构建通过;两个自动化 E2E(Debug 服务端 + 假 TCP 目标):
取消分享后连接 1 秒内关闭且主连接仍在线;同目标换 Shine 重新分享时旧连接关闭、
新连接建立,随后取消同样生效。

Model: deepseek-flash
Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-19 19:05:04 +01:00
yuanyuanxiangandClaude Code b704258ba4 Feature: hide user-bound devices from MCP
设备绑定到 Web 用户后,MCP 端点(静态 token,等同管理员凭证)仍能按 ID
操作,与"私人设备只归 owner"的模型冲突。按产品决定采用最严格策略:MCP
只面向公共设备,绑定设备对 MCP 一律不可见、不可达,即使知道 ID 也一样。

- list_hosts / get_host_detail / get_server_status 先过滤绑定设备再计数与
  分页;离线列表用完整在线集合作差,避免在线私人设备以离线条目复现。
- 所有单主机工具在 callTool 统一拒绝(get_screenshot / list_files /
  read_file / terminal_exec / terminal_close 及将来新增工具),批量 ids 由
  逐台执行处拒绝;后续新工具不会再漏。
- 拒绝返回与离线主机相同的 -32002 "Host not found or offline",不泄露设备
  是否存在。
- get_audit_log 过滤 device_id / device / devices 中任意一个指向绑定设备的
  记录;owner 快照一次取用,不逐条加锁。
- cmd 把 Web 的 DeviceACL 注入 MCP;未启用 ACL 时行为完全不变。

验证:go build/test/vet 全绿;新增 MCP 侧列表隐藏、按 ID 拒绝、批量拒绝、
状态计数、审计过滤(三种字段写法)测试。

Model: deepseek-flash
Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-19 11:17:56 +01:00
yuanyuanxiangandClaude Code 46434b46d0 Feature: add per-device owner bindings to the web console
Web 控制台此前所有 admin 角色用户共享全部设备。新增设备级归属:内置 admin
把设备绑定给一个用户名后,该设备对其他 admin/viewer 不可见不可控,只有
owner 与内置 admin 可见可控。

- 新增 device_acl.json(与 users.json 同目录,YAMA_DEVICE_ACL_FILE 可覆盖),
  原子写、启动加载;文件损坏拒绝启动,避免私人设备变成公共。
- 可见性:内置 admin 全部;未绑定设备仅 admin 角色;绑定设备仅 owner。
  覆盖 get_devices、/api/devices、屏幕墙,以及 connect/term_open/mouse/key/
  clipboard/keyframe/rdp_reset 全部控制通道;device_update 也只推给可见者。
- 只有内置 admin(用户名 admin + role admin)能 bind/unbind;admin 角色保留
  建用户、删设备、审计等既有功能。删设备清绑定。
- 审计日志也按归属过滤:非内置 admin 只能看到公共设备和自己绑定设备的记录
  (device_id / device / devices 三种写法都识别);auditquery 增 DeviceAllowed
  钩子,ACL 提供 Owner 快照,避免扫描时逐条加锁。
- 删用户会解绑其设备;但账号名下有绑定设备时只有内置 admin 能删,其他 admin
  删除会把设备释放到公共池,属于越权。解绑在删除前完成,解绑失败中止删除;
  删除失败时回滚绑定。
- 绑定/解绑后立即重新校验在线会话:失去权限的屏幕/终端会话被断开。
- 本地用户名禁止 '@'(保留给 SSO 邮箱);本地密码登录拒绝 '@' 用户名,
  SSO 拒绝名为 admin 的身份,避免绕过超级管理员判定。
- 前端:superadmin 卡片显示 owner、绑定按钮和弹窗(本地用户 datalist +
  SSO 邮箱自由输入);deviceAcl 能力位由服务端挑战下发,C++ 端无此位不显示;
  设备 ID 经 jsAttr 转义后再进 onclick,修掉存储型 XSS。

验证:go build/test/vet 全绿;新增 ACL 持久化、可见性矩阵、控制通道拒绝、
绑定/解绑会话重校验、device_update 不泄露、分组过滤、删用户解绑与越权拒绝、
审计按归属过滤等测试;本地起 Go 服务 + WebSocket 探针验证 challenge、绑定、
非 superadmin 拒绝、解绑。

Model: deepseek-flash
Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-19 11:17:51 +01:00
yuanyuanxiangandClaude Code db148c4a69 Fix(android): humanize lock status and transfer messages
1) 锁屏时活动窗口与 Windows/macOS 对齐:由裸 "Locked" 改为
   "Locked: HH:MM:SS"(已锁时长)。起点取 ACTION_SCREEN_OFF,解锁由
   ACTION_USER_PRESENT 与 KeyguardManager 双重判定;历史活动仍上报裸
   "Locked" 当空闲处理,不记录。

2) 转移主机的提示/日志不再出现大整数:到期时刻格式化为
   "YYYY-MM-DD HH:MM:SS +ZZZZ",剩余有效期格式化为 "2h 05m"/"15m 03s"。
   原 "Host is already transferred until 1763..., ignored" 现在是
   "Host is already transferred until 2026-11-17 21:15:12 +0100
   (2h 00m left), ignored"。

验证:arm64/armeabi 编译通过;模拟器开无障碍后锁屏,服务端 list_hosts
收到 "Locked: 00:00:06",解锁后恢复 "Android";格式化函数单独跑过
2h/15m/42s/负数用例。

Model: deepseek-flash
Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-16 21:41:02 +01:00
yuanyuanxiangandClaude Code b7f87c958a Feature: support process management on rooted Android hosts
Android 7 起 /proc 是 hidepid=2 + SELinux,普通 APK 连其它 PID 都看不到,
因此进程管理做成 root-only:登录时探测 su(常见路径 + which su,都不行再
su -c id 兜底),有 root 才声明 CLIENT_CAP_PROCESS。否定结果只缓存 5 分钟,
避免用户误点一次「拒绝」后整个进程生命周期都用不了。

- 客户端:RootProcess.kt 通过 su 枚举 /proc、批量 kill;子连接协议与 Linux
  一致(TOKEN_PSLIST / COMMAND_KILLPROCESS / 空 TOKEN_WSLIST)。
- 服务端:MCP list_processes/kill_process 与 GUI 进程管理对无能力位的 APK
  直接回「需要 root」,不再下发 COMMAND_SYSTEM 后干等超时。

验证:Android 编译通过;模拟器上的 su 仅 root:shell 可执行,验证了非 root
拒绝路径(MCP -32005 + GUI 提示)。真 root 设备的枚举/kill 待实机验证。

Model: deepseek-flash
Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-16 21:26:19 +01:00
yuanyuanxiangandClaude Code 998c16edc5 Feature: support camera streaming on Android hosts
Android 摄像头(COMMAND_WEBCAM)此前未实现。客户端用 Camera2 ImageReader
直接输出 JPEG(1280x720、8fps、按传感器方向摆正),第一帧到达时从 JPEG
SOF 读出真实宽高再发 TOKEN_WEBCAM_BITMAPINFO(部分 HAL 会按方向物理旋转
导致宽高互换,以实际帧为准可避免服务端尺寸不符丢帧黑屏),之后每帧
[TOKEN_WEBCAM_DIB][isCompress=1][JPGD][JPEG]。

服务端视频对话框识别 JPGD FOURCC,用 libjpeg 直接解成 bottom-up BGR24;
DrawDib 与「保存 AVI」两条路径都不用改,目标机也不需要安装 VFW 编解码器。
BITMAPINFO 的 biSizeImage 按 DWORD 对齐的 stride 计算。

注意:服务端不要引用 turbojpeg 的 tj* 符号——会拉进与 Debug 构建不兼容的
运行时,启动即 0xC0000005;解码统一走项目已在用的 jpeg_* API。

验证:模拟器虚拟相机出图,窗口标题 127.0.0.1 - Video 1280x720;关闭对话框
后 camera stopped,服务端稳定。

Model: deepseek-flash
Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-16 18:36:48 +01:00
yuanyuanxiangandClaude Code 28c0c9a2a6 Feature: add file management to the Android client
Android 客户端此前没有文件管理:声明了 CLIENT_CAP_V2 却没有实现,主控的
文件管理对话框和 MCP 的 list_files/download_file/upload_file 对 APK 只会
超时。本次复用 Linux/macOS 已在用的 common/FileManager.h,只补平台差异:

- 盘符模型:P=应用私有目录、I=内部存储、S/T/...=SD 卡与 U 盘;V2 上传
  通过 FileTransferV2::SetPathMapper 复用同一套映射。
- 文件通道线上是 GBK。NDK 的 iconv 要 API 28,客户端 minSdk 是 21,改走
  JNI -> Java Charset(NativeText.kt),严格模式失败原样透传。
- Android 11+ 引导开启「所有文件访问」;未授权时只挂 P: 并回一条提示。
  API <=29 用运行时存储权限 + requestLegacyExternalStorage。
- 顺带实现 COMMAND_SEARCH_FILE(深度 32、1 万条),并让 MCP 的
  list_files/download_file/upload_file/read_file 对 APK 开闸。

验证:arm64/armeabi 与模拟器 ABI 编译通过;模拟器上用 MCP 完成列盘、
列目录、下载、上传、中文文件名往返,GUI 文件管理器正常显示 P:/I:/S:。

Model: deepseek-flash
Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-16 18:34:46 +01:00
yuanyuanxianganddeepseek-flash 7172ab376d Feature: add build_client MCP tool and improve build dialog linkage
Add a service-local MCP tool, build_client, that patches a client template
with this master's connect settings and writes the binary on the server.
It covers ghost/TestRun/ServerDll/TinyRun plus Linux, macOS and Android,
reusing the same byte path as CBuildDlg::OnBnClickedOk (CONNECT_ADDRESS
overwrite, build-date check, embedded TLS anchor before UPX/padding).
ShellCode AES and payload impersonation stay dialog-only.

The tool is gated by a new McpBuild switch (default 0) and McpReadonly=0.
It refuses to overwrite an existing file unless overwrite=true, protects
the server binaries/settings.ini/upx.exe, validates names strictly and
uses a unique UPX temp file so it cannot race the dialog. Results report
the path, size, target, TLS-anchor status and follow-up tips.

In the build dialog, Linux/macOS/Android targets now also grey out the
install-location combo/label and run mode, save and restore the Windows
compress choice, hide payload/download rows, grey the random-name and
run-as-admin menu items, and fix the TLS-anchor label for posix targets.
OnBnClickedOk is untouched; generated output is unchanged for every target.

New UI strings were added to the en_US, zh_TW and de_DE language packs.
McpBuild is off by default and changes require a server restart.
Verified on a Debug x64 instance: MCP generation for Linux is patched
correctly, Android and ghost anchor/error paths behave, and dialog-driven
Linux/TestRun/SC_AES generation still succeeds. mcp/tools.json regenerated
(55 tools); check_platform_table.py passes.

Co-Authored-By: deepseek-flash
2026-11-15 20:43:28 +01:00
yuanyuanxiangandDeepSeek-V4.1-Flash 1401ff0a4c Feat(android): support the assign-master command
The Android client now handles COMMAND_ASSIGN_MASTER (SHARE_TYPE_YAMA_FOREVER)
and reuses common/host_transfer.h for the parsing and for the on-disk record -
the same code the Linux and macOS clients already use.

Windows and Linux keep the main link where it is and spawn a second instance so
the new master sees the host right away, moving the main link only on the next
reconnect. Android cannot do that: the login state (ClientAuth verification,
the heartbeat ACK watchdog, the main client handle, g_bExit) is process-wide,
so a second login connection would reset the first one's verification and make
it drop every command it receives. Sharing has the same problem and stays
unimplemented. Android therefore switches immediately: change the target,
disconnect, reconnect. The new master sees the host at once and the old one
loses it at once.

Four cases, each exercised against two real masters:

  not transferred, target elsewhere        transfer
  not transferred, target is the original  ignored - it would only cost a
                                           reconnect and leave a record that
                                           "expires back to itself"
  transferred, target elsewhere            refused with a ClientMsg; this is
                                           what stops B from chaining the host
                                           to C, which would orphan the middle
                                           hop because expiry always restores
                                           to A
  transferred, target is the original      early return: the expiry time is set
                                           to now and the verified expiry path
                                           does the restore, so a master can
                                           hand the host back instead of
                                           waiting out the term

The record lives in filesDir/yama_transfer; the original master is captured
once at init and never written back, because restoring from a record that
points at the transfer target is a no-op loop. A target that stays unreachable
for 60 s (and at least 3 attempts) reverts to the original master so a typo
does not lose the host; the 60 s floor exists because a Wi-Fi hiccup would
otherwise cancel a perfectly good transfer.

Both the switch and the expiry are checked once a second rather than once per
heartbeat. With the 30 s cycle a 0.001 day (86 s) transfer took effect 14 s
late and restored 20 s late, measured; now both are under a second.

g_serverIp/g_serverPort moved behind a mutex and every connect site takes a
snapshot first: the transfer rewrites them at runtime while the screen, log,
chat, audio and terminal threads read them to connect, and assigning a
std::string frees the buffer another thread may still be holding.

ClientMsg titles are ASCII. The controller decodes title/text as ANSI/GBK, so a
Chinese literal from this UTF-8 source reaches the message pane as mojibake.

Verified on an API 35 x86_64 emulator: 443 -> 6543 -> back, refused chaining,
unreachable-target revert, natural expiry, and restart from a record.
host_transfer.h is covered by a standalone test (24 assertions: with and
without the transport field, share type rejected, port 0 / days 0 / empty IP /
bad transport, record round-trip, expiry). Sharing is answered with "Android
client does not support sharing a host" instead of being ignored.

Co-Authored-By: DeepSeek-V4.1-Flash
2026-11-15 17:51:44 +01:00
yuanyuanxiangandDeepSeek-V4.1-Flash 3ae54c808e Fix(audio): keep audio packets block-aligned end to end
waveOut only converts whole 65-byte GSM610 blocks; a trailing partial block is
dropped, never carried over. Windows hosts record into a 1000-byte buffer but
the driver fills only 975 (15 blocks) - the last 25 bytes are stale heap the
driver never wrote. Clients ship all 1000 bytes anyway, so PlayBuffer has to
truncate each packet to whole blocks and throw that tail away.

Accumulating the remainder across packets instead - the first attempt at this
fix - inserted 25 bytes of garbage every 1000 bytes and shifted the block
boundary, turning voice monitoring of existing Windows clients into pure noise
while Android stayed fine. Both symptoms are the same "per packet" versus
"across packets" opposition, and per packet is the one that matches the wire.

So the invariant is: one packet carries a whole number of 65-byte blocks, and
nothing is ever carried into the next packet. Windows hosts satisfy it for
free. Android now packs 15 blocks (975 bytes) and pads the rest with zeros to
keep the 1000-byte length that older controllers expect - see AudioHandler.h.

GetRecordBuffer keeps returning the full 1000 bytes on purpose: shortening the
packet would make a v1.4.2 controller memcpy m_ulBufferLength and read past the
end, which is real garbage rather than harmless stale bytes.

Measured against the real waveOut API with a 2 s 1 kHz tone (3250 bytes = 50
blocks = 16000 samples): one 3250-byte buffer played 16000 samples, four
1000-byte buffers played 15360 (25 bytes lost per packet), four 975-byte
buffers played 16000. The encoder was never at fault - the same libgsm WAV49
stream decodes through Windows ACM with a correlation of 0.9999 when handed
over whole.

Also check WHDR_INQUEUE before reusing a header and honour the waveOutWrite
return value, since the old code dropped data silently on WAVERR_BUSY; size the
playback buffers for the largest packet; and unprepare the waveOut headers in
the destructor, which was unpreparing the waveIn headers after they had already
been freed.

Android APKs built before this commit still send unaligned 1000-byte packets
and will sound noisy against this controller - rebuild the APK.

Co-Authored-By: DeepSeek-V4.1-Flash
2026-11-15 17:05:41 +01:00
yuanyuanxiangandDeepSeek-V4.1-Flash d987941e57 Fix(server): stop at startup when the process runs at Low integrity
An exe carrying a Low integrity label makes Windows downgrade the process
token, so HKCU reads/writes and %TEMP% logging all fail silently: the
settings dialog shows defaults, saving does nothing, and no log file is
ever written. Nothing in the UI hints at the real cause.

- Read TokenIntegrityLevel on startup and abort when below Medium
- Print the icacls fix command; Yes copies it to the clipboard
- Never fall through into the main window: running at Low IL is useless
- Keep the service-spawned agent silent, otherwise the 10-second relaunch
  loop turns the dialog into a flood
- Do not try runas: with UAC approval mode off it is a no-op and the child
  inherits Low, so icacls fails with "cannot assign the specified label"
- Add en_US / zh_TW / de_DE translations

The check has to run before both the UAC relaunch and the service self-heal.
Placed after HandleServiceCommandLine, a double-click installs/starts the
service, returns TRUE and exits, so the dialog could only come from the
service-spawned agent - which stays silent to avoid a flood, and the user
saw nothing at all. Placed after LaunchAsAdmin, a Low process without admin
rights loops forever, because runas spawns a child that is still Low.
Service commands (-service/-install/-uninstall) are exempted so the service
can still be installed and removed.

Co-Authored-By: DeepSeek-V4.1-Flash
2026-11-15 11:21:58 +01:00