Fix(client): rotate HELL header encoding across reconnects

A Release client drew one of the twelve HELL header encodings in the
constructor and kept it for life. The Go fallback server latches a type
from the first packet and only decodes None..V6, so every client that
drew V7..V10 could never log in to it — a third of them, at random, for
good.

The main connection now advances to the next type when it reconnects
after a connection that was never login-acked (CMD_MASTERSETTING), and
republishes the accepted type into CONNECT_ADDRESS::szFuture. A type that
did log in is kept, so a healthy client no longer churns through values
the fallback would reject. Sub-connections, including one-shot ones
(file/process/screen), inherit the published value at construction and
on every reconnect instead of rolling their own dice. Debug keeps its
None..V6-only range; the initial Release type now comes from
random_device rather than time() % N, which handed a whole batch started
in the same second the same value.

The slot sits at szFuture+16, after LOCAL_TEST_CLIENT_MAGIC, guarded by
static_asserts; it is memory-only and never persisted or sent. Swapping
the encoder is a single atomic function-pointer store, so the send and
receive threads see either the old or the new encoder and never a
dropped object.

Co-Authored-By: deepseek-flash
This commit is contained in:
yuanyuanxianganddeepseek-flash committed 2026-11-13 16:47:53 +01:00
1 parent a818ace83c
commit 9fadb58c76
5 files changed
+178 -10

No files matched your search

+3
View File
@@ -809,6 +809,9 @@ DWORD WINAPI StartClient(LPVOID lParam)
State& bExit(app.g_bExit);
IOCPClient *ClientObject = NewNetClient(&settings, bExit, pubIP);
if (nullptr == ClientObject) return -1;
// 主连接:登录被接受后发布头加密类型;上一条连接没被登录接受时,重连换下一种类型
// 轮转探测。其余 IOCPClient(文件/进程/屏幕等子连接)都跟随这里发布的值。
ClientObject->MarkMainLink();
CKernelManager* Manager = nullptr;
if (!app.m_bShared) {