mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2026-11-03 02:02:24 +00:00
Fix cache system not working properly
Clean up codes.
This commit is contained in:
18 files changed
+1661
-1667
No files matched your search
@@ -3,6 +3,7 @@
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
#include "../../handler/settings.h"
|
||||
#include "../../handler/webget.h"
|
||||
#include "../../parser/config/proxy.h"
|
||||
#include "../../parser/infoparser.h"
|
||||
@@ -17,10 +18,7 @@
|
||||
#include "nodemanip.h"
|
||||
#include "subexport.h"
|
||||
|
||||
std::string override_conf_port;
|
||||
bool ss_libev, ssr_libev;
|
||||
extern int gCacheSubscription;
|
||||
extern bool gScriptCleanContext;
|
||||
extern Settings global;
|
||||
|
||||
int explodeConf(const std::string &filepath, std::vector<Proxy> &nodes)
|
||||
{
|
||||
@@ -39,7 +37,7 @@ int addNodes(std::string link, std::vector<Proxy> &allNodes, int groupID, parse_
|
||||
string_array &include_remarks = *parse_set.include_remarks;
|
||||
RegexMatchConfigs &stream_rules = *parse_set.stream_rules;
|
||||
RegexMatchConfigs &time_rules = *parse_set.time_rules;
|
||||
string_icase_map &request_headers = *parse_set.request_header;
|
||||
string_icase_map *request_headers = parse_set.request_header;
|
||||
bool &authorized = parse_set.authorized;
|
||||
|
||||
ConfType linkType = ConfType::Unknow;
|
||||
@@ -88,7 +86,7 @@ int addNodes(std::string link, std::vector<Proxy> &allNodes, int groupID, parse_
|
||||
}
|
||||
}
|
||||
}
|
||||
}, gScriptCleanContext);
|
||||
}, global.scriptCleanContext);
|
||||
/*
|
||||
duk_context *ctx = duktape_init();
|
||||
defer(duk_destroy_heap(ctx);)
|
||||
@@ -142,7 +140,7 @@ int addNodes(std::string link, std::vector<Proxy> &allNodes, int groupID, parse_
|
||||
writeLog(LOG_TYPE_INFO, "Downloading subscription data...");
|
||||
if(startsWith(link, "surge:///install-config")) //surge config link
|
||||
link = urlDecode(getUrlArg(link, "url"));
|
||||
strSub = webGet(link, proxy, gCacheSubscription, &extra_headers, &request_headers);
|
||||
strSub = webGet(link, proxy, global.cacheSubscription, &extra_headers, request_headers);
|
||||
/*
|
||||
if(strSub.size() == 0)
|
||||
{
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
#include <string>
|
||||
|
||||
#include "../../handler/settings.h"
|
||||
#include "../../utils/logger.h"
|
||||
#include "../../utils/network.h"
|
||||
#include "../../utils/regexp.h"
|
||||
#include "../../utils/string.h"
|
||||
#include "subexport.h"
|
||||
|
||||
extern size_t gMaxAllowedRules;
|
||||
|
||||
/// 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", "PROCESS-NAME"};
|
||||
@@ -95,7 +94,7 @@ std::string convertRuleset(const std::string &content, int type)
|
||||
}
|
||||
|
||||
|
||||
void rulesetToClash(YAML::Node &base_rule, std::vector<ruleset_content> &ruleset_content_array, bool overwrite_original_rules, bool new_field_name)
|
||||
void rulesetToClash(YAML::Node &base_rule, std::vector<RulesetContent> &ruleset_content_array, bool overwrite_original_rules, bool new_field_name)
|
||||
{
|
||||
string_array allRules;
|
||||
std::string rule_group, retrieved_rules, strLine;
|
||||
@@ -107,9 +106,9 @@ void rulesetToClash(YAML::Node &base_rule, std::vector<ruleset_content> &ruleset
|
||||
if(!overwrite_original_rules && base_rule[field_name].IsDefined())
|
||||
Rules = base_rule[field_name];
|
||||
|
||||
for(ruleset_content &x : ruleset_content_array)
|
||||
for(RulesetContent &x : ruleset_content_array)
|
||||
{
|
||||
if(gMaxAllowedRules && total_rules > gMaxAllowedRules)
|
||||
if(global.maxAllowedRules && total_rules > global.maxAllowedRules)
|
||||
break;
|
||||
rule_group = x.rule_group;
|
||||
retrieved_rules = x.rule_content.get();
|
||||
@@ -138,7 +137,7 @@ void rulesetToClash(YAML::Node &base_rule, std::vector<ruleset_content> &ruleset
|
||||
std::string::size_type lineSize;
|
||||
while(getline(strStrm, strLine, delimiter))
|
||||
{
|
||||
if(gMaxAllowedRules && total_rules > gMaxAllowedRules)
|
||||
if(global.maxAllowedRules && total_rules > global.maxAllowedRules)
|
||||
break;
|
||||
strLine = trimWhitespace(strLine, true, true); //remove whitespaces
|
||||
lineSize = strLine.size();
|
||||
@@ -167,7 +166,7 @@ void rulesetToClash(YAML::Node &base_rule, std::vector<ruleset_content> &ruleset
|
||||
base_rule[field_name] = Rules;
|
||||
}
|
||||
|
||||
std::string rulesetToClashStr(YAML::Node &base_rule, std::vector<ruleset_content> &ruleset_content_array, bool overwrite_original_rules, bool new_field_name)
|
||||
std::string rulesetToClashStr(YAML::Node &base_rule, std::vector<RulesetContent> &ruleset_content_array, bool overwrite_original_rules, bool new_field_name)
|
||||
{
|
||||
std::string rule_group, retrieved_rules, strLine;
|
||||
std::stringstream strStrm;
|
||||
@@ -182,9 +181,9 @@ std::string rulesetToClashStr(YAML::Node &base_rule, std::vector<ruleset_content
|
||||
}
|
||||
base_rule.remove(field_name);
|
||||
|
||||
for(ruleset_content &x : ruleset_content_array)
|
||||
for(RulesetContent &x : ruleset_content_array)
|
||||
{
|
||||
if(gMaxAllowedRules && total_rules > gMaxAllowedRules)
|
||||
if(global.maxAllowedRules && total_rules > global.maxAllowedRules)
|
||||
break;
|
||||
rule_group = x.rule_group;
|
||||
retrieved_rules = x.rule_content.get();
|
||||
@@ -213,7 +212,7 @@ std::string rulesetToClashStr(YAML::Node &base_rule, std::vector<ruleset_content
|
||||
std::string::size_type lineSize;
|
||||
while(getline(strStrm, strLine, delimiter))
|
||||
{
|
||||
if(gMaxAllowedRules && total_rules > gMaxAllowedRules)
|
||||
if(global.maxAllowedRules && total_rules > global.maxAllowedRules)
|
||||
break;
|
||||
strLine = trimWhitespace(strLine, true, true); //remove whitespaces
|
||||
lineSize = strLine.size();
|
||||
@@ -236,7 +235,7 @@ std::string rulesetToClashStr(YAML::Node &base_rule, std::vector<ruleset_content
|
||||
return output_content;
|
||||
}
|
||||
|
||||
void rulesetToSurge(INIReader &base_rule, std::vector<ruleset_content> &ruleset_content_array, int surge_ver, bool overwrite_original_rules, std::string remote_path_prefix)
|
||||
void rulesetToSurge(INIReader &base_rule, std::vector<RulesetContent> &ruleset_content_array, int surge_ver, bool overwrite_original_rules, std::string remote_path_prefix)
|
||||
{
|
||||
string_array allRules;
|
||||
std::string rule_group, rule_path, rule_path_typed, retrieved_rules, strLine;
|
||||
@@ -274,9 +273,9 @@ void rulesetToSurge(INIReader &base_rule, std::vector<ruleset_content> &ruleset_
|
||||
|
||||
const std::string rule_match_regex = "^(.*?,.*?)(,.*)(,.*)$";
|
||||
|
||||
for(ruleset_content &x : ruleset_content_array)
|
||||
for(RulesetContent &x : ruleset_content_array)
|
||||
{
|
||||
if(gMaxAllowedRules && total_rules > gMaxAllowedRules)
|
||||
if(global.maxAllowedRules && total_rules > global.maxAllowedRules)
|
||||
break;
|
||||
rule_group = x.rule_group;
|
||||
rule_path = x.rule_path;
|
||||
@@ -387,7 +386,7 @@ void rulesetToSurge(INIReader &base_rule, std::vector<ruleset_content> &ruleset_
|
||||
std::string::size_type lineSize;
|
||||
while(getline(strStrm, strLine, delimiter))
|
||||
{
|
||||
if(gMaxAllowedRules && total_rules > gMaxAllowedRules)
|
||||
if(global.maxAllowedRules && total_rules > global.maxAllowedRules)
|
||||
break;
|
||||
strLine = trimWhitespace(strLine, true, true);
|
||||
lineSize = strLine.size();
|
||||
|
||||
@@ -18,7 +18,7 @@ enum ruleset_type
|
||||
RULESET_CLASH_CLASSICAL
|
||||
};
|
||||
|
||||
struct ruleset_content
|
||||
struct RulesetContent
|
||||
{
|
||||
std::string rule_group;
|
||||
std::string rule_path;
|
||||
@@ -29,8 +29,8 @@ struct ruleset_content
|
||||
};
|
||||
|
||||
std::string convertRuleset(const std::string &content, int type);
|
||||
void rulesetToClash(YAML::Node &base_rule, std::vector<ruleset_content> &ruleset_content_array, bool overwrite_original_rules, bool new_field_name);
|
||||
std::string rulesetToClashStr(YAML::Node &base_rule, std::vector<ruleset_content> &ruleset_content_array, bool overwrite_original_rules, bool new_field_name);
|
||||
void rulesetToSurge(INIReader &base_rule, std::vector<ruleset_content> &ruleset_content_array, int surge_ver, bool overwrite_original_rules, std::string remote_path_prefix);
|
||||
void rulesetToClash(YAML::Node &base_rule, std::vector<RulesetContent> &ruleset_content_array, bool overwrite_original_rules, bool new_field_name);
|
||||
std::string rulesetToClashStr(YAML::Node &base_rule, std::vector<RulesetContent> &ruleset_content_array, bool overwrite_original_rules, bool new_field_name);
|
||||
void rulesetToSurge(INIReader &base_rule, std::vector<RulesetContent> &ruleset_content_array, int surge_ver, bool overwrite_original_rules, std::string remote_path_prefix);
|
||||
|
||||
#endif // RULECONVERT_H_INCLUDED
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "../../config/regmatch.h"
|
||||
#include "../../generator/config/subexport.h"
|
||||
#include "../../generator/template/templates.h"
|
||||
#include "../../handler/settings.h"
|
||||
#include "../../parser/config/proxy.h"
|
||||
#include "../../script/script_quickjs.h"
|
||||
#include "../../utils/bitwise.h"
|
||||
@@ -26,7 +27,6 @@
|
||||
#include "nodemanip.h"
|
||||
#include "ruleconvert.h"
|
||||
|
||||
extern bool gAPIMode, gSurgeResolveHostname, gScriptCleanContext;
|
||||
extern string_array ss_ciphers, ssr_ciphers;
|
||||
|
||||
const string_array clashr_protocols = {"origin", "auth_sha1_v4", "auth_aes128_md5", "auth_aes128_sha1", "auth_chain_a", "auth_chain_b"};
|
||||
@@ -89,7 +89,7 @@ void nodeRename(Proxy &node, const RegexMatchConfigs &rename_array, extra_settin
|
||||
{
|
||||
script_print_stack(ctx);
|
||||
}
|
||||
}, gScriptCleanContext);
|
||||
}, global.scriptCleanContext);
|
||||
continue;
|
||||
}
|
||||
if(applyMatcher(x.Match, real_rule, node) && real_rule.size())
|
||||
@@ -142,7 +142,7 @@ std::string addEmoji(const Proxy &node, const RegexMatchConfigs &emoji_array, ex
|
||||
{
|
||||
script_print_stack(ctx);
|
||||
}
|
||||
}, gScriptCleanContext);
|
||||
}, global.scriptCleanContext);
|
||||
if(!result.empty())
|
||||
return result;
|
||||
continue;
|
||||
@@ -175,28 +175,6 @@ void processRemark(std::string &oldremark, std::string &newremark, string_array
|
||||
oldremark = newremark;
|
||||
}
|
||||
|
||||
void parseGroupTimes(const std::string &src, int *interval, int *tolerance, int *timeout)
|
||||
{
|
||||
std::vector<int*> ptrs;
|
||||
ptrs.push_back(interval);
|
||||
ptrs.push_back(timeout);
|
||||
ptrs.push_back(tolerance);
|
||||
string_size bpos = 0, epos = src.find(",");
|
||||
for(int *x : ptrs)
|
||||
{
|
||||
if(x != NULL)
|
||||
*x = to_int(src.substr(bpos, epos - bpos), 0);
|
||||
if(epos != src.npos)
|
||||
{
|
||||
bpos = epos + 1;
|
||||
epos = src.find(",", bpos);
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void groupGenerate(const std::string &rule, std::vector<Proxy> &nodelist, string_array &filtered_nodelist, bool add_direct, extra_settings &ext)
|
||||
{
|
||||
std::string real_rule;
|
||||
@@ -219,7 +197,7 @@ void groupGenerate(const std::string &rule, std::vector<Proxy> &nodelist, string
|
||||
{
|
||||
script_print_stack(ctx);
|
||||
}
|
||||
}, gScriptCleanContext);
|
||||
}, global.scriptCleanContext);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -273,7 +251,7 @@ void preprocessNodes(std::vector<Proxy> &nodes, extra_settings &ext)
|
||||
{
|
||||
script_print_stack(ctx);
|
||||
}
|
||||
}, gScriptCleanContext);
|
||||
}, global.scriptCleanContext);
|
||||
}
|
||||
if(failed) std::stable_sort(nodes.begin(), nodes.end(), [](const Proxy &a, const Proxy &b)
|
||||
{
|
||||
@@ -592,7 +570,7 @@ void proxyToClash(std::vector<Proxy> &nodes, YAML::Node &yamlnode, const ProxyGr
|
||||
yamlnode["Proxy Group"] = original_groups;
|
||||
}
|
||||
|
||||
std::string proxyToClash(std::vector<Proxy> &nodes, const std::string &base_conf, std::vector<ruleset_content> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, bool clashR, extra_settings &ext)
|
||||
std::string proxyToClash(std::vector<Proxy> &nodes, const std::string &base_conf, std::vector<RulesetContent> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, bool clashR, extra_settings &ext)
|
||||
{
|
||||
YAML::Node yamlnode;
|
||||
|
||||
@@ -640,7 +618,7 @@ std::string proxyToClash(std::vector<Proxy> &nodes, const std::string &base_conf
|
||||
return output_content;
|
||||
}
|
||||
|
||||
std::string proxyToSurge(std::vector<Proxy> &nodes, const std::string &base_conf, std::vector<ruleset_content> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, int surge_ver, extra_settings &ext)
|
||||
std::string proxyToSurge(std::vector<Proxy> &nodes, const std::string &base_conf, std::vector<RulesetContent> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, int surge_ver, extra_settings &ext)
|
||||
{
|
||||
INIReader ini;
|
||||
std::string proxy;
|
||||
@@ -762,7 +740,7 @@ std::string proxyToSurge(std::vector<Proxy> &nodes, const std::string &base_conf
|
||||
proxy += "\", local-port=" + std::to_string(local_port);
|
||||
if(isIPv4(hostname) || isIPv6(hostname))
|
||||
proxy += ", addresses=" + hostname;
|
||||
else if(gSurgeResolveHostname)
|
||||
else if(global.surgeResolveHostname)
|
||||
proxy += ", addresses=" + hostnameToIPAddr(hostname);
|
||||
local_port++;
|
||||
break;
|
||||
@@ -1041,7 +1019,7 @@ std::string proxyToSSSub(std::string base_conf, std::vector<Proxy> &nodes, extra
|
||||
return output_content;
|
||||
}
|
||||
|
||||
std::string proxyToQuan(std::vector<Proxy> &nodes, const std::string &base_conf, std::vector<ruleset_content> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, extra_settings &ext)
|
||||
std::string proxyToQuan(std::vector<Proxy> &nodes, const std::string &base_conf, std::vector<RulesetContent> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, extra_settings &ext)
|
||||
{
|
||||
INIReader ini;
|
||||
ini.store_any_line = true;
|
||||
@@ -1065,7 +1043,7 @@ std::string proxyToQuan(std::vector<Proxy> &nodes, const std::string &base_conf,
|
||||
return ini.ToString();
|
||||
}
|
||||
|
||||
void proxyToQuan(std::vector<Proxy> &nodes, INIReader &ini, std::vector<ruleset_content> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, extra_settings &ext)
|
||||
void proxyToQuan(std::vector<Proxy> &nodes, INIReader &ini, std::vector<RulesetContent> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, extra_settings &ext)
|
||||
{
|
||||
std::string type, proxyStr;
|
||||
tribool scv;
|
||||
@@ -1268,7 +1246,7 @@ void proxyToQuan(std::vector<Proxy> &nodes, INIReader &ini, std::vector<ruleset_
|
||||
rulesetToSurge(ini, ruleset_content_array, -2, ext.overwrite_original_rules, std::string());
|
||||
}
|
||||
|
||||
std::string proxyToQuanX(std::vector<Proxy> &nodes, const std::string &base_conf, std::vector<ruleset_content> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, extra_settings &ext)
|
||||
std::string proxyToQuanX(std::vector<Proxy> &nodes, const std::string &base_conf, std::vector<RulesetContent> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, extra_settings &ext)
|
||||
{
|
||||
INIReader ini;
|
||||
ini.store_any_line = true;
|
||||
@@ -1299,7 +1277,7 @@ std::string proxyToQuanX(std::vector<Proxy> &nodes, const std::string &base_conf
|
||||
return ini.ToString();
|
||||
}
|
||||
|
||||
void proxyToQuanX(std::vector<Proxy> &nodes, INIReader &ini, std::vector<ruleset_content> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, extra_settings &ext)
|
||||
void proxyToQuanX(std::vector<Proxy> &nodes, INIReader &ini, std::vector<RulesetContent> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, extra_settings &ext)
|
||||
{
|
||||
std::string type;
|
||||
std::string remark, hostname, port, method;
|
||||
@@ -1661,7 +1639,7 @@ std::string proxyToSSD(std::vector<Proxy> &nodes, std::string &group, std::strin
|
||||
return "ssd://" + base64Encode(sb.GetString());
|
||||
}
|
||||
|
||||
std::string proxyToMellow(std::vector<Proxy> &nodes, const std::string &base_conf, std::vector<ruleset_content> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, extra_settings &ext)
|
||||
std::string proxyToMellow(std::vector<Proxy> &nodes, const std::string &base_conf, std::vector<RulesetContent> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, extra_settings &ext)
|
||||
{
|
||||
INIReader ini;
|
||||
ini.store_any_line = true;
|
||||
@@ -1676,7 +1654,7 @@ std::string proxyToMellow(std::vector<Proxy> &nodes, const std::string &base_con
|
||||
return ini.ToString();
|
||||
}
|
||||
|
||||
void proxyToMellow(std::vector<Proxy> &nodes, INIReader &ini, std::vector<ruleset_content> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, extra_settings &ext)
|
||||
void proxyToMellow(std::vector<Proxy> &nodes, INIReader &ini, std::vector<RulesetContent> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, extra_settings &ext)
|
||||
{
|
||||
std::string proxy;
|
||||
std::string type, remark, hostname, port, username, password, method;
|
||||
@@ -1818,7 +1796,7 @@ void proxyToMellow(std::vector<Proxy> &nodes, INIReader &ini, std::vector<rulese
|
||||
rulesetToSurge(ini, ruleset_content_array, 0, ext.overwrite_original_rules, std::string());
|
||||
}
|
||||
|
||||
std::string proxyToLoon(std::vector<Proxy> &nodes, const std::string &base_conf, std::vector<ruleset_content> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, extra_settings &ext)
|
||||
std::string proxyToLoon(std::vector<Proxy> &nodes, const std::string &base_conf, std::vector<RulesetContent> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, extra_settings &ext)
|
||||
{
|
||||
rapidjson::Document json;
|
||||
INIReader ini;
|
||||
|
||||
@@ -50,22 +50,22 @@ struct extra_settings
|
||||
}
|
||||
};
|
||||
|
||||
void rulesetToClash(YAML::Node &base_rule, std::vector<ruleset_content> &ruleset_content_array, bool overwrite_original_rules, bool new_field_name);
|
||||
void rulesetToSurge(INIReader &base_rule, std::vector<ruleset_content> &ruleset_content_array, int surge_ver, bool overwrite_original_rules, std::string remote_path_prefix);
|
||||
void rulesetToClash(YAML::Node &base_rule, std::vector<RulesetContent> &ruleset_content_array, bool overwrite_original_rules, bool new_field_name);
|
||||
void rulesetToSurge(INIReader &base_rule, std::vector<RulesetContent> &ruleset_content_array, int surge_ver, bool overwrite_original_rules, std::string remote_path_prefix);
|
||||
void preprocessNodes(std::vector<Proxy> &nodes, extra_settings &ext);
|
||||
|
||||
std::string proxyToClash(std::vector<Proxy> &nodes, const std::string &base_conf, std::vector<ruleset_content> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, bool clashR, extra_settings &ext);
|
||||
std::string proxyToClash(std::vector<Proxy> &nodes, const std::string &base_conf, std::vector<RulesetContent> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, bool clashR, extra_settings &ext);
|
||||
void proxyToClash(std::vector<Proxy> &nodes, YAML::Node &yamlnode, const ProxyGroupConfigs &extra_proxy_group, bool clashR, extra_settings &ext);
|
||||
std::string proxyToSurge(std::vector<Proxy> &nodes, const std::string &base_conf, std::vector<ruleset_content> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, int surge_ver, extra_settings &ext);
|
||||
std::string proxyToMellow(std::vector<Proxy> &nodes, const std::string &base_conf, std::vector<ruleset_content> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, extra_settings &ext);
|
||||
void proxyToMellow(std::vector<Proxy> &nodes, INIReader &ini, std::vector<ruleset_content> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, extra_settings &ext);
|
||||
std::string proxyToLoon(std::vector<Proxy> &nodes, const std::string &base_conf, std::vector<ruleset_content> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, extra_settings &ext);
|
||||
std::string proxyToSurge(std::vector<Proxy> &nodes, const std::string &base_conf, std::vector<RulesetContent> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, int surge_ver, extra_settings &ext);
|
||||
std::string proxyToMellow(std::vector<Proxy> &nodes, const std::string &base_conf, std::vector<RulesetContent> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, extra_settings &ext);
|
||||
void proxyToMellow(std::vector<Proxy> &nodes, INIReader &ini, std::vector<RulesetContent> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, extra_settings &ext);
|
||||
std::string proxyToLoon(std::vector<Proxy> &nodes, const std::string &base_conf, std::vector<RulesetContent> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, extra_settings &ext);
|
||||
std::string proxyToSSSub(std::string base_conf, std::vector<Proxy> &nodes, extra_settings &ext);
|
||||
std::string proxyToSingle(std::vector<Proxy> &nodes, int types, extra_settings &ext);
|
||||
std::string proxyToQuanX(std::vector<Proxy> &nodes, const std::string &base_conf, std::vector<ruleset_content> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, extra_settings &ext);
|
||||
void proxyToQuanX(std::vector<Proxy> &nodes, INIReader &ini, std::vector<ruleset_content> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, extra_settings &ext);
|
||||
std::string proxyToQuan(std::vector<Proxy> &nodes, const std::string &base_conf, std::vector<ruleset_content> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, extra_settings &ext);
|
||||
void proxyToQuan(std::vector<Proxy> &nodes, INIReader &ini, std::vector<ruleset_content> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, extra_settings &ext);
|
||||
std::string proxyToQuanX(std::vector<Proxy> &nodes, const std::string &base_conf, std::vector<RulesetContent> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, extra_settings &ext);
|
||||
void proxyToQuanX(std::vector<Proxy> &nodes, INIReader &ini, std::vector<RulesetContent> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, extra_settings &ext);
|
||||
std::string proxyToQuan(std::vector<Proxy> &nodes, const std::string &base_conf, std::vector<RulesetContent> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, extra_settings &ext);
|
||||
void proxyToQuan(std::vector<Proxy> &nodes, INIReader &ini, std::vector<RulesetContent> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group, extra_settings &ext);
|
||||
std::string proxyToSSD(std::vector<Proxy> &nodes, std::string &group, std::string &userinfo, extra_settings &ext);
|
||||
|
||||
#endif // SUBEXPORT_H_INCLUDED
|
||||
@@ -5,16 +5,15 @@
|
||||
#include <inja.hpp>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "../../utils/yamlcpp_extra.h"
|
||||
#include "../../utils/urlencode.h"
|
||||
#include "../../utils/regexp.h"
|
||||
#include "../../handler/interfaces.h"
|
||||
#include "../../handler/settings.h"
|
||||
#include "../../utils/logger.h"
|
||||
#include "../../utils/network.h"
|
||||
#include "../../utils/regexp.h"
|
||||
#include "../../utils/urlencode.h"
|
||||
#include "../../utils/yamlcpp_extra.h"
|
||||
#include "templates.h"
|
||||
|
||||
extern std::string gManagedConfigPrefix;
|
||||
|
||||
namespace inja
|
||||
{
|
||||
void convert_dot_to_json_pointer(nonstd::string_view dot, std::string& out)
|
||||
@@ -139,7 +138,7 @@ int render_template(const std::string &content, const template_args &vars, std::
|
||||
});
|
||||
env.add_callback("getLink", 1, [](inja::Arguments &args)
|
||||
{
|
||||
return gManagedConfigPrefix + args.at(0)->get<std::string>();
|
||||
return global.managedConfigPrefix + args.at(0)->get<std::string>();
|
||||
});
|
||||
env.add_callback("startsWith", 2, [](inja::Arguments &args)
|
||||
{
|
||||
@@ -265,7 +264,7 @@ std::string findFileName(const std::string &path)
|
||||
return path.substr(pos + 1, pos2 - pos - 1);
|
||||
}
|
||||
|
||||
int renderClashScript(YAML::Node &base_rule, std::vector<ruleset_content> &ruleset_content_array, std::string remote_path_prefix, bool script, bool overwrite_original_rules, bool clash_classical_ruleset)
|
||||
int renderClashScript(YAML::Node &base_rule, std::vector<RulesetContent> &ruleset_content_array, std::string remote_path_prefix, bool script, bool overwrite_original_rules, bool clash_classical_ruleset)
|
||||
{
|
||||
nlohmann::json data;
|
||||
std::string match_group, geoips, retrieved_rules;
|
||||
@@ -281,7 +280,7 @@ int renderClashScript(YAML::Node &base_rule, std::vector<ruleset_content> &rules
|
||||
if(!overwrite_original_rules && base_rule["rules"].IsDefined())
|
||||
rules = safe_as<string_array>(base_rule["rules"]);
|
||||
|
||||
for(ruleset_content &x : ruleset_content_array)
|
||||
for(RulesetContent &x : ruleset_content_array)
|
||||
{
|
||||
rule_group = x.rule_group;
|
||||
rule_path = x.rule_path;
|
||||
|
||||
@@ -16,6 +16,6 @@ struct template_args
|
||||
};
|
||||
|
||||
int render_template(const std::string &content, const template_args &vars, std::string &output, const std::string &include_scope = "templates");
|
||||
int renderClashScript(YAML::Node &base_rule, std::vector<ruleset_content> &ruleset_content_array, std::string remote_path_prefix, bool script, bool overwrite_original_rules, bool clash_classic_ruleset);
|
||||
int renderClashScript(YAML::Node &base_rule, std::vector<RulesetContent> &ruleset_content_array, std::string remote_path_prefix, bool script, bool overwrite_original_rules, bool clash_classic_ruleset);
|
||||
|
||||
#endif // TEMPLATES_H_INCLUDED
|
||||
Reference in new issue
Block a user