Feature(Go): read_file over the V2 stream receiver
read_file reuses the list_files handshake: COMMAND_LIST_DRIVE opens the file-manager sub-conn, which then gets [CMD_DOWN_FILES_V2][targetDir\0][path\0][\0] and streams COMMAND_SEND_FILE_V2 chunks plus a COMMAND_FILE_COMPLETE_V2 carrying the whole-file SHA-256. Windows clients open a fresh authenticated sub-conn for the chunks; POSIX clients stream on the file-manager conn itself, so that conn is retired when the call ends rather than right after the request. TOKEN_DOWNLOAD_ERROR on the file-manager conn maps to -32009 / -32010 / -32000 like the Win32 server. Bytes land only in a per-call os.MkdirTemp dir; the client name is checked against the target dir (separator-normalised, path.Clean, so ..\.., absolute, UNC and mixed separators are refused) as defence-in-depth, never used as a path. First chunk enforces the size gate (ReadMax) and rejects multi-file batches, so an expanded directory fails with -32602 instead of returning its first file. Chunks from a sub-conn opened for an earlier call are dropped by connection ID, data sub-conns are closed when the call ends, and a closed sub-conn fails the call fast instead of waiting for the stall watchdog. Text windowing, encoding detection (BOM / UTF-8 / GBK / explicit / latin1) and EOL handling mirror McpServer.cpp. Verified with the Debug ghost on Windows 11 and the WSL Ubuntu ghost: .env text plus newline is byte-identical, sha256 equals SHA-256 over the file, windows/GBK/empty/ max_bytes/directory/size-gate/missing-path/POSIX-path cases all pass. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
d7accf1d30
commit
9ce1a58bc3
7 files changed
+1790
-71
No files matched your search
@@ -148,6 +148,9 @@ const (
|
||||
CommandUninstall byte = 63 // TOKEN_UNINSTALL - uninstall the host agent (single byte)
|
||||
CommandTerminalRsize byte = 81 // CMD_TERMINAL_RESIZE - [cmd:1][cols:2 LE][rows:2 LE]
|
||||
CmdRestoreConsole byte = 82 // CMD_RESTORE_CONSOLE - RDP session "归位": switch back to the console session and restart capture
|
||||
CommandSendFileV2 byte = 85 // COMMAND_SEND_FILE_V2 - one V2 file chunk (77-byte packed header + name + data)
|
||||
CommandFileCompleteV2 byte = 91 // COMMAND_FILE_COMPLETE_V2 - end of one V2 file, carries its SHA-256
|
||||
CmdDownFilesV2 byte = 94 // CMD_DOWN_FILES_V2 - [cmd][targetDir\0][path\0][\0] on the file-manager sub-conn
|
||||
CommandScreenKeyframeReq byte = 169 // COMMAND_SCREEN_KEYFRAME_REQ - force the client to emit an IDR immediately
|
||||
CommandBye byte = 204 // COMMAND_BYE - disconnect
|
||||
CommandHeartbeat byte = 216 // CMD_HEARTBEAT_ACK
|
||||
@@ -168,6 +171,10 @@ const (
|
||||
// directory" reply: [token:1][win32err:4 LE]. Legacy clients send nothing,
|
||||
// which the server can only report as a timeout.
|
||||
TokenFileListError byte = 171 // TOKEN_FILE_LIST_ERROR - directory listing failed
|
||||
// TOKEN_DOWNLOAD_ERROR is the file-manager sub-conn's "nothing to send"
|
||||
// reply to CMD_DOWN_FILES_V2: [token:1][win32err:4 LE]. The transfer sub-conn
|
||||
// is not created in that case, so this is the only failure signal.
|
||||
TokenDownloadError byte = 173 // TOKEN_DOWNLOAD_ERROR - download request rejected
|
||||
TokenTerminalStart byte = 232 // TOKEN_TERMINAL_START - modern PTY shell sub-conn open
|
||||
TokenTerminalClose byte = 233 // TOKEN_TERMINAL_CLOSE - shell exited / close ack
|
||||
TokenConnAuth byte = 246 // TOKEN_CONN_AUTH - sub-connection identity handshake
|
||||
|
||||
Reference in new issue
Block a user