Fix(server,client): keep web terminal alive across heartbeat reconnects
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
This commit is contained in:
1 parent
4aedca8ee0
commit
81f0d6c031
8 files changed
+412
-46
No files matched your search
@@ -134,6 +134,26 @@ const (
|
||||
CmdSockDllLoader byte = 210 // SOCKET_DLLLOADER - shellcode/memory-DLL loader requests the full DLL payload
|
||||
)
|
||||
|
||||
// HeartbeatACK (CMD_HEARTBEAT_ACK) response layout — mirrors the HeartbeatACK
|
||||
// struct in common/commands.h, where sizeof(HeartbeatACK) == 1024.
|
||||
//
|
||||
// Size matters: clients deployed before 2026-11 gate the ACK on
|
||||
// `ulLength >= 1 + sizeof(HeartbeatACK)` (1025 bytes) and silently drop
|
||||
// anything shorter. That never feeds their application-level ACK watchdog,
|
||||
// so they reconnect every 60s forever — a 33-byte reply here did exactly
|
||||
// that on the Go server. Current clients accept both sizes (they clamp to
|
||||
// min(ulLength-1, sizeof)), and the C++ server always sends 1+1024
|
||||
// (2015RemoteDlg.cpp), so the wire is 1+1024 for everyone. Windows was the
|
||||
// only client tolerant of the short form from the start (KernelManager.cpp
|
||||
// copies min(ulLength, 32)).
|
||||
const (
|
||||
HeartbeatACKSize = 1024
|
||||
HeartbeatACKOffTime = 0 // uint64 LE — the request's Time, echoed back
|
||||
HeartbeatACKOffAuthorized = 8 // byte — 0/1/2 (2 = authorized by admin)
|
||||
HeartbeatACKOffIsTrail = 9 // byte — trial master
|
||||
HeartbeatACKOffProcessing = 212 // uint32 LE — server-side processing time (ms)
|
||||
)
|
||||
|
||||
// Sub-connection authentication (matches common/commands.h ConnAuth* structs).
|
||||
// Each newly-opened sub-conn first sends a 512-byte ConnAuthPacket, then waits
|
||||
// for a 256-byte ConnAuthAck before any further command is meaningful.
|
||||
|
||||
Reference in new issue
Block a user