Skip to content

Commit 36573b3

Browse files
authored
Merge pull request #44 from balthild/bugfix/tuic-sni
2 parents 3f50ea3 + 6dffc43 commit 36573b3

1 file changed

Lines changed: 26 additions & 25 deletions

File tree

src/parser/subparser.cpp

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ void hysteriaConstruct(
171171
if (!up.empty())
172172
{
173173
if (up.length() > 4 && up.find("bps") == up.length() - 3)
174-
174+
175175
node.Up = up;
176176
else if (to_int(up))
177177
{
@@ -212,13 +212,13 @@ void hysteriaConstruct(
212212
}
213213

214214
void hysteria2Construct(
215-
Proxy &node,
215+
Proxy &node,
216216
const std::string &group,
217217
const std::string &remarks,
218-
const std::string &server,
218+
const std::string &server,
219219
const std::string &port,
220220
const std::string &ports,
221-
const std::string &up,
221+
const std::string &up,
222222
const std::string &down,
223223
const std::string &password,
224224
const std::string &obfs,
@@ -229,10 +229,10 @@ void hysteria2Construct(
229229
const std::string &ca,
230230
const std::string &ca_str,
231231
const std::string &cwnd,
232-
const std::string &hop_interval,
232+
const std::string &hop_interval,
233233
tribool udp,
234-
tribool tfo,
235-
tribool scv,
234+
tribool tfo,
235+
tribool scv,
236236
const std::string &underlying_proxy
237237
) {
238238
commonConstruct(node, ProxyType::Hysteria2, group, remarks, server, port, udp, tfo, scv, tribool(), underlying_proxy);
@@ -1259,7 +1259,7 @@ void explodeClash(Node yamlnode, std::vector<Proxy> &nodes)
12591259
singleproxy["name"] >>= ps;
12601260
singleproxy["server"] >>= server;
12611261
singleproxy["port"] >>= port;
1262-
1262+
12631263
underlying_proxy.clear();
12641264
// Use 'dialer-proxy' or 'underlying-proxy' to set underlying proxy
12651265
if (singleproxy["dialer-proxy"].IsDefined())
@@ -1272,7 +1272,7 @@ void explodeClash(Node yamlnode, std::vector<Proxy> &nodes)
12721272
udp = safe_as<std::string>(singleproxy["udp"]);
12731273
tfo = safe_as<std::string>(singleproxy["fast-open"]);
12741274
scv = safe_as<std::string>(singleproxy["skip-cert-verify"]);
1275-
1275+
12761276
// Read common new parameters
12771277
singleproxy["ip-version"] >>= ip_version;
12781278
singleproxy["client-fingerprint"] >>= client_fingerprint;
@@ -1283,7 +1283,7 @@ void explodeClash(Node yamlnode, std::vector<Proxy> &nodes)
12831283
ech_enable = safe_as<std::string>(singleproxy["ech-opts"]["enable"]);
12841284
singleproxy["ech-opts"]["config"] >>= ech_config;
12851285
}
1286-
1286+
12871287
switch(hash_(proxytype))
12881288
{
12891289
case "vmess"_hash:
@@ -1329,7 +1329,7 @@ void explodeClash(Node yamlnode, std::vector<Proxy> &nodes)
13291329
tls = safe_as<std::string>(singleproxy["tls"]) == "true" ? "tls" : "";
13301330

13311331
vmessConstruct(node, group, ps, server, port, "", id, aid, net, cipher, path, host, edge, tls, sni, udp, tfo, scv, tribool(), underlying_proxy);
1332-
1332+
13331333
// Assign new parameters to node for Vmess
13341334
node.IpVersion = ip_version;
13351335
node.ClientFingerprint = client_fingerprint;
@@ -1407,7 +1407,7 @@ void explodeClash(Node yamlnode, std::vector<Proxy> &nodes)
14071407
break;
14081408
}
14091409
tls = safe_as<std::string>(singleproxy["tls"]) == "true" ? "tls" : "";
1410-
1410+
14111411
vlessConstruct(node, group, ps, server, port, uuid, sni, alpn, type, net, mode, host, path, fingerprint, flow, xtls, public_key, short_id, client_fingerprint, udp, tfo, scv, underlying_proxy);
14121412
node.TLSSecure = tls == "tls";
14131413
// Assign new parameters to node for VLESS
@@ -1427,7 +1427,7 @@ void explodeClash(Node yamlnode, std::vector<Proxy> &nodes)
14271427
}
14281428
node.XUDP = safe_as<std::string>(singleproxy["xudp"]);
14291429
node.PacketAddr = safe_as<std::string>(singleproxy["packet-addr"]);
1430-
1430+
14311431
// Add WebSocket enhanced parameters support for VLESS
14321432
if(net == "ws")
14331433
{
@@ -1450,12 +1450,12 @@ void explodeClash(Node yamlnode, std::vector<Proxy> &nodes)
14501450

14511451
singleproxy["cipher"] >>= cipher;
14521452
singleproxy["password"] >>= password;
1453-
1453+
14541454
// Shadowsocks UDP-over-TCP options - only assign if explicitly provided
14551455
node.UdpOverTcp = safe_as<std::string>(singleproxy["udp-over-tcp"]);
14561456
if(singleproxy["udp-over-tcp-version"].IsDefined())
14571457
node.UdpOverTcpVersion = to_int(safe_as<std::string>(singleproxy["udp-over-tcp-version"]));
1458-
1458+
14591459
// Read SMUX configuration for Shadowsocks
14601460
if(singleproxy["smux"].IsDefined())
14611461
{
@@ -1471,7 +1471,7 @@ void explodeClash(Node yamlnode, std::vector<Proxy> &nodes)
14711471
smux_statistic = safe_as<std::string>(singleproxy["smux"]["statistic"]);
14721472
smux_only_tcp = safe_as<std::string>(singleproxy["smux"]["only-tcp"]);
14731473
}
1474-
1474+
14751475
if(singleproxy["plugin"].IsDefined())
14761476
{
14771477
switch(hash_(safe_as<std::string>(singleproxy["plugin"])))
@@ -1536,7 +1536,7 @@ void explodeClash(Node yamlnode, std::vector<Proxy> &nodes)
15361536
}
15371537

15381538
ssConstruct(node, group, ps, server, port, password, cipher, plugin, pluginopts, udp, tfo, scv, tribool(), underlying_proxy);
1539-
1539+
15401540
// Assign new parameters to node
15411541
node.IpVersion = ip_version;
15421542
node.ClientFingerprint = client_fingerprint;
@@ -1588,7 +1588,7 @@ void explodeClash(Node yamlnode, std::vector<Proxy> &nodes)
15881588
singleproxy["tls"] >>= tls;
15891589

15901590
httpConstruct(node, group, ps, server, port, user, password, tls == "true", tfo, scv, tribool(), underlying_proxy);
1591-
1591+
15921592
// Assign new parameters to node for HTTP
15931593
node.IpVersion = ip_version;
15941594
node.ClientFingerprint = client_fingerprint;
@@ -1615,7 +1615,7 @@ void explodeClash(Node yamlnode, std::vector<Proxy> &nodes)
16151615
}
16161616

16171617
trojanConstruct(node, group, ps, server, port, password, net, host, path, true, udp, tfo, scv, tribool(), underlying_proxy);
1618-
1618+
16191619
// Assign new parameters to node for Trojan
16201620
node.IpVersion = ip_version;
16211621
node.ClientFingerprint = client_fingerprint;
@@ -1630,7 +1630,7 @@ void explodeClash(Node yamlnode, std::vector<Proxy> &nodes)
16301630
node.TrojanSsMethod = trojan_ss_method;
16311631
node.TrojanSsPassword = trojan_ss_password;
16321632
}
1633-
1633+
16341634
// Add WebSocket enhanced parameters support for Trojan
16351635
if(net == "ws")
16361636
{
@@ -1698,7 +1698,7 @@ void explodeClash(Node yamlnode, std::vector<Proxy> &nodes)
16981698
singleproxy["hop-interval"] >>= hop_interval;
16991699

17001700
hysteriaConstruct(node, group, ps, server, port, ports, protocol, obfs_protocol, up, up_speed, down, down_speed, auth, auth_str, obfs, sni, fingerprint, ca, ca_str, recv_window_conn, recv_window, disable_mtu_discovery, hop_interval, alpn, tfo, scv, underlying_proxy);
1701-
1701+
17021702
// Assign new parameters to node for Hysteria
17031703
node.IpVersion = ip_version;
17041704
node.ClientFingerprint = client_fingerprint;
@@ -1716,7 +1716,7 @@ void explodeClash(Node yamlnode, std::vector<Proxy> &nodes)
17161716
singleproxy["down"] >>= down;
17171717
singleproxy["password"] >>= password;
17181718
if (password.empty())
1719-
singleproxy["auth"] >>= password;
1719+
singleproxy["auth"] >>= password;
17201720
singleproxy["obfs"] >>= obfs;
17211721
singleproxy["obfs-password"] >>= obfs_password;
17221722
singleproxy["sni"] >>= sni;
@@ -1730,7 +1730,7 @@ void explodeClash(Node yamlnode, std::vector<Proxy> &nodes)
17301730
singleproxy["cwnd"] >>= cwnd;
17311731
singleproxy["hop-interval"] >>= hop_interval;
17321732
hysteria2Construct(node, group, ps, server, port, ports, up, down, password, obfs, obfs_password, sni, fingerprint, alpn, ca, ca_str, cwnd, hop_interval, udp, tfo, scv, underlying_proxy);
1733-
1733+
17341734
// Assign new parameters to node for Hysteria2
17351735
node.IpVersion = ip_version;
17361736
node.ClientFingerprint = client_fingerprint;
@@ -1767,9 +1767,10 @@ void explodeClash(Node yamlnode, std::vector<Proxy> &nodes)
17671767
singleproxy["congestion-controller"] >>= congestion_controller;
17681768
singleproxy["max-udp-relay-packet-size"] >>= max_udp_relay_packet_size;
17691769
singleproxy["max-open-streams"] >>= max_open_streams;
1770+
singleproxy["sni"] >>= sni;
17701771
singleproxy["fast-open"] >>= fast_open;
17711772
tuicConstruct(node, group, ps, server, port, uuid, password, ip, heartbeat_interval, alpn, disable_sni, reduce_rtt, request_timeout, udp_relay_mode, congestion_controller, max_udp_relay_packet_size, max_open_streams, sni, fast_open, tfo, scv, underlying_proxy);
1772-
1773+
17731774
// Assign new parameters to node for TUIC
17741775
node.IpVersion = ip_version;
17751776
node.ClientFingerprint = client_fingerprint;
@@ -1792,7 +1793,7 @@ void explodeClash(Node yamlnode, std::vector<Proxy> &nodes)
17921793
singleproxy["alpn"] >>= alpn;
17931794
singleproxy["fingerprint"] >>= fingerprint;
17941795
anytlsConstruct(node, group, ps, server, port, password, sni, alpn, fingerprint, idle_session_check_interval, idle_session_timeout, min_idle_session, tfo, scv, underlying_proxy);
1795-
1796+
17961797
// Assign new parameters to node for AnyTLS
17971798
node.IpVersion = ip_version;
17981799
node.ClientFingerprint = client_fingerprint;

0 commit comments

Comments
 (0)