mirror of
https://github.com/MetaCubeX/subconverter.git
synced 2025-11-04 18:19:42 +08:00
Bug fixes
Fix issue [#44](https://github.com/tindy2013/subconverter/issues/44). Fix host setting missing for VMess TCP+TLS nodes. Fix logical error in loading external configuration file. Fix a potential multi-thread resource conflict. Add rename and emoji option in external configuration file.
This commit is contained in:
parent
1a54f7c500
commit
1514727573
@ -2,6 +2,7 @@
|
|||||||
;This is an example external configuration file
|
;This is an example external configuration file
|
||||||
;All possible customization settings are shown below
|
;All possible customization settings are shown below
|
||||||
|
|
||||||
|
;Options for custom groups
|
||||||
custom_proxy_group=Proxy`select`.*`[]AUTO`[]DIRECT`.*
|
custom_proxy_group=Proxy`select`.*`[]AUTO`[]DIRECT`.*
|
||||||
custom_proxy_group=AUTO`url-test`.*`http://www.gstatic.com/generate_204`300
|
custom_proxy_group=AUTO`url-test`.*`http://www.gstatic.com/generate_204`300
|
||||||
custom_proxy_group=google`select`.*
|
custom_proxy_group=google`select`.*
|
||||||
@ -17,6 +18,7 @@ custom_proxy_group=屏蔽广告`select`[]REJECT`[]DIRECT
|
|||||||
custom_proxy_group=UnblockNeteaseMusic`select`云音乐解锁`[]DIRECT
|
custom_proxy_group=UnblockNeteaseMusic`select`云音乐解锁`[]DIRECT
|
||||||
custom_proxy_group=Telegram`select`新加坡`[]Proxy
|
custom_proxy_group=Telegram`select`新加坡`[]Proxy
|
||||||
|
|
||||||
|
;Options for custom rulesets
|
||||||
enable_rule_generator=false
|
enable_rule_generator=false
|
||||||
overwrite_original_rules=false
|
overwrite_original_rules=false
|
||||||
;surge_ruleset=DIRECT,https://raw.githubusercontent.com/ConnersHua/Profiles/master/Surge/Ruleset/Unbreak.list
|
;surge_ruleset=DIRECT,https://raw.githubusercontent.com/ConnersHua/Profiles/master/Surge/Ruleset/Unbreak.list
|
||||||
@ -33,7 +35,16 @@ overwrite_original_rules=false
|
|||||||
;surge_ruleset=🍎 苹果服务,https://raw.githubusercontent.com/ConnersHua/Profiles/master/Surge/Ruleset/Apple.list
|
;surge_ruleset=🍎 苹果服务,https://raw.githubusercontent.com/ConnersHua/Profiles/master/Surge/Ruleset/Apple.list
|
||||||
;surge_ruleset=DIRECT,https://raw.githubusercontent.com/ConnersHua/Profiles/master/Surge/Ruleset/China.list
|
;surge_ruleset=DIRECT,https://raw.githubusercontent.com/ConnersHua/Profiles/master/Surge/Ruleset/China.list
|
||||||
|
|
||||||
|
;Options for custom base configuration file
|
||||||
clash_rule_base=config/forcerule.yml
|
clash_rule_base=config/forcerule.yml
|
||||||
;surge_rule_base=surge.conf
|
;surge_rule_base=surge.conf
|
||||||
;surfboard_rule_base=surfboard.conf
|
;surfboard_rule_base=surfboard.conf
|
||||||
;mellow_rule_base=mellow.conf
|
;mellow_rule_base=mellow.conf
|
||||||
|
|
||||||
|
;Options for renaming nodes
|
||||||
|
;rename=Test-(.*?)-(.*?)-(.*?)\((.*?)\)@\1\4x测试线路_自\2到\3
|
||||||
|
;rename=rename_node=\(?((x|X)?(\d+)(\.?\d+)?)((\s?倍率?)|(x|X))\)?@$1x
|
||||||
|
|
||||||
|
;Options for adding emojis
|
||||||
|
;emoji=(流量|时间|应急),🏳️🌈
|
||||||
|
;emoji=阿根廷,🇦🇷
|
||||||
|
|||||||
23
src/main.cpp
23
src/main.cpp
@ -268,6 +268,8 @@ struct ExternalConfig
|
|||||||
std::string surge_rule_base;
|
std::string surge_rule_base;
|
||||||
std::string surfboard_rule_base;
|
std::string surfboard_rule_base;
|
||||||
std::string mellow_rule_base;
|
std::string mellow_rule_base;
|
||||||
|
string_array rename;
|
||||||
|
string_array emoji;
|
||||||
bool overwrite_original_rules = false;
|
bool overwrite_original_rules = false;
|
||||||
bool enable_rule_generator = true;
|
bool enable_rule_generator = true;
|
||||||
};
|
};
|
||||||
@ -309,6 +311,11 @@ int loadExternalConfig(std::string &path, ExternalConfig &ext, std::string proxy
|
|||||||
if(ini.ItemExist("enable_rule_generator"))
|
if(ini.ItemExist("enable_rule_generator"))
|
||||||
ext.enable_rule_generator = ini.GetBool("enable_rule_generator");
|
ext.enable_rule_generator = ini.GetBool("enable_rule_generator");
|
||||||
|
|
||||||
|
if(ini.ItemPrefixExist("rename"))
|
||||||
|
ini.GetAll("rename", ext.rename);
|
||||||
|
if(ini.ItemPrefixExist("emoji"))
|
||||||
|
ini.GetAll("emoji", ext.emoji);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,7 +331,7 @@ void generateBase()
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
clash_base = YAML::Load(base_content);
|
clash_base = YAML::Load(base_content);
|
||||||
rulesetToClash(clash_base, ruleset_content_array);
|
rulesetToClash(clash_base, ruleset_content_array, overwrite_original_rules);
|
||||||
}
|
}
|
||||||
catch (YAML::Exception &e)
|
catch (YAML::Exception &e)
|
||||||
{
|
{
|
||||||
@ -339,7 +346,7 @@ void generateBase()
|
|||||||
if(retVal != INIREADER_EXCEPTION_NONE)
|
if(retVal != INIREADER_EXCEPTION_NONE)
|
||||||
std::cerr<<"Unable to load Mellow base content. Reason: "<<mellow_base.GetLastError()<<"\n";
|
std::cerr<<"Unable to load Mellow base content. Reason: "<<mellow_base.GetLastError()<<"\n";
|
||||||
else
|
else
|
||||||
rulesetToSurge(mellow_base, ruleset_content_array, 2);
|
rulesetToSurge(mellow_base, ruleset_content_array, 2, overwrite_original_rules);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string subconverter(RESPONSE_CALLBACK_ARGS)
|
std::string subconverter(RESPONSE_CALLBACK_ARGS)
|
||||||
@ -383,6 +390,9 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS)
|
|||||||
else
|
else
|
||||||
proxy = proxy_subscription;
|
proxy = proxy_subscription;
|
||||||
|
|
||||||
|
ext.emoji_array = safe_get_emojis();
|
||||||
|
ext.rename_array = safe_get_renames();
|
||||||
|
|
||||||
//load external configuration
|
//load external configuration
|
||||||
if(config.size())
|
if(config.size())
|
||||||
{
|
{
|
||||||
@ -401,12 +411,17 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS)
|
|||||||
ext_surfboard_base = extconf.surfboard_rule_base;
|
ext_surfboard_base = extconf.surfboard_rule_base;
|
||||||
if(extconf.mellow_rule_base.size())
|
if(extconf.mellow_rule_base.size())
|
||||||
ext_mellow_base = extconf.mellow_rule_base;
|
ext_mellow_base = extconf.mellow_rule_base;
|
||||||
|
if(extconf.rename.size())
|
||||||
|
ext.rename_array = extconf.rename;
|
||||||
|
if(extconf.emoji.size())
|
||||||
|
ext.emoji_array = extconf.emoji;
|
||||||
ext.enable_rule_generator = extconf.enable_rule_generator;
|
ext.enable_rule_generator = extconf.enable_rule_generator;
|
||||||
//load custom group
|
//load custom group
|
||||||
if(extconf.custom_proxy_group.size())
|
if(extconf.custom_proxy_group.size())
|
||||||
extra_group = extconf.custom_proxy_group;
|
extra_group = extconf.custom_proxy_group;
|
||||||
//load custom rules
|
//load custom rules
|
||||||
if(extconf.overwrite_original_rules)
|
ext.overwrite_original_rules = extconf.overwrite_original_rules;
|
||||||
|
if(extconf.surge_ruleset.size())
|
||||||
{
|
{
|
||||||
extra_ruleset = extconf.surge_ruleset;
|
extra_ruleset = extconf.surge_ruleset;
|
||||||
refreshRulesets(extra_ruleset, rca);
|
refreshRulesets(extra_ruleset, rca);
|
||||||
@ -679,7 +694,7 @@ std::string simpleToClashR(RESPONSE_CALLBACK_ARGS)
|
|||||||
refreshRulesets(rulesets, ruleset_content_array);
|
refreshRulesets(rulesets, ruleset_content_array);
|
||||||
rca = ruleset_content_array;
|
rca = ruleset_content_array;
|
||||||
|
|
||||||
extra_settings ext = {true, add_emoji, remove_old_emoji, append_proxy_type, udp_flag, tfo_flag, false, do_sort, scv_flag, filter_deprecated, ""};
|
extra_settings ext = {true, overwrite_original_rules, safe_get_renames(), safe_get_emojis(), add_emoji, remove_old_emoji, append_proxy_type, udp_flag, tfo_flag, false, do_sort, scv_flag, filter_deprecated, ""};
|
||||||
|
|
||||||
std::string proxy;
|
std::string proxy;
|
||||||
if(proxy_subscription == "SYSTEM")
|
if(proxy_subscription == "SYSTEM")
|
||||||
|
|||||||
@ -8,21 +8,6 @@ std::mutex on_configuring, on_emoji, on_rename;
|
|||||||
|
|
||||||
extern string_array emojis, renames;
|
extern string_array emojis, renames;
|
||||||
|
|
||||||
void try_config_lock()
|
|
||||||
{
|
|
||||||
guarded_mutex guard(on_configuring);
|
|
||||||
}
|
|
||||||
|
|
||||||
void try_emoji_lock()
|
|
||||||
{
|
|
||||||
guarded_mutex guard(on_emoji);
|
|
||||||
}
|
|
||||||
|
|
||||||
void try_rename_lock()
|
|
||||||
{
|
|
||||||
guarded_mutex guard(on_rename);
|
|
||||||
}
|
|
||||||
|
|
||||||
string_array safe_get_emojis()
|
string_array safe_get_emojis()
|
||||||
{
|
{
|
||||||
guarded_mutex guard(on_emoji);
|
guarded_mutex guard(on_emoji);
|
||||||
|
|||||||
@ -15,9 +15,6 @@
|
|||||||
#include <rapidjson/document.h>
|
#include <rapidjson/document.h>
|
||||||
#include <yaml-cpp/yaml.h>
|
#include <yaml-cpp/yaml.h>
|
||||||
|
|
||||||
extern bool overwrite_original_rules;
|
|
||||||
extern string_array renames, emojis;
|
|
||||||
extern bool add_emoji, remove_old_emoji;
|
|
||||||
extern bool api_mode;
|
extern bool api_mode;
|
||||||
extern string_array ss_ciphers, ssr_ciphers;
|
extern string_array ss_ciphers, ssr_ciphers;
|
||||||
|
|
||||||
@ -91,10 +88,10 @@ std::string vmessConstruct(std::string add, std::string port, std::string type,
|
|||||||
writer.String(cipher.data());
|
writer.String(cipher.data());
|
||||||
writer.Key("TransferProtocol");
|
writer.Key("TransferProtocol");
|
||||||
writer.String(net.data());
|
writer.String(net.data());
|
||||||
|
writer.Key("Host");
|
||||||
|
writer.String(host.data());
|
||||||
if(net == "ws")
|
if(net == "ws")
|
||||||
{
|
{
|
||||||
writer.Key("Host");
|
|
||||||
writer.String(host.data());
|
|
||||||
writer.Key("Path");
|
writer.Key("Path");
|
||||||
writer.String(path.data());
|
writer.String(path.data());
|
||||||
}
|
}
|
||||||
@ -230,7 +227,7 @@ std::string vmessLinkConstruct(std::string remarks, std::string add, std::string
|
|||||||
writer.Key("id");
|
writer.Key("id");
|
||||||
writer.String(id.data());
|
writer.String(id.data());
|
||||||
writer.Key("aid");
|
writer.Key("aid");
|
||||||
writer.Int(to_int(port));
|
writer.Int(to_int(aid));
|
||||||
writer.Key("net");
|
writer.Key("net");
|
||||||
writer.String(net.data());
|
writer.String(net.data());
|
||||||
writer.Key("path");
|
writer.Key("path");
|
||||||
@ -243,11 +240,11 @@ std::string vmessLinkConstruct(std::string remarks, std::string add, std::string
|
|||||||
return sb.GetString();
|
return sb.GetString();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string nodeRename(std::string remark)
|
std::string nodeRename(std::string remark, const string_array &rename_array)
|
||||||
{
|
{
|
||||||
string_array vArray, renames_temp = safe_get_renames();
|
string_array vArray;
|
||||||
|
|
||||||
for(std::string &x : renames_temp)
|
for(const std::string &x : rename_array)
|
||||||
{
|
{
|
||||||
vArray = split(x, "@");
|
vArray = split(x, "@");
|
||||||
if(vArray.size() == 1)
|
if(vArray.size() == 1)
|
||||||
@ -266,8 +263,6 @@ std::string nodeRename(std::string remark)
|
|||||||
|
|
||||||
std::string removeEmoji(std::string remark)
|
std::string removeEmoji(std::string remark)
|
||||||
{
|
{
|
||||||
if(!remove_old_emoji)
|
|
||||||
return remark;
|
|
||||||
char emoji_id[2] = {(char)-16, (char)-97};
|
char emoji_id[2] = {(char)-16, (char)-97};
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
@ -279,12 +274,10 @@ std::string removeEmoji(std::string remark)
|
|||||||
return remark;
|
return remark;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string addEmoji(std::string remark)
|
std::string addEmoji(std::string remark, const string_array &emoji_array)
|
||||||
{
|
{
|
||||||
if(!add_emoji)
|
string_array vArray;
|
||||||
return remark;
|
for(const std::string &x : emoji_array)
|
||||||
string_array vArray, emojis_temp = safe_get_emojis();
|
|
||||||
for(std::string &x : emojis_temp)
|
|
||||||
{
|
{
|
||||||
vArray = split(x, ",");
|
vArray = split(x, ",");
|
||||||
if(vArray.size() != 2)
|
if(vArray.size() != 2)
|
||||||
@ -298,9 +291,8 @@ std::string addEmoji(std::string remark)
|
|||||||
return remark;
|
return remark;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rulesetToClash(YAML::Node &base_rule, std::vector<ruleset_content> &ruleset_content_array)
|
void rulesetToClash(YAML::Node &base_rule, std::vector<ruleset_content> &ruleset_content_array, bool overwrite_original_rules)
|
||||||
{
|
{
|
||||||
try_config_lock();
|
|
||||||
string_array allRules, vArray;
|
string_array allRules, vArray;
|
||||||
std::string rule_group, retrived_rules, strLine;
|
std::string rule_group, retrived_rules, strLine;
|
||||||
std::stringstream strStrm;
|
std::stringstream strStrm;
|
||||||
@ -357,9 +349,8 @@ void rulesetToClash(YAML::Node &base_rule, std::vector<ruleset_content> &ruleset
|
|||||||
base_rule["Rule"] = Rules;
|
base_rule["Rule"] = Rules;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rulesetToSurge(INIReader &base_rule, std::vector<ruleset_content> &ruleset_content_array, int surge_ver)
|
void rulesetToSurge(INIReader &base_rule, std::vector<ruleset_content> &ruleset_content_array, int surge_ver, bool overwrite_original_rules)
|
||||||
{
|
{
|
||||||
try_config_lock();
|
|
||||||
string_array allRules;
|
string_array allRules;
|
||||||
std::string rule_group, rule_path, retrived_rules, strLine;
|
std::string rule_group, rule_path, retrived_rules, strLine;
|
||||||
std::stringstream strStrm;
|
std::stringstream strStrm;
|
||||||
@ -483,7 +474,6 @@ void groupGenerate(std::string &rule, std::vector<nodeInfo> &nodelist, std::vect
|
|||||||
|
|
||||||
void netchToClash(std::vector<nodeInfo> &nodes, YAML::Node &yamlnode, string_array &extra_proxy_group, bool clashR, extra_settings &ext)
|
void netchToClash(std::vector<nodeInfo> &nodes, YAML::Node &yamlnode, string_array &extra_proxy_group, bool clashR, extra_settings &ext)
|
||||||
{
|
{
|
||||||
try_config_lock();
|
|
||||||
YAML::Node proxies, singleproxy, singlegroup, original_groups;
|
YAML::Node proxies, singleproxy, singlegroup, original_groups;
|
||||||
rapidjson::Document json;
|
rapidjson::Document json;
|
||||||
std::string type, remark, hostname, port, username, password, method;
|
std::string type, remark, hostname, port, username, password, method;
|
||||||
@ -496,12 +486,12 @@ void netchToClash(std::vector<nodeInfo> &nodes, YAML::Node &yamlnode, string_arr
|
|||||||
|
|
||||||
std::for_each(nodes.begin(), nodes.end(), [ext](nodeInfo &x)
|
std::for_each(nodes.begin(), nodes.end(), [ext](nodeInfo &x)
|
||||||
{
|
{
|
||||||
x.remarks = nodeRename(x.remarks);
|
x.remarks = nodeRename(x.remarks, ext.rename_array);
|
||||||
if(ext.remove_emoji)
|
if(ext.remove_emoji)
|
||||||
x.remarks = trim(removeEmoji(x.remarks));
|
x.remarks = trim(removeEmoji(x.remarks));
|
||||||
|
|
||||||
if(ext.add_emoji)
|
if(ext.add_emoji)
|
||||||
x.remarks = addEmoji(x.remarks);
|
x.remarks = addEmoji(x.remarks, ext.emoji_array);
|
||||||
});
|
});
|
||||||
|
|
||||||
if(ext.sort_flag)
|
if(ext.sort_flag)
|
||||||
@ -724,14 +714,13 @@ std::string netchToClash(std::vector<nodeInfo> &nodes, std::string &base_conf, s
|
|||||||
return YAML::Dump(yamlnode);
|
return YAML::Dump(yamlnode);
|
||||||
|
|
||||||
if(ext.enable_rule_generator)
|
if(ext.enable_rule_generator)
|
||||||
rulesetToClash(yamlnode, ruleset_content_array);
|
rulesetToClash(yamlnode, ruleset_content_array, ext.overwrite_original_rules);
|
||||||
|
|
||||||
return YAML::Dump(yamlnode);
|
return YAML::Dump(yamlnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string netchToSurge(std::vector<nodeInfo> &nodes, std::string &base_conf, std::vector<ruleset_content> &ruleset_content_array, string_array &extra_proxy_group, int surge_ver, extra_settings &ext)
|
std::string netchToSurge(std::vector<nodeInfo> &nodes, std::string &base_conf, std::vector<ruleset_content> &ruleset_content_array, string_array &extra_proxy_group, int surge_ver, extra_settings &ext)
|
||||||
{
|
{
|
||||||
try_config_lock();
|
|
||||||
rapidjson::Document json;
|
rapidjson::Document json;
|
||||||
INIReader ini;
|
INIReader ini;
|
||||||
std::string proxy;
|
std::string proxy;
|
||||||
@ -760,12 +749,12 @@ std::string netchToSurge(std::vector<nodeInfo> &nodes, std::string &base_conf, s
|
|||||||
|
|
||||||
std::for_each(nodes.begin(), nodes.end(), [ext](nodeInfo &x)
|
std::for_each(nodes.begin(), nodes.end(), [ext](nodeInfo &x)
|
||||||
{
|
{
|
||||||
x.remarks = nodeRename(x.remarks);
|
x.remarks = nodeRename(x.remarks, ext.rename_array);
|
||||||
if(ext.remove_emoji)
|
if(ext.remove_emoji)
|
||||||
x.remarks = trim(removeEmoji(x.remarks));
|
x.remarks = trim(removeEmoji(x.remarks));
|
||||||
|
|
||||||
if(ext.add_emoji)
|
if(ext.add_emoji)
|
||||||
x.remarks = addEmoji(x.remarks);
|
x.remarks = addEmoji(x.remarks, ext.emoji_array);
|
||||||
});
|
});
|
||||||
|
|
||||||
if(ext.sort_flag)
|
if(ext.sort_flag)
|
||||||
@ -952,7 +941,7 @@ std::string netchToSurge(std::vector<nodeInfo> &nodes, std::string &base_conf, s
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(ext.enable_rule_generator)
|
if(ext.enable_rule_generator)
|
||||||
rulesetToSurge(ini, ruleset_content_array, surge_ver);
|
rulesetToSurge(ini, ruleset_content_array, surge_ver, ext.overwrite_original_rules);
|
||||||
|
|
||||||
return ini.ToString();
|
return ini.ToString();
|
||||||
}
|
}
|
||||||
@ -967,12 +956,12 @@ std::string netchToSS(std::vector<nodeInfo> &nodes, extra_settings &ext)
|
|||||||
|
|
||||||
std::for_each(nodes.begin(), nodes.end(), [ext](nodeInfo &x)
|
std::for_each(nodes.begin(), nodes.end(), [ext](nodeInfo &x)
|
||||||
{
|
{
|
||||||
x.remarks = nodeRename(x.remarks);
|
x.remarks = nodeRename(x.remarks, ext.rename_array);
|
||||||
if(ext.remove_emoji)
|
if(ext.remove_emoji)
|
||||||
x.remarks = trim(removeEmoji(x.remarks));
|
x.remarks = trim(removeEmoji(x.remarks));
|
||||||
|
|
||||||
if(ext.add_emoji)
|
if(ext.add_emoji)
|
||||||
x.remarks = addEmoji(x.remarks);
|
x.remarks = addEmoji(x.remarks, ext.emoji_array);
|
||||||
});
|
});
|
||||||
|
|
||||||
if(ext.sort_flag)
|
if(ext.sort_flag)
|
||||||
@ -1039,12 +1028,12 @@ std::string netchToSSSub(std::vector<nodeInfo> &nodes, extra_settings &ext)
|
|||||||
|
|
||||||
std::for_each(nodes.begin(), nodes.end(), [ext](nodeInfo &x)
|
std::for_each(nodes.begin(), nodes.end(), [ext](nodeInfo &x)
|
||||||
{
|
{
|
||||||
x.remarks = nodeRename(x.remarks);
|
x.remarks = nodeRename(x.remarks, ext.rename_array);
|
||||||
if(ext.remove_emoji)
|
if(ext.remove_emoji)
|
||||||
x.remarks = trim(removeEmoji(x.remarks));
|
x.remarks = trim(removeEmoji(x.remarks));
|
||||||
|
|
||||||
if(ext.add_emoji)
|
if(ext.add_emoji)
|
||||||
x.remarks = addEmoji(x.remarks);
|
x.remarks = addEmoji(x.remarks, ext.emoji_array);
|
||||||
});
|
});
|
||||||
|
|
||||||
if(ext.sort_flag)
|
if(ext.sort_flag)
|
||||||
@ -1112,12 +1101,12 @@ std::string netchToSSR(std::vector<nodeInfo> &nodes, extra_settings &ext)
|
|||||||
|
|
||||||
std::for_each(nodes.begin(), nodes.end(), [ext](nodeInfo &x)
|
std::for_each(nodes.begin(), nodes.end(), [ext](nodeInfo &x)
|
||||||
{
|
{
|
||||||
x.remarks = nodeRename(x.remarks);
|
x.remarks = nodeRename(x.remarks, ext.rename_array);
|
||||||
if(ext.remove_emoji)
|
if(ext.remove_emoji)
|
||||||
x.remarks = trim(removeEmoji(x.remarks));
|
x.remarks = trim(removeEmoji(x.remarks));
|
||||||
|
|
||||||
if(ext.add_emoji)
|
if(ext.add_emoji)
|
||||||
x.remarks = addEmoji(x.remarks);
|
x.remarks = addEmoji(x.remarks, ext.emoji_array);
|
||||||
});
|
});
|
||||||
|
|
||||||
if(ext.sort_flag)
|
if(ext.sort_flag)
|
||||||
@ -1173,12 +1162,12 @@ std::string netchToVMess(std::vector<nodeInfo> &nodes, extra_settings &ext)
|
|||||||
|
|
||||||
std::for_each(nodes.begin(), nodes.end(), [ext](nodeInfo &x)
|
std::for_each(nodes.begin(), nodes.end(), [ext](nodeInfo &x)
|
||||||
{
|
{
|
||||||
x.remarks = nodeRename(x.remarks);
|
x.remarks = nodeRename(x.remarks, ext.rename_array);
|
||||||
if(ext.remove_emoji)
|
if(ext.remove_emoji)
|
||||||
x.remarks = trim(removeEmoji(x.remarks));
|
x.remarks = trim(removeEmoji(x.remarks));
|
||||||
|
|
||||||
if(ext.add_emoji)
|
if(ext.add_emoji)
|
||||||
x.remarks = addEmoji(x.remarks);
|
x.remarks = addEmoji(x.remarks, ext.emoji_array);
|
||||||
});
|
});
|
||||||
|
|
||||||
if(ext.sort_flag)
|
if(ext.sort_flag)
|
||||||
@ -1232,12 +1221,12 @@ std::string netchToQuan(std::vector<nodeInfo> &nodes, extra_settings &ext)
|
|||||||
|
|
||||||
std::for_each(nodes.begin(), nodes.end(), [ext](nodeInfo &x)
|
std::for_each(nodes.begin(), nodes.end(), [ext](nodeInfo &x)
|
||||||
{
|
{
|
||||||
x.remarks = nodeRename(x.remarks);
|
x.remarks = nodeRename(x.remarks, ext.rename_array);
|
||||||
if(ext.remove_emoji)
|
if(ext.remove_emoji)
|
||||||
x.remarks = trim(removeEmoji(x.remarks));
|
x.remarks = trim(removeEmoji(x.remarks));
|
||||||
|
|
||||||
if(ext.add_emoji)
|
if(ext.add_emoji)
|
||||||
x.remarks = addEmoji(x.remarks);
|
x.remarks = addEmoji(x.remarks, ext.emoji_array);
|
||||||
});
|
});
|
||||||
|
|
||||||
if(ext.sort_flag)
|
if(ext.sort_flag)
|
||||||
@ -1326,12 +1315,12 @@ std::string netchToQuanX(std::vector<nodeInfo> &nodes, extra_settings &ext)
|
|||||||
|
|
||||||
std::for_each(nodes.begin(), nodes.end(), [ext](nodeInfo &x)
|
std::for_each(nodes.begin(), nodes.end(), [ext](nodeInfo &x)
|
||||||
{
|
{
|
||||||
x.remarks = nodeRename(x.remarks);
|
x.remarks = nodeRename(x.remarks, ext.rename_array);
|
||||||
if(ext.remove_emoji)
|
if(ext.remove_emoji)
|
||||||
x.remarks = trim(removeEmoji(x.remarks));
|
x.remarks = trim(removeEmoji(x.remarks));
|
||||||
|
|
||||||
if(ext.add_emoji)
|
if(ext.add_emoji)
|
||||||
x.remarks = addEmoji(x.remarks);
|
x.remarks = addEmoji(x.remarks, ext.emoji_array);
|
||||||
});
|
});
|
||||||
|
|
||||||
if(ext.sort_flag)
|
if(ext.sort_flag)
|
||||||
@ -1369,7 +1358,7 @@ std::string netchToQuanX(std::vector<nodeInfo> &nodes, extra_settings &ext)
|
|||||||
if(transproto == "ws")
|
if(transproto == "ws")
|
||||||
proxyStr += ", obfs=ws, obfs-host=" + host + ", obfs-uri=" + path;
|
proxyStr += ", obfs=ws, obfs-host=" + host + ", obfs-uri=" + path;
|
||||||
else if(tlssecure)
|
else if(tlssecure)
|
||||||
proxyStr += ", obfs=over-tls";
|
proxyStr += ", obfs=over-tls, obfs-host=" + host;
|
||||||
if(ext.skip_cert_verify)
|
if(ext.skip_cert_verify)
|
||||||
proxyStr += ", certificate=0";
|
proxyStr += ", certificate=0";
|
||||||
break;
|
break;
|
||||||
@ -1435,12 +1424,12 @@ std::string netchToSSD(std::vector<nodeInfo> &nodes, std::string &group, extra_s
|
|||||||
|
|
||||||
std::for_each(nodes.begin(), nodes.end(), [ext](nodeInfo &x)
|
std::for_each(nodes.begin(), nodes.end(), [ext](nodeInfo &x)
|
||||||
{
|
{
|
||||||
x.remarks = nodeRename(x.remarks);
|
x.remarks = nodeRename(x.remarks, ext.rename_array);
|
||||||
if(ext.remove_emoji)
|
if(ext.remove_emoji)
|
||||||
x.remarks = trim(removeEmoji(x.remarks));
|
x.remarks = trim(removeEmoji(x.remarks));
|
||||||
|
|
||||||
if(ext.add_emoji)
|
if(ext.add_emoji)
|
||||||
x.remarks = addEmoji(x.remarks);
|
x.remarks = addEmoji(x.remarks, ext.emoji_array);
|
||||||
});
|
});
|
||||||
|
|
||||||
if(ext.sort_flag)
|
if(ext.sort_flag)
|
||||||
@ -1537,7 +1526,6 @@ std::string netchToMellow(std::vector<nodeInfo> &nodes, std::string &base_conf,
|
|||||||
|
|
||||||
void netchToMellow(std::vector<nodeInfo> &nodes, INIReader &ini, std::vector<ruleset_content> &ruleset_content_array, string_array &extra_proxy_group, extra_settings &ext)
|
void netchToMellow(std::vector<nodeInfo> &nodes, INIReader &ini, std::vector<ruleset_content> &ruleset_content_array, string_array &extra_proxy_group, extra_settings &ext)
|
||||||
{
|
{
|
||||||
try_config_lock();
|
|
||||||
rapidjson::Document json;
|
rapidjson::Document json;
|
||||||
std::string proxy;
|
std::string proxy;
|
||||||
std::string type, remark, hostname, port, username, password, method;
|
std::string type, remark, hostname, port, username, password, method;
|
||||||
@ -1551,12 +1539,12 @@ void netchToMellow(std::vector<nodeInfo> &nodes, INIReader &ini, std::vector<rul
|
|||||||
|
|
||||||
std::for_each(nodes.begin(), nodes.end(), [ext](nodeInfo &x)
|
std::for_each(nodes.begin(), nodes.end(), [ext](nodeInfo &x)
|
||||||
{
|
{
|
||||||
x.remarks = nodeRename(x.remarks);
|
x.remarks = nodeRename(x.remarks, ext.rename_array);
|
||||||
if(ext.remove_emoji)
|
if(ext.remove_emoji)
|
||||||
x.remarks = trim(removeEmoji(x.remarks));
|
x.remarks = trim(removeEmoji(x.remarks));
|
||||||
|
|
||||||
if(ext.add_emoji)
|
if(ext.add_emoji)
|
||||||
x.remarks = addEmoji(x.remarks);
|
x.remarks = addEmoji(x.remarks, ext.emoji_array);
|
||||||
});
|
});
|
||||||
|
|
||||||
if(ext.sort_flag)
|
if(ext.sort_flag)
|
||||||
@ -1687,7 +1675,7 @@ void netchToMellow(std::vector<nodeInfo> &nodes, INIReader &ini, std::vector<rul
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(ext.enable_rule_generator)
|
if(ext.enable_rule_generator)
|
||||||
rulesetToSurge(ini, ruleset_content_array, 2);
|
rulesetToSurge(ini, ruleset_content_array, 2, ext.overwrite_original_rules);
|
||||||
ini.RenameSection("Rule", "RoutingRule");
|
ini.RenameSection("Rule", "RoutingRule");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,6 +13,9 @@ struct ruleset_content
|
|||||||
struct extra_settings
|
struct extra_settings
|
||||||
{
|
{
|
||||||
bool enable_rule_generator = true;
|
bool enable_rule_generator = true;
|
||||||
|
bool overwrite_original_rules = true;
|
||||||
|
string_array rename_array;
|
||||||
|
string_array emoji_array;
|
||||||
bool add_emoji = false;
|
bool add_emoji = false;
|
||||||
bool remove_emoji = false;
|
bool remove_emoji = false;
|
||||||
bool append_proxy_type = false;
|
bool append_proxy_type = false;
|
||||||
@ -25,8 +28,8 @@ struct extra_settings
|
|||||||
std::string surge_ssr_path;
|
std::string surge_ssr_path;
|
||||||
};
|
};
|
||||||
|
|
||||||
void rulesetToClash(YAML::Node &base_rule, std::vector<ruleset_content> &ruleset_content_array);
|
void rulesetToClash(YAML::Node &base_rule, std::vector<ruleset_content> &ruleset_content_array, bool overwrite_original_rules);
|
||||||
void rulesetToSurge(INIReader &base_rule, std::vector<ruleset_content> &ruleset_content_array, int surge_ver);
|
void rulesetToSurge(INIReader &base_rule, std::vector<ruleset_content> &ruleset_content_array, int surge_ver, bool overwrite_original_rules);
|
||||||
std::string netchToClash(std::vector<nodeInfo> &nodes, std::string &base_conf, std::vector<ruleset_content> &ruleset_content_array, string_array &extra_proxy_group, bool clashR, extra_settings &ext);
|
std::string netchToClash(std::vector<nodeInfo> &nodes, std::string &base_conf, std::vector<ruleset_content> &ruleset_content_array, string_array &extra_proxy_group, bool clashR, extra_settings &ext);
|
||||||
void netchToClash(std::vector<nodeInfo> &nodes, YAML::Node &base, string_array &extra_proxy_group, bool clashR, extra_settings &ext);
|
void netchToClash(std::vector<nodeInfo> &nodes, YAML::Node &base, string_array &extra_proxy_group, bool clashR, extra_settings &ext);
|
||||||
std::string netchToSurge(std::vector<nodeInfo> &nodes, std::string &base_conf, std::vector<ruleset_content> &ruleset_content_array, string_array &extra_proxy_group, int surge_ver, extra_settings &ext);
|
std::string netchToSurge(std::vector<nodeInfo> &nodes, std::string &base_conf, std::vector<ruleset_content> &ruleset_content_array, string_array &extra_proxy_group, int surge_ver, extra_settings &ext);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user