From f51dad62dcc7667f98b6714c85128a7e85efe222 Mon Sep 17 00:00:00 2001 From: dzhuang Date: Tue, 30 Jan 2024 14:48:39 +0800 Subject: [PATCH] Fix scv not changed with skip_cert_verify_flag default value for Hysteria and Trojan. (#12) * Fix "insecure" param of Hysteria2 with Default skip_cert_verify_flag. * Fix "allowInsecure" param of Trojan with Default skip_cert_verify_flag. --- src/generator/config/subexport.cpp | 4 ++++ src/parser/subparser.cpp | 3 ++- src/parser/subparser.h | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/generator/config/subexport.cpp b/src/generator/config/subexport.cpp index d4799a652..55f966203 100644 --- a/src/generator/config/subexport.cpp +++ b/src/generator/config/subexport.cpp @@ -363,6 +363,8 @@ void proxyToClash(std::vector &nodes, YAML::Node &yamlnode, const ProxyGr singleproxy["sni"] = x.Host; if (!scv.is_undef()) singleproxy["skip-cert-verify"] = scv.get(); + if (!x.AllowInsecure.is_undef()) + singleproxy["skip-cert-verify"] = x.AllowInsecure.get(); if (!x.Alpn.empty()) singleproxy["alpn"].push_back(x.Alpn); if (!x.OBFSParam.empty()) @@ -495,6 +497,8 @@ void proxyToClash(std::vector &nodes, YAML::Node &yamlnode, const ProxyGr singleproxy["password"].SetTag("str"); if(!scv.is_undef()) singleproxy["skip-cert-verify"] = scv.get(); + if (!x.AllowInsecure.is_undef()) + singleproxy["skip-cert-verify"] = x.AllowInsecure.get(); switch(hash_(x.TransferProtocol)) { case "tcp"_hash: diff --git a/src/parser/subparser.cpp b/src/parser/subparser.cpp index 6a3bafe19..ba5a1ee54 100644 --- a/src/parser/subparser.cpp +++ b/src/parser/subparser.cpp @@ -1353,6 +1353,7 @@ void explodeClash(Node yamlnode, std::vector &nodes) singleproxy["sni"] >>= host; singleproxy["alpn"][0] >>= alpn; + scv = singleproxy["insecure"].IsDefined() ? singleproxy["insecure"].as() == "1" : false; hysteria2Construct(node, group, ps, server, port, password, host, up, down, alpn, obfsParam, obfsPassword, udp, tfo, scv); break; default: @@ -1444,7 +1445,7 @@ void explodeStdHysteria(std::string hysteria, Proxy &node) void explodeStdHysteria2(std::string hysteria2, Proxy &node) { - std::string add, port, password, host, insecure, up, down, alpn, obfsParam, obfsPassword, remarks; + std::string add, port, password, host, up, down, alpn, obfsParam, obfsPassword, remarks; std::string addition; tribool scv; hysteria2 = hysteria2.substr(12); diff --git a/src/parser/subparser.h b/src/parser/subparser.h index 685f27225..c8a31273c 100644 --- a/src/parser/subparser.h +++ b/src/parser/subparser.h @@ -21,7 +21,7 @@ enum class ConfType }; void hysteriaConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &add, const std::string &port, const std::string &type, const std::string &auth, const std::string &host, const std::string &up, const std::string &down, const std::string &alpn, const std::string &obfsParam, const std::string &insecure ,tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool(), tribool tls13 = tribool()); -void hysteria2Construct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &add, const std::string &port, const std::string &password, const std::string &host, const std::string &up, const std::string &down, const std::string &alpn, const std::string &obfsParam, const std::string &obfsPassword, const std::string &insecure ,tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool(), tribool tls13 = tribool()); +void hysteria2Construct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &add, const std::string &port, const std::string &password, const std::string &host, const std::string &up, const std::string &down, const std::string &alpn, const std::string &obfsParam, const std::string &obfsPassword, tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool()); void vmessConstruct(Proxy &node, 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, const std::string &sni, const std::string &alpn, tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool(), tribool tls13 = tribool()); void vlessConstruct(Proxy &node, 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 &flow, const std::string &mode, const std::string &path, const std::string &host, const std::string &edge, const std::string &tls,const std::string &pkd, const std::string &sid, const std::string &fp, tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool(), tribool tls13 = tribool()); void ssrConstruct(Proxy &node, const std::string &group, const std::string &remarks, 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, tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool());