From 3683b4ebeb2b7da0805f5c45df5eac1ac8dba579 Mon Sep 17 00:00:00 2001 From: yuanyuanxiang <962914132@qq.com> Date: Sat, 5 Dec 2026 15:32:26 +0100 Subject: [PATCH] Feature: localize the preview messages and report the cached hash Add the preview strings to en_US, zh_TW and de_DE (GBK, no '=' in keys; German uses ASCII transliterations where GBK cannot encode umlauts), and pass the cached entry's SHA-256 back to the open helper so the executable confirmation shows the actual hash on a cache hit. Honour PreviewEnabled=0 by leaving double-click unchanged, and document the preview plus COMMAND_FILE_HASH capability in the client matrix. Co-Authored-By: deepseek-flash --- docs/Client_Capability_Matrix.md | 11 +++++++---- server/2015Remote/FileManagerDlg.cpp | 6 +++--- server/2015Remote/FilePreview.cpp | 8 ++++++-- server/2015Remote/FilePreview.h | 3 ++- server/2015Remote/lang/de_DE.ini | 18 ++++++++++++++++++ server/2015Remote/lang/en_US.ini | 18 ++++++++++++++++++ server/2015Remote/lang/zh_TW.ini | 18 ++++++++++++++++++ 7 files changed, 72 insertions(+), 10 deletions(-) diff --git a/docs/Client_Capability_Matrix.md b/docs/Client_Capability_Matrix.md index 59e87b0..12a6b1e 100644 --- a/docs/Client_Capability_Matrix.md +++ b/docs/Client_Capability_Matrix.md @@ -86,6 +86,8 @@ | ç£�盘/目录æµ�览 | ✓ | ✓ | ✓ | ✓ | | 上传/下载 | ✓ | ✓ | ✓ | ✓ | | V2 文件传输通é�“ | ✓ | ✓ | ✓ | ✓ | +| å�Œå‡»è¿œç¨‹æ–‡ä»¶é¢„览(≤8 MiB) | ✓ | ✓ | ✓ | ✓ | +| 远程文件 SHA-256 查询(`COMMAND_FILE_HASH`) | ✓ | ✓ | ✓ | ✓ | | 断点续传 | ✓ | — | — | — | | 删除/é‡�命å��/新建目录 | ✓ | ✓ | ✓ | ✓ | | 文件æ�œç´¢ | ✓ | — | — | ✓ | @@ -97,6 +99,7 @@ | æ�’件文件管ç�†ï¼ˆSimplePlugins) | ✓ | — | — | — | 说明: +- å�Œå‡»é¢„览:由æœ�务端把远程文件ç»� V2 拉回 `Preview\\` 并打开;客户端å�ªè¦�求 V2 通é�“(≤8 MiB)。P1 按列表的精确 size+mtime 命中缓存,P2 用 `COMMAND_FILE_HASH` 按内容哈希命中。 - 断点续传:仅 Windows 客户端处ç�† `COMMAND_FILE_QUERY_RESUME` / `COMMAND_FILE_RESUME`;其他平å�°èµ° V2 普通传输,ä¸�å“�应续传查询。 - C2C 文件:Windows 支æŒ�å�‘é€�(`CLIENT_CAP_C2C_PATHS`)与接收(`COMMAND_C2C_PREPARE/_RESP`);Linux/macOS å�ªå�šæŽ¥æ”¶ç«¯å¹¶åœ¨è�½ç›˜å�Žå›žæ‰§ï¼ˆ`CLIENT_CAP_C2C_RECV_ACK`);Android 未实现。C2C 需è¦�æ”¶å�‘两端能力é…�å�ˆï¼Œå�•端具备能力ä¸�等于任æ„�两平å�°ä¹‹é—´éƒ½èƒ½ç›´ä¼ ã€‚ - C2C 剪贴æ�¿æ–‡æœ¬ï¼ˆ`COMMAND_C2C_TEXT`):Windows 能å�‘é€�也能接收;Linux/macOS å�ªå¤„ç�†æŽ¥æ”¶ç«¯ï¼ˆæœ�务端下å�‘文本å�Žå†™å…¥æœ¬æœºå‰ªè´´æ�¿ï¼ŒLinux 需è¦� `xclip`/`xsel`);Android 未实现。 @@ -171,9 +174,9 @@ | å¹³å�° | 默认能力ä½� | è¿�行时追加 | |---|---|---| -| Windows | V2ã€�UTF8ã€�SCREEN_PREVIEWã€�C2C_PATHSã€�PROTO_SWITCHã€�VIRTUAL_DESKTOPã€�WINDOW_INFOã€�SCREEN_REGION | 仅当本次连接走 TLS 且使用内嵌锚时追加 EMBEDDED_ANCHOR | -| Linux | V2ã€�UTF8ã€�C2C_RECV_ACKã€�PROCESS | SCREEN_PREVIEW(有å�¯æŠ“ X11 桌é�¢æ—¶ï¼‰ | -| macOS | V2ã€�UTF8ã€�TERMINALã€�SCREEN_CLIPBOARDã€�PROCESSã€�C2C_RECV_ACK | SCREEN_PREVIEW(已授录å±�æ�ƒé™�时) | -| Android | V2ã€�UTF8ã€�APK_UPDATEã€�SCREEN_CLIPBOARDã€�UNINSTALLã€�REMOTE_CHATã€�TERMINAL | SCREEN_PREVIEWã€�LOCK_SCREENã€�PRIVACY_OVERLAYã€�PROCESS(按无障ç¢�/API/root 状æ€�) | +| Windows | V2ã€�UTF8ã€�SCREEN_PREVIEWã€�C2C_PATHSã€�PROTO_SWITCHã€�VIRTUAL_DESKTOPã€�WINDOW_INFOã€�SCREEN_REGIONã€�FILE_HASH | 仅当本次连接走 TLS 且使用内嵌锚时追加 EMBEDDED_ANCHOR | +| Linux | V2ã€�UTF8ã€�C2C_RECV_ACKã€�PROCESSã€�FILE_HASH | SCREEN_PREVIEW(有å�¯æŠ“ X11 桌é�¢æ—¶ï¼‰ | +| macOS | V2ã€�UTF8ã€�TERMINALã€�SCREEN_CLIPBOARDã€�PROCESSã€�C2C_RECV_ACKã€�FILE_HASH | SCREEN_PREVIEW(已授录å±�æ�ƒé™�时) | +| Android | V2ã€�UTF8ã€�APK_UPDATEã€�SCREEN_CLIPBOARDã€�UNINSTALLã€�REMOTE_CHATã€�TERMINALã€�FILE_HASH | SCREEN_PREVIEWã€�LOCK_SCREENã€�PRIVACY_OVERLAYã€�PROCESS(按无障ç¢�/API/root 状æ€�) | 注æ„�:Windows 的终端ã€�进程ã€�è�Šå¤©ã€�剪贴æ�¿ã€�å�¸è½½ç­‰èƒ½åŠ›è™½æœªåœ¨èƒ½åŠ›ä½�中声明,但客户端实际实现并被æœ�务端按平å�°æ”¾è¡Œï¼›å…¶ä»–å¹³å�°çš„能力ä½�缺失会被æœ�务端æ��å‰�æ‹’ç»�。 diff --git a/server/2015Remote/FileManagerDlg.cpp b/server/2015Remote/FileManagerDlg.cpp index 423110c..8c0396c 100644 --- a/server/2015Remote/FileManagerDlg.cpp +++ b/server/2015Remote/FileManagerDlg.cpp @@ -1330,14 +1330,14 @@ void CFileManagerDlg::BeginRemotePreview(const CString& fullPath) std::string basename = (pos == std::string::npos) ? remotePath : remotePath.substr(pos + 1); std::string clientKey = GetPreviewClientKey(clientID); - std::string outPath, error; + std::string outPath, error, cachedSha; CFilePreviewMgr::PrepareResult pr = CFilePreviewMgr::Instance().Prepare( clientID, clientKey, remotePath, basename, meta.size, meta.mtimeMs, - std::string(), m_hWnd, outPath, error); + std::string(), m_hWnd, outPath, error, &cachedSha); Mprintf("[Preview] prepare result=%d out=%s err=%s\n", (int)pr, outPath.c_str(), error.c_str()); if (pr == CFilePreviewMgr::PrepareCached) { - CFilePreviewMgr::OpenLocalFile(m_hWnd, outPath, remotePath, meta.size, std::string()); + CFilePreviewMgr::OpenLocalFile(m_hWnd, outPath, remotePath, meta.size, cachedSha); return; } if (pr != CFilePreviewMgr::PrepareTransfer) { diff --git a/server/2015Remote/FilePreview.cpp b/server/2015Remote/FilePreview.cpp index 02f1bd5..3fc9991 100644 --- a/server/2015Remote/FilePreview.cpp +++ b/server/2015Remote/FilePreview.cpp @@ -121,10 +121,12 @@ CFilePreviewMgr::PrepareResult CFilePreviewMgr::Prepare( uint64_t clientID, const std::string& clientKey, const std::string& remotePath, const std::string& basename, uint64_t size, uint64_t mtimeMs, const std::string& sha256, - HWND notifyHwnd, std::string& outPath, std::string& error) + HWND notifyHwnd, std::string& outPath, std::string& error, + std::string* outSha) { outPath.clear(); error.clear(); + if (outSha) outSha->clear(); std::string root = RootDir(); if (root.empty()) { @@ -157,6 +159,7 @@ CFilePreviewMgr::PrepareResult CFilePreviewMgr::Prepare( } SaveIndex(clientDir, index); outPath = localPath; + if (outSha) *outSha = hit.sha256; return PrepareCached; } } @@ -185,6 +188,7 @@ CFilePreviewMgr::PrepareResult CFilePreviewMgr::Prepare( SaveIndex(clientDir, index); EnforceCacheLimits(clientDir, index); outPath = localPath; + if (outSha) *outSha = sha; return PrepareCached; } @@ -1122,7 +1126,7 @@ bool CFilePreviewMgr::OpenLocalFile(HWND owner, const std::string& localPath, if (IsExecutableExtension(localPath)) { CString msg; - msg.Format(_TR("远程文件å�¯èƒ½æ‰§è¡Œä»£ç �,确定è¦�打开å�—?\n\n远程路径:%s\n大å°�:%llu 字节\nSHA-256:%s"), + msg.Format(_TR("远程文件å�¯èƒ½æ‰§è¡Œä»£ç �,确定è¦�打开å�—?(%s,%llu 字节,SHA-256 %s)"), CString(remotePath.c_str()), (unsigned long long)size, CString(sha256.size() >= 16 ? sha256.substr(0, 16).c_str() : sha256.c_str())); diff --git a/server/2015Remote/FilePreview.h b/server/2015Remote/FilePreview.h index af0faed..ae704f1 100644 --- a/server/2015Remote/FilePreview.h +++ b/server/2015Remote/FilePreview.h @@ -69,7 +69,8 @@ public: PrepareResult Prepare(uint64_t clientID, const std::string& clientKey, const std::string& remotePath, const std::string& basename, uint64_t size, uint64_t mtimeMs, const std::string& sha256, - HWND notifyHwnd, std::string& outPath, std::string& error); + HWND notifyHwnd, std::string& outPath, std::string& error, + std::string* outSha = nullptr); // UI 线程:对è¯�框关闭时放弃本窗å�£çš„æ‰€æœ‰é¢„览请求。 void CancelForHwnd(HWND hwnd); diff --git a/server/2015Remote/lang/de_DE.ini b/server/2015Remote/lang/de_DE.ini index 1a66e5c..a043f9e 100644 --- a/server/2015Remote/lang/de_DE.ini +++ b/server/2015Remote/lang/de_DE.ini @@ -2352,3 +2352,21 @@ MCP \nÊ£ÓàÌìÊý°üº¬µ½ÆÚµ±Ì죻ÒѹýÆÚʱÖ÷¿Ø¹¦ÄÜ¿ÉÄÜÊÜÏÞ¡£=\nDie verbleibenden Tage schliessen den Ablauftag ein; nach Ablauf koennen Funktionen eingeschraenkt sein. ÖØÖÃ=Zuruecksetzen ÒÑÇå¿ÕÓïÑÔ°üĿ¼ÉèÖã¬Òѻָ´ÄÚÖÃÓïÑÔ£¬ÖØÆô³ÌÐòºóÉúЧ¡£=Sprachpaketordner-Einstellung geleert; integrierte Sprache wiederhergestellt. Neustart des Programms erforderlich. +ÎÞ·¨´´½¨Ô¤ÀÀ»º´æÄ¿Â¼=Vorschau-Cache-Verzeichnis konnte nicht erstellt werden +ÎÞ·¨Éú³ÉÔ¤ÀÀÇëÇó ID=Vorschau-Anfrage-ID konnte nicht erzeugt werden +ÕýÔÚÔ¤ÀÀÁíÒ»¸öÎļþ£¬ÇëÉÔºò=Eine andere Vorschau laeuft bereits, bitte warten +Ô¤ÀÀÎļþÃûÔ½½ç=Vorschau-Dateiname verlaesst das temporaere Verzeichnis +Îļþ½Ï´ó»ò²»Ö§³ÖÔ¤ÀÀ=Datei ist zu gross oder kann nicht angezeigt werden +Ô¤ÀÀÎļþУÑéʧ°Ü=Vorschau-Datei konnte nicht verifiziert werden +ÎļþÔÚ´«Êä¹ý³ÌÖз¢Éú±ä»¯£¬ÇëÖØÊÔ=Datei wurde waehrend der Uebertragung geaendert, bitte erneut versuchen +Ô¤ÀÀ´«ÊäÍ£ÖÍ£¬ÒÑÈ¡Ïû=Vorschau-Uebertragung stockte und wurde abgebrochen +Ô¤ÀÀ´«Ê䳬ʱ£¬ÒÑÈ¡Ïû=Vorschau-Uebertragung ist abgelaufen und wurde abgebrochen +ÎÞ·¨Ð´ÈëÔ¤ÀÀ»º´æÎļþ=Vorschau-Cache-Datei konnte nicht geschrieben werden +ÎÞ·¨´ò¿ªÎļþ£º%s£¨Îļþ²»´æÔÚ£©=Datei kann nicht geoeffnet werden: %s (nicht gefunden) +Ô¶³ÌÎļþ¿ÉÄÜÖ´ÐдúÂ룬ȷ¶¨Òª´ò¿ªÂ𣿣¨%s£¬%llu ×Ö½Ú£¬SHA-256 %s£©=Die entfernte Datei kann Code ausfuehren. Trotzdem oeffnen? (%s, %llu Bytes, SHA-256 %s) +°²È«È·ÈÏ=Sicherheitsbestaetigung +ÎÞ·¨´ò¿ªÎļþ£º%s£¨¿ÉÄÜûÓйØÁª³ÌÐò£©=Datei kann nicht geoeffnet werden: %s (kein zugeordnetes Programm) +¿Í»§¶Ë»ò V2 ¿ª¹Ø²»Ö§³ÖÎļþÔ¤ÀÀ£¨²ÎÊý ¡ú Îļþ´«Êä V2£©=Dieser Client oder der V2-Schalter unterstuetzt keine Vorschau (Einstellungen -> Dateiuebertragung V2) +ÎÞ·¨»ñÈ¡ÎļþÐÅÏ¢£¬ÇëË¢ÐÂĿ¼ºóÖØÊÔ=Dateiinformationen nicht verfuegbar; Verzeichnis aktualisieren und erneut versuchen +Îļþ½Ï´ó£¬²»Ö§³ÖÔ¤ÀÀ£º%s£¨%llu MB£¬ÉÏÏÞ %u MB£©=Datei zu gross fuer die Vorschau: %s (%llu MB, Grenze %u MB) +ÕýÔÚÔ¤ÀÀ %s ...=Vorschau von %s ... diff --git a/server/2015Remote/lang/en_US.ini b/server/2015Remote/lang/en_US.ini index 88698d8..fe2ef51 100644 --- a/server/2015Remote/lang/en_US.ini +++ b/server/2015Remote/lang/en_US.ini @@ -2363,3 +2363,21 @@ MCP \nÊ£ÓàÌìÊý°üº¬µ½ÆÚµ±Ì죻ÒѹýÆÚʱÖ÷¿Ø¹¦ÄÜ¿ÉÄÜÊÜÏÞ¡£=\nRemaining days include the expiry day; some features may be restricted after expiry. ÖØÖÃ=Reset ÒÑÇå¿ÕÓïÑÔ°üĿ¼ÉèÖã¬Òѻָ´ÄÚÖÃÓïÑÔ£¬ÖØÆô³ÌÐòºóÉúЧ¡£=Language pack folder setting cleared; built-in language restored. Restart the program to apply. +ÎÞ·¨´´½¨Ô¤ÀÀ»º´æÄ¿Â¼=Failed to create the preview cache directory +ÎÞ·¨Éú³ÉÔ¤ÀÀÇëÇó ID=Failed to create a preview request ID +ÕýÔÚÔ¤ÀÀÁíÒ»¸öÎļþ£¬ÇëÉÔºò=Another preview is in progress, please wait +Ô¤ÀÀÎļþÃûÔ½½ç=Preview filename escapes the temporary directory +Îļþ½Ï´ó»ò²»Ö§³ÖÔ¤ÀÀ=File is too large or cannot be previewed +Ô¤ÀÀÎļþУÑéʧ°Ü=Preview file verification failed +ÎļþÔÚ´«Êä¹ý³ÌÖз¢Éú±ä»¯£¬ÇëÖØÊÔ=File changed during transfer, please retry +Ô¤ÀÀ´«ÊäÍ£ÖÍ£¬ÒÑÈ¡Ïû=Preview transfer stalled and was cancelled +Ô¤ÀÀ´«Ê䳬ʱ£¬ÒÑÈ¡Ïû=Preview transfer timed out and was cancelled +ÎÞ·¨Ð´ÈëÔ¤ÀÀ»º´æÎļþ=Failed to write the preview cache file +ÎÞ·¨´ò¿ªÎļþ£º%s£¨Îļþ²»´æÔÚ£©=Cannot open file: %s (file not found) +Ô¶³ÌÎļþ¿ÉÄÜÖ´ÐдúÂ룬ȷ¶¨Òª´ò¿ªÂ𣿣¨%s£¬%llu ×Ö½Ú£¬SHA-256 %s£©=The remote file may execute code. Open it anyway? (%s, %llu bytes, SHA-256 %s) +°²È«È·ÈÏ=Security confirmation +ÎÞ·¨´ò¿ªÎļþ£º%s£¨¿ÉÄÜûÓйØÁª³ÌÐò£©=Cannot open file: %s (no associated program) +¿Í»§¶Ë»ò V2 ¿ª¹Ø²»Ö§³ÖÎļþÔ¤ÀÀ£¨²ÎÊý ¡ú Îļþ´«Êä V2£©=This client or the V2 switch does not support preview (Settings -> File Transfer V2) +ÎÞ·¨»ñÈ¡ÎļþÐÅÏ¢£¬ÇëË¢ÐÂĿ¼ºóÖØÊÔ=Cannot get file information; refresh the directory and retry +Îļþ½Ï´ó£¬²»Ö§³ÖÔ¤ÀÀ£º%s£¨%llu MB£¬ÉÏÏÞ %u MB£©=File too large to preview: %s (%llu MB, limit %u MB) +ÕýÔÚÔ¤ÀÀ %s ...=Previewing %s ... diff --git a/server/2015Remote/lang/zh_TW.ini b/server/2015Remote/lang/zh_TW.ini index 3c2e062..7db9890 100644 --- a/server/2015Remote/lang/zh_TW.ini +++ b/server/2015Remote/lang/zh_TW.ini @@ -2356,3 +2356,21 @@ MCP \nÊ£ÓàÌìÊý°üº¬µ½ÆÚµ±Ì죻ÒѹýÆÚʱÖ÷¿Ø¹¦ÄÜ¿ÉÄÜÊÜÏÞ¡£=\nÊ£ðNÌ씵°üº¬µ½ÆÚ®”Ì죻ÒÑß^ÆÚ•rÖ÷¿Ø¹¦ÄÜ¿ÉÄÜÊÜÏÞ¡£ ÖØÖÃ=ÖØÔO ÒÑÇå¿ÕÓïÑÔ°üĿ¼ÉèÖã¬Òѻָ´ÄÚÖÃÓïÑÔ£¬ÖØÆô³ÌÐòºóÉúЧ¡£=ÒÑÇå¿ÕÕZÑÔ°üÄ¿ä›ÔO¶¨£¬ÒÑ»Ö�̓Ƚ¨ÕZÑÔ£¬ÖØÐ†¢„Ó³ÌʽááÉúЧ¡£ +ÎÞ·¨´´½¨Ô¤ÀÀ»º´æÄ¿Â¼=Ÿo·¨½¨Á¢îAÓ[¿ìÈ¡Ä¿ä› +ÎÞ·¨Éú³ÉÔ¤ÀÀÇëÇó ID=Ÿo·¨®aÉúîAÓ[ÕˆÇó ID +ÕýÔÚÔ¤ÀÀÁíÒ»¸öÎļþ£¬ÇëÉÔºò=ÕýÔÚîAÓ[ÁíÒ»‚€™n°¸£¬ÕˆÉÔºò +Ô¤ÀÀÎļþÃûÔ½½ç=îAÓ[™nÃûÔ½½ç +Îļþ½Ï´ó»ò²»Ö§³ÖÔ¤ÀÀ=™n°¸ß^´ó»ò²»Ö§Ô®îAÓ[ +Ô¤ÀÀÎļþУÑéʧ°Ü=îAÓ[™n°¸Ð£òžÊ§”¡ +ÎļþÔÚ´«Êä¹ý³ÌÖз¢Éú±ä»¯£¬ÇëÖØÊÔ=™n°¸ÔÚ‚÷Ý”ß^³ÌÖаlÉú׃»¯£¬ÕˆÖØÔ‡ +Ô¤ÀÀ´«ÊäÍ£ÖÍ£¬ÒÑÈ¡Ïû=îAÓ[‚÷ݔͣœþ£¬ÒÑÈ¡Ïû +Ô¤ÀÀ´«Ê䳬ʱ£¬ÒÑÈ¡Ïû=îAÓ[‚÷Ý”Óâ•r£¬ÒÑÈ¡Ïû +ÎÞ·¨Ð´ÈëÔ¤ÀÀ»º´æÎļþ=Ÿo·¨Œ‘ÈëîAÓ[¿ìÈ¡™n°¸ +ÎÞ·¨´ò¿ªÎļþ£º%s£¨Îļþ²»´æÔÚ£©=Ÿo·¨é_†¢™n°¸£º%s£¨™n°¸²»´æÔÚ£© +Ô¶³ÌÎļþ¿ÉÄÜÖ´ÐдúÂ룬ȷ¶¨Òª´ò¿ªÂ𣿣¨%s£¬%llu ×Ö½Ú£¬SHA-256 %s£©=ßh¶Ë™n°¸¿ÉÄ܈ÌÐдú´a£¬´_¶¨Òªé_†¢†á£¿£¨%s£¬%llu λԪ½M£¬SHA-256 %s£© +°²È«È·ÈÏ=°²È«´_ÕJ +ÎÞ·¨´ò¿ªÎļþ£º%s£¨¿ÉÄÜûÓйØÁª³ÌÐò£©=Ÿo·¨é_†¢™n°¸£º%s£¨¿ÉÄÜ›]ÓÐêP“³Ìʽ£© +¿Í»§¶Ë»ò V2 ¿ª¹Ø²»Ö§³ÖÎļþÔ¤ÀÀ£¨²ÎÊý ¡ú Îļþ´«Êä V2£©=´Ë¿Í‘ô¶Ë»ò V2 é_êP²»Ö§Ô®™n°¸îAÓ[£¨…¢”µ ¡ú ™n°¸‚÷Ý” V2£© +ÎÞ·¨»ñÈ¡ÎļþÐÅÏ¢£¬ÇëË¢ÐÂĿ¼ºóÖØÊÔ=Ÿo·¨È¡µÃ™n°¸ÙYÓ�£¬ÕˆÖØÐÂÕûÀíÄ¿ä›ááÖØÔ‡ +Îļþ½Ï´ó£¬²»Ö§³ÖÔ¤ÀÀ£º%s£¨%llu MB£¬ÉÏÏÞ %u MB£©=™n°¸ß^´ó£¬²»Ö§Ô®îAÓ[£º%s£¨%llu MB£¬ÉÏÏÞ %u MB£© +ÕýÔÚÔ¤ÀÀ %s ...=ÕýÔÚîAÓ[ %s ...