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
This commit was merged in pull request #9.
This commit is contained in:
yuanyuanxianganddeepseek-flash committed 2026-11-24 10:33:42 +01:00
1 parent 0e20e0bbdb
commit e6a3255a2b
13 files changed
+74 -17

No files matched your search

Binary file not shown.
+36 -4
View File
@@ -826,6 +826,8 @@ CMy2015RemoteDlg::CMy2015RemoteDlg(CWnd* pParent): CDialogLangEx(CMy2015RemoteDl
m_bmOnline[74].LoadBitmap(IDB_BITMAP_DISCLAIMER); // 其他→免责声明
m_bmOnline[75].LoadBitmap(IDB_BITMAP_COPYNAME); // 右键→复制名称
m_bmOnline[76].LoadBitmap(IDB_BITMAP_RUN_TEST); // 高级→运行测试程序
m_bmCompressZstd.LoadBitmap(IDB_BITMAP_COMPRESS_ZSTD); // 线缆压缩:ZSTD
m_bmCompressZlib.LoadBitmap(IDB_BITMAP_COMPRESS_ZLIB); // 线缆压缩:ZLIB
for (int i = 0; i < PAYLOAD_MAXTYPE; i++) {
m_ServerDLL[i] = nullptr;
m_ServerBin[i] = nullptr;
@@ -4984,9 +4986,38 @@ void CMy2015RemoteDlg::OnNMRClickOnline(NMHDR *pNMHDR, LRESULT *pResult)
// 线缆压缩切换:放在实验功能末尾。仅当该组仍有可见项时追加——被功能位整组
// 隐藏时既不泄露,也不影响下面「空组摘除」的逻辑。
if (!IsPopupEmptyOfItems(pExperimentMenu)) {
// 置灰规则:选中的主机全是 zstd → ZSTD 置灰;全是 zlib → ZLIB 置灰;
// 混选时两个都可用;有老客户端不支持切换时两个都置灰。
int sel = 0, zstdN = 0, zlibN = 0, unsupported = 0;
EnterCriticalSection(&m_cs);
POSITION modePos = m_CList_Online.GetFirstSelectedItemPosition();
while (modePos) {
context* c = GetContextByListIndex(m_CList_Online.GetNextSelectedItem(modePos));
if (!c || !c->IsLogin()) continue;
++sel;
if (!c->SupportsCompressSwitch()) { ++unsupported; continue; }
const int m = c->GetCompressMethod();
if (m == COMPRESS_ZSTD) ++zstdN;
else if (m == COMPRESS_ZLIB) ++zlibN;
}
LeaveCriticalSection(&m_cs);
UINT zstdFlags = MF_STRING, zlibFlags = MF_STRING;
if (sel > 0) {
if (unsupported > 0) {
zstdFlags |= MF_GRAYED;
zlibFlags |= MF_GRAYED;
} else {
if (zstdN == sel) zstdFlags |= MF_GRAYED; // 已经是 zstd
if (zlibN == sel) zlibFlags |= MF_GRAYED; // 已经是 zlib
}
}
pExperimentMenu->AppendMenu(MF_SEPARATOR);
pExperimentMenu->AppendMenuL(MF_STRING, ID_EXPERIMENT_COMPRESS_ZSTD, "线缆压缩:ZSTD");
pExperimentMenu->AppendMenuL(MF_STRING, ID_EXPERIMENT_COMPRESS_ZLIB, "线缆压缩:ZLIB");
pExperimentMenu->AppendMenuL(zstdFlags, ID_EXPERIMENT_COMPRESS_ZSTD, "线缆压缩:ZSTD");
pExperimentMenu->AppendMenuL(zlibFlags, ID_EXPERIMENT_COMPRESS_ZLIB, "线缆压缩:ZLIB");
pExperimentMenu->SetMenuItemBitmaps(ID_EXPERIMENT_COMPRESS_ZSTD, MF_BYCOMMAND,
&m_bmCompressZstd, &m_bmCompressZstd);
pExperimentMenu->SetMenuItemBitmaps(ID_EXPERIMENT_COMPRESS_ZLIB, MF_BYCOMMAND,
&m_bmCompressZlib, &m_bmCompressZlib);
}
for (UINT i = 0; i < SubMenu->GetMenuItemCount(); i++) {
if (SubMenu->GetSubMenu(i) == pExperimentMenu) {
@@ -5357,8 +5388,9 @@ VOID CMy2015RemoteDlg::SwitchSelectedCompression(const char* mode)
return;
}
// 载荷 [cmd]["zstd"|"zlib"]。客户端写入 settings\compress 后重启 StartClient 线程,
// 新连接按新模式重连;服务端按每个连接的首包自动识别算法,不影响其它主机。
// 载荷 [cmd]["zstd"|"zlib"]。客户端写入 settings\compress 后断开当前连接,
// 原地切换压缩模式并由 StartClient 重连循环用新模式建链;服务端按每个连接的
// 首包自动识别算法,不影响其它主机。
std::string pkt(1, (char)COMMAND_SET_COMPRESS);
pkt += mode;
Mprintf("[compress-switch] send %s to %d host(s)\n", mode, selected);
+2
View File
@@ -506,6 +506,8 @@ public:
void RecordDllRequest(const std::string& ip);
CMenu m_MainMenu;
CBitmap m_bmOnline[77];
CBitmap m_bmCompressZstd; // 实验功能→线缆压缩:ZSTD
CBitmap m_bmCompressZlib; // 实验功能→线缆压缩:ZLIB
uint64_t m_superID;
std::map<HWND, CDialogBase *> m_RemoteWnds;
FileTransformCmd m_CmdList;
+4
View File
@@ -98,6 +98,7 @@ RTT=RTT
生成服务端=Server erstellen
即时消息=Nachricht
虚拟屏幕=Virtueller Bildschirm
实验功能=Experimentelle Funktionen
隐私屏幕=Datenschutz-Bildschirm
代理服务=Proxy-Dienst
注入设置=Injektionskonfiguration
@@ -2172,6 +2173,9 @@ TLS
证书/私钥加载失败,加密功能未生效。请检查文件路径与格式(证书 PEM、私钥 PKCS#8)。=Zertifikat/privater Schluessel konnte nicht geladen werden; Verschluesselung ist inaktiv. Bitte Pfad und Format pruefen (PEM-Zertifikat, PKCS#8-Schluessel).
TLS传输=TLS-Transport
取消TLS=TLS deaktivieren
线缆压缩:ZSTD=Leitungskompression: ZSTD
线缆压缩:ZLIB=Leitungskompression: ZLIB
选中的主机里有客户端版本不支持线缆压缩切换(需要新版 Windows 客户端)=Ausgewaehlte Hosts unterstuetzen das Umschalten der Leitungskompression nicht (ein neuerer Windows-Client ist erforderlich)
确定对选中主机启用 TLS 传输吗?\n(客户端立即生效并断线重连,正在进行的远程会话会中断)=TLS-Transport fuer die ausgewaehlten Hosts aktivieren?\n(Clients wirken sofort und verbinden sich neu; laufende Sitzungen werden unterbrochen)
确定取消选中主机的 TLS 传输吗?\n(客户端立即生效并断线重连,正在进行的远程会话会中断)=TLS-Transport fuer die ausgewaehlten Hosts deaktivieren?\n(Clients wirken sofort und verbinden sich neu; laufende Sitzungen werden unterbrochen)
服务端未启用 TLS 证书,无法切换客户端 TLS 传输=Server-TLS-Zertifikat ist nicht aktiviert; TLS-Transport der Clients kann nicht umgeschaltet werden
+3
View File
@@ -2187,6 +2187,9 @@ TLS
证书/私钥加载失败,加密功能未生效。请检查文件路径与格式(证书 PEM、私钥 PKCS#8)。=Failed to load certificate/private key; encryption is not active. Check the file path and format (PEM certificate, PKCS#8 private key).
TLS传输=TLS Transport
取消TLS=Disable TLS
线缆压缩:ZSTD=Wire compression: ZSTD
线缆压缩:ZLIB=Wire compression: ZLIB
选中的主机里有客户端版本不支持线缆压缩切换(需要新版 Windows 客户端)=Some selected hosts do not support switching wire compression (a newer Windows client is required)
确定对选中主机启用 TLS 传输吗?\n(客户端立即生效并断线重连,正在进行的远程会话会中断)=Enable TLS transport for the selected host?\n(Clients apply it immediately and reconnect; any active remote session is interrupted)
确定取消选中主机的 TLS 传输吗?\n(客户端立即生效并断线重连,正在进行的远程会话会中断)=Disable TLS transport for the selected host?\n(Clients apply it immediately and reconnect; any active remote session is interrupted)
服务端未启用 TLS 证书,无法切换客户端 TLS 传输=Server TLS certificate is not enabled; cannot toggle client TLS transport
+3
View File
@@ -2180,6 +2180,9 @@ TLS
证书/私钥加载失败,加密功能未生效。请检查文件路径与格式(证书 PEM、私钥 PKCS#8)。=憑證/私鑰載入失敗,加密功能未生效。請檢查檔案路徑與格式(憑證 PEM、私鑰 PKCS#8)。
TLS传输=TLS 傳輸
取消TLS=停用 TLS
线缆压缩:ZSTD=線纜壓縮:ZSTD
线缆压缩:ZLIB=線纜壓縮:ZLIB
选中的主机里有客户端版本不支持线缆压缩切换(需要新版 Windows 客户端)=選取的主機中有用戶端版本不支援線纜壓縮切換(需要新版 Windows 用戶端)
确定对选中主机启用 TLS 传输吗?\n(客户端立即生效并断线重连,正在进行的远程会话会中断)=確定對選取主機啟用 TLS 傳輸嗎?\n(用戶端立即生效並斷線重連,正在進行的遠端工作階段會中斷)
确定取消选中主机的 TLS 传输吗?\n(客户端立即生效并断线重连,正在进行的远程会话会中断)=確定取消選取主機的 TLS 傳輸嗎?\n(用戶端立即生效並斷線重連,正在進行的遠端工作階段會中斷)
服务端未启用 TLS 证书,无法切换客户端 TLS 传输=伺服器未啟用 TLS 憑證,無法切換用戶端 TLS 傳輸
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

+3 -1
View File
@@ -299,6 +299,8 @@
#define IDB_BITMAP_DISCLAIMER 415
#define IDB_BITMAP_COPYNAME 416
#define IDB_BITMAP_RUN_TEST 417
#define IDB_BITMAP_COMPRESS_ZSTD 418
#define IDB_BITMAP_COMPRESS_ZLIB 419
#define IDC_MESSAGE 1000
#define IDC_ONLINE 1001
#define IDC_STATIC_TIPS 1002
@@ -1133,7 +1135,7 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 418
#define _APS_NEXT_RESOURCE_VALUE 420
#define _APS_NEXT_COMMAND_VALUE 33109
#define _APS_NEXT_CONTROL_VALUE 2621
#define _APS_NEXT_SYMED_VALUE 105