From f56e7dd5aeeb88ca87427bfe9ede6e27ea8a5e4a Mon Sep 17 00:00:00 2001 From: Tindy X <49061470+tindy2013@users.noreply.github.com> Date: Thu, 23 Jul 2020 00:13:13 +0800 Subject: [PATCH] Add support for ShadowsocksR nodes in Clash subscriptions --- src/subexport.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/subexport.cpp b/src/subexport.cpp index 9fac398..a483724 100644 --- a/src/subexport.cpp +++ b/src/subexport.cpp @@ -28,8 +28,9 @@ extern bool api_mode, surge_ssr_resolve; extern string_array ss_ciphers, ssr_ciphers; extern size_t max_allowed_rules; -const string_array clashr_protocols = {"auth_aes128_md5", "auth_aes128_sha1"}; -const string_array clashr_obfs = {"plain", "http_simple", "http_post", "tls1.2_ticket_auth"}; +const string_array clashr_protocols = {"origin", "auth_sha1_v4", "auth_aes128_md5", "auth_aes128_sha1", "auth_chain_a", "auth_chain_b"}; +const string_array clashr_obfs = {"plain", "http_simple", "http_post", "random_head", "tls1.2_ticket_auth", "tls1.2_ticket_fastauth"}; +const string_array clash_ssr_ciphers = {"rc4-md5", "aes-128-ctr", "aes-192-ctr", "aes-256-ctr", "aes-128-cfb", "aes-192-cfb", "aes-256-cfb", "chacha20-ietf", "xchacha20"}; /// rule type lists #define basic_types "DOMAIN", "DOMAIN-SUFFIX", "DOMAIN-KEYWORD", "IP-CIDR", "SRC-IP-CIDR", "GEOIP", "MATCH", "FINAL" @@ -1249,13 +1250,13 @@ void netchToClash(std::vector &nodes, YAML::Node &yamlnode, const stri } break; case SPEEDTEST_MESSAGE_FOUNDSSR: - if(!clashR) - continue; //ignoring all nodes with unsupported obfs, protocols and encryption protocol = GetMember(json, "Protocol"); obfs = GetMember(json, "OBFS"); if(ext.filter_deprecated) { + if(!clashR && std::find(clash_ssr_ciphers.cbegin(), clash_ssr_ciphers.cend(), method) == clash_ssr_ciphers.cend()) + continue; if(std::find(clashr_protocols.cbegin(), clashr_protocols.cend(), protocol) == clashr_protocols.cend()) continue; if(std::find(clashr_obfs.cbegin(), clashr_obfs.cend(), obfs) == clashr_obfs.cend()) @@ -1270,9 +1271,17 @@ void netchToClash(std::vector &nodes, YAML::Node &yamlnode, const stri if(std::all_of(password.begin(), password.end(), ::isdigit) && !password.empty()) singleproxy["password"].SetTag("str"); singleproxy["protocol"] = protocol; - singleproxy["protocolparam"] = protoparam; singleproxy["obfs"] = obfs; - singleproxy["obfsparam"] = obfsparam; + if(clashR) + { + singleproxy["protocolparam"] = protoparam; + singleproxy["obfsparam"] = obfsparam; + } + else + { + singleproxy["protocol-param"] = protoparam; + singleproxy["obfs-param"] = obfsparam; + } break; case SPEEDTEST_MESSAGE_FOUNDSOCKS: singleproxy["type"] = "socks5";