fix(share): carry the transport in the share and assign payloads
The share payload was host:port:shine and carried no transport at all, so a
shared client fell back to its baked-in protoType. Share instances also skip
ApplyProtoSwitch (ClientDll.cpp:810), so a client upgraded to WSS was shared
to a TLS front end as raw TCP and looped on HTTP/1.1 400.
Extend both payloads with an optional trailing transport field:
share : host:port:shine[:transport]
assign : host:port:days:shine[:transport]
The field is omitted when the source protocol is not TCP/WS/WSS, so HTTP/UDP/
KCP hosts keep their previous behaviour instead of being silently downgraded
to plain TCP.
- server: add SelectedShareTransport(), share it between OnOnlineShare and
OnOnlineAssignTo, and accept a tcp:// ws:// wss:// prefix in the address.
- client: parse the field on both paths and persist the assigned value to
settings/master_transport, clearing it when the field is absent.
- share_list: dedup on host:port instead of the whole record, so re-sharing
a host with a different transport replaces the stale entry.
- assign: guard bToken[_MAX_PATH] against the longer payload.
- lang: translate the reworded prompt and the three new messages in en_US,
zh_TW and de_DE.
Transport is pinned at share time and does not follow a later protocol switch
on the master link; the m_bShared gate stays as-is on purpose.
This commit is contained in:
1 parent
951b4072e5
commit
454d25d37f
10 files changed
+266
-22
No files matched your search
+20
-3
@@ -66,7 +66,7 @@ BOOL IsClientAppRunning(void* thisApp)
|
||||
return S_CLIENT_NORMAL == This->g_bExit;
|
||||
}
|
||||
|
||||
ClientApp* NewClientStartArg(const char* remoteAddr, IsRunning run, BOOL shared, int headerEnc)
|
||||
ClientApp* NewClientStartArg(const char* remoteAddr, IsRunning run, BOOL shared, int headerEnc, int protoType)
|
||||
{
|
||||
auto v = StringToVector(remoteAddr, ':', 2);
|
||||
if (v[0].empty() || v[1].empty())
|
||||
@@ -75,6 +75,11 @@ ClientApp* NewClientStartArg(const char* remoteAddr, IsRunning run, BOOL shared,
|
||||
a->g_Connection->SetServer(v[0].c_str(), atoi(v[1].c_str()));
|
||||
if (headerEnc == PROTOCOL_SHINE || headerEnc == PROTOCOL_HELL)
|
||||
a->g_Connection->iHeaderEnc = headerEnc;
|
||||
// 传输方式只在本实例的那份 CONNECT_ADDRESS 上改(ClientApp 构造时已深拷贝),
|
||||
// 不影响主实例。分享实例不走 ApplyProtoSwitch(入口由分享方控制),传输就靠这里
|
||||
// 显式给出;-1 表示沿用烘焙值,与改造前一致。
|
||||
if (protoType == PROTO_TCP || protoType == PROTO_WS || protoType == PROTO_WSS)
|
||||
a->g_Connection->protoType = (char)protoType;
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -739,6 +744,12 @@ DWORD WINAPI StartClient(LPVOID lParam)
|
||||
auto saved_proto = cfg.GetStr("settings", "master_proto");
|
||||
if (saved_proto == "0" || saved_proto == "1")
|
||||
settings.iHeaderEnc = atoi(saved_proto.c_str());
|
||||
// 转移时一并下发的传输方式(新服务端才有;老记录没有这个键)。没有记录就
|
||||
// 沿用烘焙值——这里不能写死 PROTO_TCP,否则老转移记录会把原本 WSS 的
|
||||
// 客户端改回直连。
|
||||
auto saved_transport = cfg.GetStr("settings", "master_transport");
|
||||
if (saved_transport == "0" || saved_transport == "5" || saved_transport == "6")
|
||||
settings.protoType = (char)atoi(saved_transport.c_str());
|
||||
Mprintf("[StartClient] Client is assigned to %s:%d- %ds left.\n", saved_ip.c_str(), saved_port,
|
||||
int(valid_to-now));
|
||||
}
|
||||
@@ -766,9 +777,15 @@ DWORD WINAPI StartClient(LPVOID lParam)
|
||||
auto a = cfg.GetStr("settings", "share_list");
|
||||
auto shareList = a.empty() ? std::vector<std::string>{} : StringToVector(a, '|');
|
||||
for (int i = 0; i < shareList.size(); ++i) {
|
||||
auto v = StringToVector(shareList[i], ':', 3);
|
||||
auto v = StringToVector(shareList[i], ':', 4);
|
||||
int proto = (v.size() >= 3 && (v[2] == "0" || v[2] == "1")) ? atoi(v[2].c_str()) : -1;
|
||||
auto a = NewClientStartArg(shareList[i].c_str(), IsSharedRunning, TRUE, proto);
|
||||
// 第 4 段是分享链路的传输方式(新服务端才下发;老记录没有这一段,按烘焙值走)。
|
||||
// 同样只认合法值:atoi 对非法串返回 0(=PROTO_TCP),会把 WSS 静默降级成直连。
|
||||
int transport = (v.size() >= 4 && (v[3] == std::to_string(PROTO_TCP)
|
||||
|| v[3] == std::to_string(PROTO_WS)
|
||||
|| v[3] == std::to_string(PROTO_WSS)))
|
||||
? atoi(v[3].c_str()) : -1;
|
||||
auto a = NewClientStartArg(shareList[i].c_str(), IsSharedRunning, TRUE, proto, transport);
|
||||
if (nullptr != a) CloseHandle(__CreateThread(0, 0, StartClientApp, a, 0, 0));
|
||||
Mprintf("[StartClient] Client is shared to %s.\n", shareList[i].c_str());
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user