From 2abbd901e4211a771704aaed336cfb1a80b26cf0 Mon Sep 17 00:00:00 2001 From: Tindy X <49061470+tindy2013@users.noreply.github.com> Date: Wed, 26 Aug 2020 00:34:10 +0800 Subject: [PATCH] Enhancements Fix crash when trying to convert SSR subscriptions to SSD subscriptions. Add PROCESS-NAME rule type to Clash subscriptions. Optimize codes. --- src/subexport.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/subexport.cpp b/src/subexport.cpp index 21aaadd..e36e87a 100644 --- a/src/subexport.cpp +++ b/src/subexport.cpp @@ -34,7 +34,7 @@ const string_array clash_ssr_ciphers = {"rc4-md5", "aes-128-ctr", "aes-192-ctr", /// rule type lists #define basic_types "DOMAIN", "DOMAIN-SUFFIX", "DOMAIN-KEYWORD", "IP-CIDR", "SRC-IP-CIDR", "GEOIP", "MATCH", "FINAL" -string_array ClashRuleTypes = {basic_types, "IP-CIDR6", "SRC-PORT", "DST-PORT"}; +string_array ClashRuleTypes = {basic_types, "IP-CIDR6", "SRC-PORT", "DST-PORT", "PROCESS-NAME"}; string_array Surge2RuleTypes = {basic_types, "IP-CIDR6", "USER-AGENT", "URL-REGEX", "PROCESS-NAME", "IN-PORT", "DEST-PORT", "SRC-IP"}; string_array SurgeRuleTypes = {basic_types, "IP-CIDR6", "USER-AGENT", "URL-REGEX", "AND", "OR", "NOT", "PROCESS-NAME", "IN-PORT", "DEST-PORT", "SRC-IP"}; string_array QuanXRuleTypes = {basic_types, "USER-AGENT", "HOST", "HOST-SUFFIX", "HOST-KEYWORD"}; @@ -1528,6 +1528,7 @@ std::string netchToSurge(std::vector &nodes, const std::string &base_c ini.AddDirectSaveSection("Rule"); ini.AddDirectSaveSection("MITM"); ini.AddDirectSaveSection("Script"); + ini.AddDirectSaveSection("Host"); ini.AddDirectSaveSection("URL Rewrite"); ini.AddDirectSaveSection("Header Rewrite"); if(ini.Parse(base_conf) != 0 && !ext.nodelist) @@ -2586,7 +2587,7 @@ std::string netchToSSD(std::vector &nodes, std::string &group, std::st rapidjson::Document json; rapidjson::StringBuffer sb; rapidjson::Writer writer(sb); - std::string remark, hostname, password, method; + std::string hostname, password, method; std::string plugin, pluginopts; std::string protocol, protoparam, obfs, obfsparam; int port, index = 0; @@ -2629,7 +2630,6 @@ std::string netchToSSD(std::vector &nodes, std::string &group, std::st { json.Parse(x.proxyStr.data()); - remark = "\"" + replace_all_distinct(UTF8ToCodePoint(x.remarks), "\\u1f1", "\\ud83c\\udd") + "\""; //convert UTF-8 characters to code points hostname = GetMember(json, "Hostname"); port = (unsigned short)to_int(GetMember(json, "Port")); password = GetMember(json, "Password"); @@ -2660,7 +2660,7 @@ std::string netchToSSD(std::vector &nodes, std::string &group, std::st writer.Key("plugin_options"); writer.String(pluginopts.data()); writer.Key("remarks"); - writer.RawValue(remark.data(), remark.size(), rapidjson::Type::kStringType); + writer.String(x.remarks.data()); writer.Key("id"); writer.Int(index); writer.EndObject(); @@ -2677,9 +2677,8 @@ std::string netchToSSD(std::vector &nodes, std::string &group, std::st writer.String(method.data()); writer.Key("password"); writer.String(password.data()); - writer.String(pluginopts.data()); writer.Key("remarks"); - writer.RawValue(remark.data(), remark.size(), rapidjson::Type::kStringType); + writer.String(x.remarks.data()); writer.Key("id"); writer.Int(index); writer.EndObject();