Feature: Embed the server TLS certificate in delivered DLLs

Add a "高级 → DLL内嵌TLS证书" toggle (off by default, persisted as
[settings] EmbedTlsInDll). When it is on, ReadKernelDll patches the server's
current TLS anchor into the ServerDll and ShellCode payloads, so clients that
come online through the loaders start their own session over TLS without
waiting for an online push. The plaintext DLL loader in client/main.c is
untouched; only the DLL's fresh connection is protected. The write happens
after SetServer and before CalcMD5FromBytes, and the anchor records the host
part of the master address rather than "ip:port" because the client matches
the anchor against its configured address set. TinyRun has no anchor block and
keeps working as before.

Toggling the switch, and confirming the certificate dialog, rebuild the six
payloads in place, so no server restart is needed after a certificate change.
The payload pointers are replaced as a whole, and the network threads that read
them (SendServerDll and TOKEN_GETVERSION) now take a dedicated critical section
for the full duration of use.

COMMAND_UPDATE no longer clears the tls_disabled marker on the client. Now that
any delivered DLL may carry the anchor, "the payload has an anchor" no longer
means the operator opted this host into TLS, and clearing the marker would
silently flip a host that was explicitly set to plaintext onto TLS against a
plaintext path. Re-enabling TLS stays an explicit action through
COMMAND_TLS_ENABLE and COMMAND_SET_PROTO, which still clear the marker.

Menu and notice strings were added to en_US, zh_TW and de_DE, and the embedded
TLS design document records the new switch and the revised update semantics.

The new menu entry also takes a feature-limits slot so a subordinate master
can hide it like every other 高级 item (see 8807321):
HIDE_MENU_EMBED_TLS_ANCHOR in UIBranding.h, MF_EMBED_TLS_ANCHOR at bit 57
in FeatureFlags.h (the first free one after MF_FILE_SPEED), a row in the
主菜单 tab of CFeatureLimitsDlg, and the matching DeleteMenu on the 高级
menu. The entry still has no bitmap of its own, so it renders without an
icon next to its three siblings.

Co-Authored-By: deepseek-flash
This commit is contained in:
yuanyuanxianganddeepseek-flash committed 2026-11-02 18:30:37 +01:00
1 parent 8b92f32c47
commit c66f410831
12 files changed
+210 -45

No files matched your search

+9
View File
@@ -2128,6 +2128,15 @@ JPEG
强制断开=強制中斷
远程交谈=遠程交談
; ============================================
; Advanced -> DLL embeds TLS certificate (DLL內嵌TLS憑證)
; ============================================
DLL内嵌TLS证书=DLL 內嵌 TLS 憑證
服务端还没有可用的 TLS 证书,无法内嵌。\r\n请先在 TLS 证书配置里启用证书,再打开此开关。=伺服器尚無可用的 TLS 憑證,無法內嵌。\r\n請先在 TLS 憑證設定中啟用憑證,再開啟此開關。
已开启:此后经 MDLL/ShellCode 形式上线的客户端会自动启用 TLS。\r\n\r\n已上线的客户端不会自动变,需要重启(重新走一遍加载器)才会拿到带证书的 DLL。=已開啟:此後經 MDLL/ShellCode 形式上線的用戶端會自動啟用 TLS。\r\n\r\n已上線的用戶端不會自動改變,需要重新啟動(重新執行一次載入器)才會取得內嵌憑證的 DLL。
已关闭:此后下发的 DLL 不再内嵌证书。\r\n\r\n已经内嵌了证书的客户端不受影响。=已關閉:此後下發的 DLL 不再內嵌憑證。\r\n\r\n已內嵌憑證的用戶端不受影響。
重新生成内核载荷失败(资源缺失),仍沿用原来的 DLL。=重新產生核心負載失敗(資源缺失),仍沿用原本的 DLL。
; ===== TLS =====
TLS证书(&T)...=TLS 憑證(&T)...
TLS证书=TLS 憑證