Feature: add a remote file hash query for the file manager
Add COMMAND_FILE_HASH/TOKEN_FILE_HASH (182/183) and the CLIENT_CAP_FILE_HASH capability so the server can ask a client for a single file's exact size, mtime and SHA-256 without transferring it. This is the P2 half of the double-click preview design; old clients do not advertise the capability and are skipped by the caller. Windows hashes with BCrypt through the existing VerifyV2 helper; Unix and Android stream Sha256 while reading. Both clamp the peer-supplied maxBytes to FILE_PREVIEW_MAX_BYTES, echo the original request path bytes for correlation, and return TOO_LARGE without reading the file. The Unix loop also verifies the bytes hashed match stat() so a file changed mid-read reports an error instead of a mismatched hash. No existing command changes; the new values are explicit and the four DefaultCaps branches advertise the capability. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
b44935270a
commit
e39b9d1ed5
5 files changed
+263
No files matched your search
@@ -74,6 +74,14 @@ public:
|
||||
return (strtoul(caps.GetString(), nullptr, 16) & CLIENT_CAP_V2) != 0;
|
||||
}
|
||||
|
||||
// 检查客户端是否支持远程文件哈希查询(COMMAND_FILE_HASH)。
|
||||
// 只在主连接上有效;文件管理器子连接不填 CAPABILITIES,需先解析主连接。
|
||||
bool SupportsFileHash() const {
|
||||
CString caps = GetClientData(ONLINELIST_CAPABILITIES);
|
||||
if (caps.IsEmpty()) return false;
|
||||
return (strtoul(caps.GetString(), nullptr, 16) & CLIENT_CAP_FILE_HASH) != 0;
|
||||
}
|
||||
|
||||
// 检查客户端是否使用 UTF-8 协议字符串编码。
|
||||
// 无此能力位的老客户端:服务端按 CP_ACP(CP936,覆盖 95% 的简中/英语 ASCII 老客户端)解读。
|
||||
bool SupportsUtf8() const {
|
||||
|
||||
Reference in new issue
Block a user