Feature: switch hosts to the experimental UDP and KCP transports

The switch only offered direct TCP, WS and WSS; UDP and KCP are now
experimental menu entries, and the radio item follows the real transport.

The server maps ghost/UDPOption to real listeners (a "UDP;KCP" setup
used to collapse to one UDP port). A switch sends the master address and
that transport's port, refused behind an upper-level FRP. The client
persists the override, recreates its connection object when the transport
changes, and disconnects an unacknowledged switch after 60 s so the 300 s
revert can run. TCP/WS/WSS behaviour is unchanged.

Reconnecting a KCP client reused the same object: a fresh std::thread
over the old one aborted the process and leaked the ikcp session;
ConnectServer now joins the update thread and releases the session first,
and the UDP one also clears the stale login-ack flag. KCP contexts no
longer touch the shared listener socket: CancelIO is a no-op, Disconnect
looks up by IP:port and defers deletion behind the receive thread's
reference, COMMAND_BYE leaves the socket alone, and Disconnect stays
silent like UDP's. Oversized messages are delivered in chunks.

A datagram host has no disconnect event, so a new login for the same id
was parked as standby for up to 120 s while the client gave up after
60 s; a UDP/KCP or different-transport login now replaces it immediately.

The new labels, prompts and settings hint are translated in the
en_US/de_DE/zh_TW packs; UDPOption also accepts 0/1 in port order.
Verified: Debug build; switch directions plus KCP delete/reconnect/file-transfer tested.

Co-Authored-By: deepseek-flash
This commit is contained in:
yuanyuanxianganddeepseek-flash committed 2026-11-29 20:34:08 +01:00
1 parent 914553ab4e
commit dfac2b5179
21 files changed
+534 -91

No files matched your search

+7 -1
View File
@@ -605,11 +605,17 @@ public:
afx_msg void OnExperimentCompressZstd();
afx_msg void OnExperimentCompressZlib();
VOID SwitchSelectedCompression(const char* mode);
// 协议切换(在线列表右键菜单,与「实验功能」平级):直连 TCP / WS / WSS
// 协议切换(在线列表右键菜单,与「实验功能」平级):直连 TCP / WS / WSS / UDP / KCP
afx_msg void OnProtoSwitchTcp();
afx_msg void OnProtoSwitchWs();
afx_msg void OnProtoSwitchWss();
afx_msg void OnProtoSwitchUdp();
afx_msg void OnProtoSwitchKcp();
VOID SwitchSelectedProtocol(UINT nID);
// 实验传输 UDP/KCP 各自监听的端口(来自 settings 的 ghost / UDPOption 平行列表;
// 0 = 主控没有配置该传输,菜单置灰)
int m_udpSwitchPort = 0;
int m_kcpSwitchPort = 0;
// 选中主机当前的真实传输(PROTO_TCP / PROTO_WS / PROTO_WSS)。多选取第一个可识别的;
// 一个都没有(HTTP 伪装 / UDP / KCP / 没选中主机)返回 -1。分享与转移都用它给新建
// 链路定传输:-1 表示「不下发」,让对端沿用出包时烘焙的值。