From 775d83af5845ed1df23ef138d6a6bc7a0e193985 Mon Sep 17 00:00:00 2001 From: Tindy X <49061470+tindy2013@users.noreply.github.com> Date: Sun, 29 Mar 2020 23:39:22 +0800 Subject: [PATCH] Optimize codes --- src/subexport.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/subexport.cpp b/src/subexport.cpp index d55cef3..29d5873 100644 --- a/src/subexport.cpp +++ b/src/subexport.cpp @@ -807,7 +807,7 @@ void netchToClash(std::vector &nodes, YAML::Node &yamlnode, string_arr singleproxy["type"] = "ss"; singleproxy["cipher"] = method; singleproxy["password"] = password; - if(std::all_of(password.begin(), password.end(), ::isdigit)) + if(std::all_of(password.begin(), password.end(), ::isdigit) && !password.empty()) singleproxy["password"].SetTag("str"); switch(hash_(plugin)) { @@ -852,12 +852,8 @@ void netchToClash(std::vector &nodes, YAML::Node &yamlnode, string_arr singleproxy["network"] = transproto; singleproxy["ws-path"] = path; singleproxy["ws-headers"]["Host"] = host; - singleproxy["headers"]["Host"] = host; if(edge.size()) - { singleproxy["ws-headers"]["Edge"] = edge; - singleproxy["headers"]["Edge"] = edge; - } break; default: continue; @@ -884,7 +880,7 @@ void netchToClash(std::vector &nodes, YAML::Node &yamlnode, string_arr singleproxy["type"] = "ssr"; singleproxy["cipher"] = method; singleproxy["password"] = password; - if(std::all_of(password.begin(), password.end(), ::isdigit)) + if(std::all_of(password.begin(), password.end(), ::isdigit) && !password.empty()) singleproxy["password"].SetTag("str"); singleproxy["protocol"] = protocol; singleproxy["protocolparam"] = protoparam; @@ -895,7 +891,7 @@ void netchToClash(std::vector &nodes, YAML::Node &yamlnode, string_arr singleproxy["type"] = "socks5"; singleproxy["username"] = username; singleproxy["password"] = password; - if(std::all_of(password.begin(), password.end(), ::isdigit)) + if(std::all_of(password.begin(), password.end(), ::isdigit) && !password.empty()) singleproxy["password"].SetTag("str"); if(ext.skip_cert_verify) singleproxy["skip-cert-verify"] = true; @@ -904,7 +900,7 @@ void netchToClash(std::vector &nodes, YAML::Node &yamlnode, string_arr singleproxy["type"] = "http"; singleproxy["username"] = username; singleproxy["password"] = password; - if(std::all_of(password.begin(), password.end(), ::isdigit)) + if(std::all_of(password.begin(), password.end(), ::isdigit) && !password.empty()) singleproxy["password"].SetTag("str"); singleproxy["tls"] = type == "HTTPS"; if(ext.skip_cert_verify) @@ -913,7 +909,7 @@ void netchToClash(std::vector &nodes, YAML::Node &yamlnode, string_arr case SPEEDTEST_MESSAGE_FOUNDTROJAN: singleproxy["type"] = "trojan"; singleproxy["password"] = password; - if(std::all_of(password.begin(), password.end(), ::isdigit)) + if(std::all_of(password.begin(), password.end(), ::isdigit) && !password.empty()) singleproxy["password"].SetTag("str"); if(ext.skip_cert_verify) singleproxy["skip-cert-verify"] = true;