diff --git a/base/pref-new.yml b/base/pref-new.yml index 25b8b2e..e9fd9d6 100644 --- a/base/pref-new.yml +++ b/base/pref-new.yml @@ -40,9 +40,10 @@ userinfo: node_pref: # udp_flag: false # tcp_fast_open_flag: false +# skip_cert_verify_flag: false +# tls13_flag: false sort_flag: false sort_script: "" -# skip_cert_verify_flag: false filter_deprecated_nodes: false append_sub_userinfo: true clash_use_new_field_name: true diff --git a/base/pref.ini b/base/pref.ini index 9beec42..5bd8001 100644 --- a/base/pref.ini +++ b/base/pref.ini @@ -91,13 +91,14 @@ time_rule=^.*?流量:(?:.*?) 剩:(.*)$|left=$1d [node_pref] ;udp_flag=false ;tcp_fast_open_flag=false +;skip_cert_verify_flag=false +;tls13_flag=false sort_flag=false ;Script used for sorting nodes. A "compare" function with 2 arguments which are the 2 nodes to be compared should be defined in the script. Supports inline script and script path. ;Examples can be seen at the filter_script option in [common] section. ;sort_script=function compare(node_a, node_b) {\n const info_a = JSON.parse(node_a.ProxyInfo);\n const info_b = JSON.parse(node_b.ProxyInfo);\n return info_a.Remark > info_b.Remark;\n} -;skip_cert_verify_flag=false filter_deprecated_nodes=false append_sub_userinfo=true clash_use_new_field_name=true diff --git a/src/interfaces.cpp b/src/interfaces.cpp index 7161402..af87266 100644 --- a/src/interfaces.cpp +++ b/src/interfaces.cpp @@ -50,7 +50,7 @@ std::mutex on_configuring; //preferences string_array renames, emojis; bool add_emoji = false, remove_old_emoji = false, append_proxy_type = false, filter_deprecated = true; -tribool udp_flag, tfo_flag, scv_flag, enable_insert; +tribool udp_flag, tfo_flag, scv_flag, tls13_flag, enable_insert; bool do_sort = false, config_update_strict = false; bool clash_use_new_field_name = false; std::string proxy_config, proxy_ruleset, proxy_subscription; @@ -650,6 +650,7 @@ void readYAMLConf(YAML::Node &node) udp_flag.set(safe_as(section["udp_flag"])); tfo_flag.set(safe_as(section["tcp_fast_open_flag"])); scv_flag.set(safe_as(section["skip_cert_verify_flag"])); + tls13_flag.set(safe_as(section["tls13_flag"])); section["sort_flag"] >> do_sort; section["sort_script"] >> sort_script; section["filter_deprecated_nodes"] >> filter_deprecated; @@ -881,6 +882,7 @@ void readConf() udp_flag.set(ini.Get("udp_flag")); tfo_flag.set(ini.Get("tcp_fast_open_flag")); scv_flag.set(ini.Get("skip_cert_verify_flag")); + tls13_flag.set(ini.Get("tls13_flag")); ini.GetBoolIfExist("sort_flag", do_sort); sort_script = ini.Get("sort_script"); ini.GetBoolIfExist("filter_deprecated_nodes", filter_deprecated); @@ -1289,7 +1291,7 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS) tribool sort_flag = getUrlArg(argument, "sort"), use_sort_script = getUrlArg(argument, "sort_script"); tribool clash_new_field = getUrlArg(argument, "new_name"), clash_script = getUrlArg(argument, "script"), add_insert = getUrlArg(argument, "insert"); tribool scv = getUrlArg(argument, "scv"), fdn = getUrlArg(argument, "fdn"), expand = getUrlArg(argument, "expand"), append_sub_userinfo = getUrlArg(argument, "append_info"); - tribool prepend_insert = getUrlArg(argument, "prepend"), classical = getUrlArg(argument, "classic"); + tribool prepend_insert = getUrlArg(argument, "prepend"), classical = getUrlArg(argument, "classic"), tls13 = getUrlArg(argument, "tls13"); std::string base_content, output_content; string_array extra_group, extra_ruleset, include_remarks = def_include_remarks, exclude_remarks = def_exclude_remarks; @@ -1350,6 +1352,7 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS) ext.tfo.read(tfo).read(tfo_flag); ext.udp.read(udp).read(udp_flag); ext.skip_cert_verify.read(scv).read(scv_flag); + ext.tls13.read(tls13).read(tls13_flag); ext.sort_flag = sort_flag.get(do_sort); use_sort_script.define(sort_script.size() != 0); @@ -1952,7 +1955,7 @@ std::string surgeConfToClash(RESPONSE_CALLBACK_ARGS) return "No nodes were found!"; } - extra_settings ext = {true, true, dummy_str_array, dummy_str_array, false, false, false, false, do_sort, filter_deprecated, clash_use_new_field_name, false, "", "", ""}; + extra_settings ext = {true, true, dummy_str_array, dummy_str_array, false, false, false, false, do_sort, filter_deprecated, clash_use_new_field_name, false, "", "", "", udp_flag, tfo_flag, scv_flag, tls13_flag}; netchToClash(nodes, clash, dummy_str_array, false, ext); diff --git a/src/speedtestutil.cpp b/src/speedtestutil.cpp index 5e10043..4dd9efe 100644 --- a/src/speedtestutil.cpp +++ b/src/speedtestutil.cpp @@ -1247,7 +1247,7 @@ bool explodeSurge(std::string surge, const std::string &custom_port, std::vector std::string protocol, protoparam; //ssr std::string itemName, itemVal, config; std::vector configs, vArray, headers, header; - tribool udp, tfo, scv; + tribool udp, tfo, scv, tls13; /* remarks = regReplace(x.second, proxystr, "$1"); @@ -1425,6 +1425,7 @@ bool explodeSurge(std::string surge, const std::string &custom_port, std::vector case "udp-relay"_hash: udp = itemVal; break; case "tfo"_hash: tfo = itemVal; break; case "skip-cert-verify"_hash: scv = itemVal; break; + case "tls13"_hash: tls13 = itemVal; break; default: continue; } } @@ -1433,7 +1434,7 @@ bool explodeSurge(std::string surge, const std::string &custom_port, std::vector node.linkType = SPEEDTEST_MESSAGE_FOUNDVMESS; node.group = V2RAY_DEFAULT_GROUP; - node.proxyStr = vmessConstruct(node.group, remarks, server, port, "", id, "0", net, method, path, host, edge, tls, udp, tfo, scv); + node.proxyStr = vmessConstruct(node.group, remarks, server, port, "", id, "0", net, method, path, host, edge, tls, udp, tfo, scv, tls13); break; case "http"_hash: //http proxy node.linkType = SPEEDTEST_MESSAGE_FOUNDHTTP; @@ -1551,6 +1552,7 @@ bool explodeSurge(std::string surge, const std::string &custom_port, std::vector case "obfs-host"_hash: pluginopts_host = itemVal; break; case "udp-relay"_hash: udp = itemVal; break; case "fast-open"_hash: tfo = itemVal; break; + case "tls13"_hash: tls13 = itemVal; break; default: continue; } } @@ -1573,7 +1575,7 @@ bool explodeSurge(std::string surge, const std::string &custom_port, std::vector { node.linkType = SPEEDTEST_MESSAGE_FOUNDSS; node.group = SS_DEFAULT_GROUP; - node.proxyStr = ssConstruct(node.group, remarks, server, port, password, method, plugin, pluginopts, libev, udp, tfo, scv); + node.proxyStr = ssConstruct(node.group, remarks, server, port, password, method, plugin, pluginopts, libev, udp, tfo, scv, tls13); } break; case "vmess"_hash: //quantumult x style vmess link @@ -1600,6 +1602,7 @@ bool explodeSurge(std::string surge, const std::string &custom_port, std::vector { case "ws"_hash: net = "ws"; break; case "over-tls"_hash: tls = "tls"; break; + case "wss"_hash: net = "ws"; tls = "tls"; break; } break; case "obfs-host"_hash: host = itemVal; break; @@ -1607,6 +1610,7 @@ bool explodeSurge(std::string surge, const std::string &custom_port, std::vector case "over-tls"_hash: tls = itemVal == "true" ? "tls" : ""; break; case "udp-relay"_hash: udp = itemVal; break; case "fast-open"_hash: tfo = itemVal; break; + case "tls13"_hash: tls13 = itemVal; break; default: continue; } } @@ -1618,7 +1622,7 @@ bool explodeSurge(std::string surge, const std::string &custom_port, std::vector node.linkType = SPEEDTEST_MESSAGE_FOUNDVMESS; node.group = V2RAY_DEFAULT_GROUP; - node.proxyStr = vmessConstruct(node.group, remarks, server, port, "", id, "0", net, method, path, host, "", tls, udp, tfo, scv); + node.proxyStr = vmessConstruct(node.group, remarks, server, port, "", id, "0", net, method, path, host, "", tls, udp, tfo, scv, tls13); break; case "trojan"_hash: //quantumult x style trojan link server = trim(configs[0].substr(0, configs[0].rfind(":"))); @@ -1642,6 +1646,7 @@ bool explodeSurge(std::string surge, const std::string &custom_port, std::vector case "udp-relay"_hash: udp = itemVal; break; case "fast-open"_hash: tfo = itemVal; break; case "tls-verification"_hash: scv = itemVal == "false"; break; + case "tls13"_hash: tls13 = itemVal; break; default: continue; } } @@ -1653,7 +1658,7 @@ bool explodeSurge(std::string surge, const std::string &custom_port, std::vector node.linkType = SPEEDTEST_MESSAGE_FOUNDTROJAN; node.group = TROJAN_DEFAULT_GROUP; - node.proxyStr = trojanConstruct(node.group, remarks, server, port, password, host, tls == "true", udp, tfo, scv); + node.proxyStr = trojanConstruct(node.group, remarks, server, port, password, host, tls == "true", udp, tfo, scv, tls13); break; case "http"_hash: //quantumult x style http links server = trim(configs[0].substr(0, configs[0].rfind(":"))); @@ -1675,6 +1680,7 @@ bool explodeSurge(std::string surge, const std::string &custom_port, std::vector case "tag"_hash: remarks = itemVal; break; case "over-tls"_hash: tls = itemVal; break; case "tls-verification"_hash: scv = itemVal == "false"; break; + case "tls13"_hash: tls13 = itemVal; break; default: continue; } } @@ -1691,7 +1697,7 @@ bool explodeSurge(std::string surge, const std::string &custom_port, std::vector node.linkType = SPEEDTEST_MESSAGE_FOUNDHTTP; node.group = HTTP_DEFAULT_GROUP; - node.proxyStr = httpConstruct(node.group, remarks, server, port, username, password, tls == "true", scv); + node.proxyStr = httpConstruct(node.group, remarks, server, port, username, password, tls == "true", scv, tls13); break; default: continue; diff --git a/src/speedtestutil.h b/src/speedtestutil.h index 118b95e..abfc000 100644 --- a/src/speedtestutil.h +++ b/src/speedtestutil.h @@ -7,12 +7,12 @@ #include "misc.h" #include "nodeinfo.h" -std::string vmessConstruct(const std::string &group, const std::string &remarks, const std::string &add, const std::string &port, const std::string &type, const std::string &id, const std::string &aid, const std::string &net, const std::string &cipher, const std::string &path, const std::string &host, const std::string &edge, const std::string &tls, tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool()); +std::string vmessConstruct(const std::string &group, const std::string &remarks, const std::string &add, const std::string &port, const std::string &type, const std::string &id, const std::string &aid, const std::string &net, const std::string &cipher, const std::string &path, const std::string &host, const std::string &edge, const std::string &tls, tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool(), tribool tls13 = tribool()); std::string ssrConstruct(const std::string &group, const std::string &remarks, const std::string &remarks_base64, const std::string &server, const std::string &port, const std::string &protocol, const std::string &method, const std::string &obfs, const std::string &password, const std::string &obfsparam, const std::string &protoparam, bool libev, tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool()); -std::string ssConstruct(const std::string &group, const std::string &remarks, const std::string &server, const std::string &port, const std::string &password, const std::string &method, const std::string &plugin, const std::string &pluginopts, bool libev, tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool()); +std::string ssConstruct(const std::string &group, const std::string &remarks, const std::string &server, const std::string &port, const std::string &password, const std::string &method, const std::string &plugin, const std::string &pluginopts, bool libev, tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool(), tribool tls13 = tribool()); std::string socksConstruct(const std::string &group, const std::string &remarks, const std::string &server, const std::string &port, const std::string &username, const std::string &password, tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool()); -std::string httpConstruct(const std::string &group, const std::string &remarks, const std::string &server, const std::string &port, const std::string &username, const std::string &password, bool tls, tribool scv = tribool()); -std::string trojanConstruct(const std::string &group, const std::string &remarks, const std::string &server, const std::string &port, const std::string &password, const std::string &host, bool tlssecure, tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool()); +std::string httpConstruct(const std::string &group, const std::string &remarks, const std::string &server, const std::string &port, const std::string &username, const std::string &password, bool tls, tribool scv = tribool(), tribool tls13 = tribool()); +std::string trojanConstruct(const std::string &group, const std::string &remarks, const std::string &server, const std::string &port, const std::string &password, const std::string &host, bool tlssecure, tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool(), tribool tls13 = tribool()); std::string snellConstruct(const std::string &group, const std::string &remarks, const std::string &server, const std::string &port, const std::string &password, const std::string &obfs, const std::string &host, tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool()); void explodeVmess(std::string vmess, const std::string &custom_port, nodeInfo &node); void explodeSSR(std::string ssr, bool ss_libev, bool libev, const std::string &custom_port, nodeInfo &node); diff --git a/src/subexport.cpp b/src/subexport.cpp index 3912fcd..d8db974 100644 --- a/src/subexport.cpp +++ b/src/subexport.cpp @@ -74,7 +74,7 @@ std::string hostnameToIPAddr(const std::string &host) return retAddr; } -std::string vmessConstruct(const std::string &group, const std::string &remarks, const std::string &add, const std::string &port, const std::string &type, const std::string &id, const std::string &aid, const std::string &net, const std::string &cipher, const std::string &path, const std::string &host, const std::string &edge, const std::string &tls, tribool udp, tribool tfo, tribool scv) +std::string vmessConstruct(const std::string &group, const std::string &remarks, const std::string &add, const std::string &port, const std::string &type, const std::string &id, const std::string &aid, const std::string &net, const std::string &cipher, const std::string &path, const std::string &host, const std::string &edge, const std::string &tls, tribool udp, tribool tfo, tribool scv, tribool tls13) { rapidjson::StringBuffer sb; rapidjson::Writer writer(sb); @@ -135,6 +135,11 @@ std::string vmessConstruct(const std::string &group, const std::string &remarks, writer.Key("AllowInsecure"); writer.Bool(scv); } + if(!tls13.is_undef()) + { + writer.Key("TLS13"); + writer.Bool(tls13); + } writer.EndObject(); return sb.GetString(); } @@ -183,7 +188,7 @@ std::string ssrConstruct(const std::string &group, const std::string &remarks, c return sb.GetString(); } -std::string ssConstruct(const std::string &group, const std::string &remarks, const std::string &server, const std::string &port, const std::string &password, const std::string &method, const std::string &plugin, const std::string &pluginopts, bool libev, tribool udp, tribool tfo, tribool scv) +std::string ssConstruct(const std::string &group, const std::string &remarks, const std::string &server, const std::string &port, const std::string &password, const std::string &method, const std::string &plugin, const std::string &pluginopts, bool libev, tribool udp, tribool tfo, tribool scv, tribool tls13) { rapidjson::StringBuffer sb; rapidjson::Writer writer(sb); @@ -221,6 +226,11 @@ std::string ssConstruct(const std::string &group, const std::string &remarks, co writer.Key("AllowInsecure"); writer.Bool(scv); } + if(!tls13.is_undef()) + { + writer.Key("TLS13"); + writer.Bool(tls13); + } writer.EndObject(); return sb.GetString(); } @@ -263,7 +273,7 @@ std::string socksConstruct(const std::string &group, const std::string &remarks, return sb.GetString(); } -std::string httpConstruct(const std::string &group, const std::string &remarks, const std::string &server, const std::string &port, const std::string &username, const std::string &password, bool tls, tribool scv) +std::string httpConstruct(const std::string &group, const std::string &remarks, const std::string &server, const std::string &port, const std::string &username, const std::string &password, bool tls, tribool scv, tribool tls13) { rapidjson::StringBuffer sb; rapidjson::Writer writer(sb); @@ -287,11 +297,16 @@ std::string httpConstruct(const std::string &group, const std::string &remarks, writer.Key("AllowInsecure"); writer.Bool(scv); } + if(!tls13.is_undef()) + { + writer.Key("TLS13"); + writer.Bool(tls13); + } writer.EndObject(); return sb.GetString(); } -std::string trojanConstruct(const std::string &group, const std::string &remarks, const std::string &server, const std::string &port, const std::string &password, const std::string &host, bool tlssecure, tribool udp, tribool tfo, tribool scv) +std::string trojanConstruct(const std::string &group, const std::string &remarks, const std::string &server, const std::string &port, const std::string &password, const std::string &host, bool tlssecure, tribool udp, tribool tfo, tribool scv, tribool tls13) { rapidjson::StringBuffer sb; rapidjson::Writer writer(sb); @@ -327,6 +342,11 @@ std::string trojanConstruct(const std::string &group, const std::string &remarks writer.Key("AllowInsecure"); writer.Bool(scv); } + if(!tls13.is_undef()) + { + writer.Key("TLS13"); + writer.Bool(tls13); + } writer.EndObject(); return sb.GetString(); } @@ -1354,8 +1374,10 @@ void netchToClash(std::vector &nodes, YAML::Node &yamlnode, const stri rules_upper_bound -= 2; singlegroup["url"] = vArray[rules_upper_bound]; parseGroupTimes(vArray[rules_upper_bound + 1], &interval, &tolerance, NULL); - singlegroup["interval"] = interval; - singlegroup["tolerance"] = tolerance; + if(interval) + singlegroup["interval"] = interval; + if(tolerance) + singlegroup["tolerance"] = tolerance; break; default: continue; @@ -1455,7 +1477,7 @@ std::string netchToSurge(std::vector &nodes, const std::string &base_c std::string protocol, protoparam, obfs, obfsparam; std::string id, aid, transproto, faketype, host, edge, path, quicsecure, quicsecret; std::string output_nodelist; - tribool udp, tfo, scv; + tribool udp, tfo, scv, tls13; std::vector nodelist; unsigned short local_port = 1080; bool tlssecure; @@ -1497,9 +1519,11 @@ std::string netchToSurge(std::vector &nodes, const std::string &base_c udp = ext.udp; tfo = ext.tfo; scv = ext.skip_cert_verify; + tls13 = ext.tls13; udp.define(GetMember(json, "EnableUDP")); tfo.define(GetMember(json, "EnableTFO")); scv.define(GetMember(json, "AllowInsecure")); + tls13.define(GetMember(json, "TLS13")); proxy.clear(); @@ -1530,6 +1554,8 @@ std::string netchToSurge(std::vector &nodes, const std::string &base_c path = GetMember(json, "Path"); tlssecure = GetMember(json, "TLSSecure") == "true"; proxy = "vmess, " + hostname + ", " + port + ", username=" + id + ", tls=" + (tlssecure ? "true" : "false"); + if(tlssecure && !tls13.is_undef()) + proxy += ", tls13=" + std::string(tls13 ? "true" : "false"); switch(hash_(transproto)) { case "tcp"_hash: @@ -2193,7 +2219,7 @@ void netchToQuanX(std::vector &nodes, INIReader &ini, std::vector nodelist; string_array remarks_list; @@ -2217,9 +2243,11 @@ void netchToQuanX(std::vector &nodes, INIReader &ini, std::vector &nodes, INIReader &ini, std::vector