@@ -903,7 +903,7 @@ void explodeNetch(std::string netch, bool ss_libev, bool ssr_libev, const std::s
903903 if (group.empty ())
904904 group = HTTP_DEFAULT_GROUP;
905905 node.group = group;
906- node.proxyStr = httpConstruct (group, remark, address, port, username, password, type == " HTTPS" , scv);
906+ node.proxyStr = httpConstruct (group, remark, address, port, username, password, type == " HTTPS" , tfo, scv);
907907 break ;
908908 case " Trojan" _hash:
909909 host = GetMember (json, " Host" );
@@ -1081,7 +1081,7 @@ void explodeClash(Node yamlnode, const std::string &custom_port, std::vector<nod
10811081 singleproxy[" tls" ] >>= tls;
10821082
10831083 node.linkType = SPEEDTEST_MESSAGE_FOUNDHTTP;
1084- node.proxyStr = httpConstruct (group, ps, server, port, user, password, tls == " true" , scv);
1084+ node.proxyStr = httpConstruct (group, ps, server, port, user, password, tls == " true" , tfo, scv);
10851085 break ;
10861086 case " trojan" _hash:
10871087 group = TROJAN_DEFAULT_GROUP;
@@ -1242,7 +1242,7 @@ bool explodeSurge(std::string surge, const std::string &custom_port, std::vector
12421242 for (auto &x : proxies)
12431243 {
12441244 std::string remarks, server, port, method, username, password; // common
1245- std::string plugin, pluginopts, pluginopts_mode, pluginopts_host = " cloudfront.net " , mod_url, mod_md5; // ss
1245+ std::string plugin, pluginopts, pluginopts_mode, pluginopts_host, mod_url, mod_md5; // ss
12461246 std::string id, net, tls, host, edge, path; // v2
12471247 std::string protocol, protoparam; // ssr
12481248 std::string itemName, itemVal, config;
@@ -1458,7 +1458,7 @@ bool explodeSurge(std::string surge, const std::string &custom_port, std::vector
14581458 default : continue ;
14591459 }
14601460 }
1461- node.proxyStr = httpConstruct (node.group , remarks, server, port, username, password, false , scv);
1461+ node.proxyStr = httpConstruct (node.group , remarks, server, port, username, password, false , tfo, scv);
14621462 break ;
14631463 case " trojan" _hash: // surge 4 style trojan proxy
14641464 node.linkType = SPEEDTEST_MESSAGE_FOUNDTROJAN;
@@ -1546,10 +1546,28 @@ bool explodeSurge(std::string surge, const std::string &custom_port, std::vector
15461546 case " ssr-protocol" _hash: protocol = itemVal; break ;
15471547 case " ssr-protocol-param" _hash: protoparam = itemVal; break ;
15481548 case " obfs" _hash:
1549- plugin = " simple-obfs" ;
1550- pluginopts_mode = itemVal;
1549+ {
1550+ switch (hash_ (itemVal))
1551+ {
1552+ case " http" _hash:
1553+ case " tls" _hash:
1554+ plugin = " simple-obfs" ;
1555+ pluginopts_mode = itemVal;
1556+ break ;
1557+ case " wss" _hash:
1558+ tls = " tls" ;
1559+ [[fallthrough]];
1560+ case " ws" _hash:
1561+ pluginopts_mode = " websocket" ;
1562+ plugin = " v2ray-plugin" ;
1563+ break ;
1564+ default :
1565+ pluginopts_mode = itemVal;
1566+ }
15511567 break ;
1568+ }
15521569 case " obfs-host" _hash: pluginopts_host = itemVal; break ;
1570+ case " obfs-uri" _hash: path = itemVal; break ;
15531571 case " udp-relay" _hash: udp = itemVal; break ;
15541572 case " fast-open" _hash: tfo = itemVal; break ;
15551573 case " tls13" _hash: tls13 = itemVal; break ;
@@ -1558,11 +1576,23 @@ bool explodeSurge(std::string surge, const std::string &custom_port, std::vector
15581576 }
15591577 if (remarks.empty ())
15601578 remarks = server + " :" + port;
1561- if (plugin. size ( ))
1579+ switch ( hash_ (plugin ))
15621580 {
1581+ case " simple-obfs" _hash:
15631582 pluginopts = " obfs=" + pluginopts_mode;
15641583 if (pluginopts_host.size ())
15651584 pluginopts += " ;obfs-host=" + pluginopts_host;
1585+ break ;
1586+ case " v2ray-plugin" _hash:
1587+ if (pluginopts_host.empty () && !isIPv4 (server) && !isIPv6 (server))
1588+ pluginopts_host = server;
1589+ pluginopts = " mode=" + pluginopts_mode;
1590+ if (pluginopts_host.size ())
1591+ pluginopts += " ;host=" + pluginopts_host;
1592+ if (path.size ())
1593+ pluginopts += " ;path=" + path;
1594+ pluginopts += " ;" + tls;
1595+ break ;
15661596 }
15671597
15681598 if (protocol.size ())
@@ -1681,6 +1711,7 @@ bool explodeSurge(std::string surge, const std::string &custom_port, std::vector
16811711 case " over-tls" _hash: tls = itemVal; break ;
16821712 case " tls-verification" _hash: scv = itemVal == " false" ; break ;
16831713 case " tls13" _hash: tls13 = itemVal; break ;
1714+ case " fast-open" _hash: tfo = itemVal; break ;
16841715 default : continue ;
16851716 }
16861717 }
@@ -1697,7 +1728,7 @@ bool explodeSurge(std::string surge, const std::string &custom_port, std::vector
16971728
16981729 node.linkType = SPEEDTEST_MESSAGE_FOUNDHTTP;
16991730 node.group = HTTP_DEFAULT_GROUP;
1700- node.proxyStr = httpConstruct (node.group , remarks, server, port, username, password, tls == " true" , scv, tls13);
1731+ node.proxyStr = httpConstruct (node.group , remarks, server, port, username, password, tls == " true" , tfo, scv, tls13);
17011732 break ;
17021733 default :
17031734 continue ;
0 commit comments