mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2026-11-03 02:02:24 +00:00
Enhancements
Add include/exclude options for subscriptions. Clean up useless codes.
This commit is contained in:
7 files changed
+53
-153
No files matched your search
@@ -209,17 +209,17 @@ void readConf()
|
|||||||
if(ini.ItemExist("max_concurrent_threads"))
|
if(ini.ItemExist("max_concurrent_threads"))
|
||||||
max_concurrent_threads = ini.GetInt("max_concurrent_threads");
|
max_concurrent_threads = ini.GetInt("max_concurrent_threads");
|
||||||
|
|
||||||
remarksInit(def_exclude_remarks, def_include_remarks);
|
|
||||||
std::cerr<<"Read preference settings completed."<<std::endl;
|
std::cerr<<"Read preference settings completed."<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string subconverter(RESPONSE_CALLBACK_ARGS)
|
std::string subconverter(RESPONSE_CALLBACK_ARGS)
|
||||||
{
|
{
|
||||||
std::string target = getUrlArg(argument, "target"), url = UrlDecode(getUrlArg(argument, "url")), include = UrlDecode(getUrlArg(argument, "regex")), emoji = getUrlArg(argument, "emoji");
|
std::string target = getUrlArg(argument, "target"), url = UrlDecode(getUrlArg(argument, "url")), emoji = getUrlArg(argument, "emoji");
|
||||||
std::string group = UrlDecode(getUrlArg(argument, "group")), upload = getUrlArg(argument, "upload"), upload_path = getUrlArg(argument, "upload_path"), version = getUrlArg(argument, "ver");
|
std::string group = UrlDecode(getUrlArg(argument, "group")), upload = getUrlArg(argument, "upload"), upload_path = getUrlArg(argument, "upload_path"), version = getUrlArg(argument, "ver");
|
||||||
std::string append_type = getUrlArg(argument, "append_type"), tfo = getUrlArg(argument, "tfo"), udp = getUrlArg(argument, "udp"), nodelist = getUrlArg(argument, "list");
|
std::string append_type = getUrlArg(argument, "append_type"), tfo = getUrlArg(argument, "tfo"), udp = getUrlArg(argument, "udp"), nodelist = getUrlArg(argument, "list");
|
||||||
|
std::string include = UrlDecode(getUrlArg(argument, "include")), exclude = UrlDecode(getUrlArg(argument, "exclude"));
|
||||||
std::string base_content, output_content;
|
std::string base_content, output_content;
|
||||||
string_array extra_group;
|
string_array extra_group, include_remarks, exclude_remarks;
|
||||||
std::string groups = urlsafe_base64_decode(getUrlArg(argument, "groups"));
|
std::string groups = urlsafe_base64_decode(getUrlArg(argument, "groups"));
|
||||||
extra_group = split(groups, "`");
|
extra_group = split(groups, "`");
|
||||||
|
|
||||||
@@ -260,18 +260,23 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS)
|
|||||||
string_array urls = split(url, "|");
|
string_array urls = split(url, "|");
|
||||||
std::vector<nodeInfo> nodes;
|
std::vector<nodeInfo> nodes;
|
||||||
int groupID = 0;
|
int groupID = 0;
|
||||||
|
|
||||||
if(include.size())
|
if(include.size())
|
||||||
{
|
include_remarks.emplace_back(include);
|
||||||
eraseElements(ext.include_remarks);
|
else
|
||||||
ext.include_remarks.emplace_back(include);
|
include_remarks = def_include_remarks;
|
||||||
}
|
if(exclude.size())
|
||||||
|
exclude_remarks.emplace_back(exclude);
|
||||||
|
else
|
||||||
|
exclude_remarks = def_exclude_remarks;
|
||||||
|
|
||||||
if(group.size())
|
if(group.size())
|
||||||
custom_group = group;
|
custom_group = group;
|
||||||
for(std::string &x : urls)
|
for(std::string &x : urls)
|
||||||
{
|
{
|
||||||
x = trim(x);
|
x = trim(x);
|
||||||
std::cerr<<"Fetching node data from url '"<<x<<"'."<<std::endl;
|
std::cerr<<"Fetching node data from url '"<<x<<"'."<<std::endl;
|
||||||
addNodes(x, nodes, groupID, proxy);
|
addNodes(x, nodes, groupID, proxy, exclude_remarks, include_remarks);
|
||||||
groupID++;
|
groupID++;
|
||||||
}
|
}
|
||||||
if(!nodes.size())
|
if(!nodes.size())
|
||||||
|
|||||||
+3
-3
@@ -21,7 +21,7 @@ void copyNodes(std::vector<nodeInfo> *source, std::vector<nodeInfo> *dest)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addNodes(std::string link, std::vector<nodeInfo> &allNodes, int groupID, std::string proxy)
|
void addNodes(std::string link, std::vector<nodeInfo> &allNodes, int groupID, std::string proxy, string_array &exclude_remarks, string_array &include_remarks)
|
||||||
{
|
{
|
||||||
int linkType = -1;
|
int linkType = -1;
|
||||||
std::vector<nodeInfo> nodes;
|
std::vector<nodeInfo> nodes;
|
||||||
@@ -69,7 +69,7 @@ void addNodes(std::string link, std::vector<nodeInfo> &allNodes, int groupID, st
|
|||||||
if(strSub.size())
|
if(strSub.size())
|
||||||
{
|
{
|
||||||
writeLog(LOG_TYPE_INFO, "Parsing subscription data...");
|
writeLog(LOG_TYPE_INFO, "Parsing subscription data...");
|
||||||
explodeConfContent(strSub, override_conf_port, socksport, ss_libev, ssr_libev, nodes);
|
explodeConfContent(strSub, override_conf_port, socksport, ss_libev, ssr_libev, nodes, exclude_remarks, include_remarks);
|
||||||
for(nodeInfo &x : nodes)
|
for(nodeInfo &x : nodes)
|
||||||
x.groupID = groupID;
|
x.groupID = groupID;
|
||||||
copyNodes(&nodes, &allNodes);
|
copyNodes(&nodes, &allNodes);
|
||||||
@@ -83,7 +83,7 @@ void addNodes(std::string link, std::vector<nodeInfo> &allNodes, int groupID, st
|
|||||||
if(api_mode)
|
if(api_mode)
|
||||||
break;
|
break;
|
||||||
writeLog(LOG_TYPE_INFO, "Parsing configuration file data...");
|
writeLog(LOG_TYPE_INFO, "Parsing configuration file data...");
|
||||||
if(explodeConf(link, override_conf_port, socksport, ss_libev, ssr_libev, nodes) == SPEEDTEST_ERROR_UNRECOGFILE)
|
if(explodeConf(link, override_conf_port, socksport, ss_libev, ssr_libev, nodes, exclude_remarks, include_remarks) == SPEEDTEST_ERROR_UNRECOGFILE)
|
||||||
{
|
{
|
||||||
writeLog(LOG_TYPE_ERROR, "Invalid configuration file!");
|
writeLog(LOG_TYPE_ERROR, "Invalid configuration file!");
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -6,6 +6,6 @@
|
|||||||
|
|
||||||
#include "nodeinfo.h"
|
#include "nodeinfo.h"
|
||||||
|
|
||||||
void addNodes(std::string link, std::vector<nodeInfo> &allNodes, int groupID, std::string proxy = "");
|
void addNodes(std::string link, std::vector<nodeInfo> &allNodes, int groupID, std::string proxy, string_array &exclude_remarks, string_array &include_remarks);
|
||||||
|
|
||||||
#endif // NODEMANIP_H_INCLUDED
|
#endif // NODEMANIP_H_INCLUDED
|
||||||
@@ -4,29 +4,3 @@ allow-lan: true
|
|||||||
mode: Rule
|
mode: Rule
|
||||||
log-level: info
|
log-level: info
|
||||||
external-controller: 127.0.0.1:9090
|
external-controller: 127.0.0.1:9090
|
||||||
cfw-bypass:
|
|
||||||
- qq.com
|
|
||||||
- music.163.com
|
|
||||||
- '*.music.126.net'
|
|
||||||
- localhost
|
|
||||||
- 127.*
|
|
||||||
- 10.*
|
|
||||||
- 172.16.*
|
|
||||||
- 172.17.*
|
|
||||||
- 172.18.*
|
|
||||||
- 172.19.*
|
|
||||||
- 172.20.*
|
|
||||||
- 172.21.*
|
|
||||||
- 172.22.*
|
|
||||||
- 172.23.*
|
|
||||||
- 172.24.*
|
|
||||||
- 172.25.*
|
|
||||||
- 172.26.*
|
|
||||||
- 172.27.*
|
|
||||||
- 172.28.*
|
|
||||||
- 172.29.*
|
|
||||||
- 172.30.*
|
|
||||||
- 172.31.*
|
|
||||||
- 192.168.*
|
|
||||||
- <local>
|
|
||||||
cfw-latency-timeout: 5000
|
|
||||||
+32
-109
@@ -15,9 +15,6 @@ using namespace std::__cxx11;
|
|||||||
using namespace rapidjson;
|
using namespace rapidjson;
|
||||||
using namespace YAML;
|
using namespace YAML;
|
||||||
|
|
||||||
string_array exclude_remarks;
|
|
||||||
string_array include_remarks;
|
|
||||||
|
|
||||||
std::string base_ss_win = "{\"version\":\"4.1.6\",\"configs\":[?config?],\"strategy\":null,\"index\":0,\"global\":false,\"enabled\":false,\"shareOverLan\":true,\"isDefault\":false,\"localPort\":?localport?,\"portableMode\":true,\"pacUrl\":null,\"useOnlinePac\":false,\"secureLocalPac\":true,\"availabilityStatistics\":false,\"autoCheckUpdate\":true,\"checkPreRelease\":false,\"isVerboseLogging\":false,\"logViewer\":{\"topMost\":false,\"wrapText\":false,\"toolbarShown\":false,\"Font\":\"Consolas, 8pt\",\"BackgroundColor\":\"Black\",\"TextColor\":\"White\"},\"proxy\":{\"useProxy\":false,\"proxyType\":0,\"proxyServer\":\"\",\"proxyPort\":0,\"proxyTimeout\":3,\"useAuth\":false,\"authUser\":\"\",\"authPwd\":\"\"},\"hotkey\":{\"SwitchSystemProxy\":\"\",\"SwitchSystemProxyMode\":\"\",\"SwitchAllowLan\":\"\",\"ShowLogs\":\"\",\"ServerMoveUp\":\"\",\"ServerMoveDown\":\"\",\"RegHotkeysAtStartup\":false}}";
|
std::string base_ss_win = "{\"version\":\"4.1.6\",\"configs\":[?config?],\"strategy\":null,\"index\":0,\"global\":false,\"enabled\":false,\"shareOverLan\":true,\"isDefault\":false,\"localPort\":?localport?,\"portableMode\":true,\"pacUrl\":null,\"useOnlinePac\":false,\"secureLocalPac\":true,\"availabilityStatistics\":false,\"autoCheckUpdate\":true,\"checkPreRelease\":false,\"isVerboseLogging\":false,\"logViewer\":{\"topMost\":false,\"wrapText\":false,\"toolbarShown\":false,\"Font\":\"Consolas, 8pt\",\"BackgroundColor\":\"Black\",\"TextColor\":\"White\"},\"proxy\":{\"useProxy\":false,\"proxyType\":0,\"proxyServer\":\"\",\"proxyPort\":0,\"proxyTimeout\":3,\"useAuth\":false,\"authUser\":\"\",\"authPwd\":\"\"},\"hotkey\":{\"SwitchSystemProxy\":\"\",\"SwitchSystemProxyMode\":\"\",\"SwitchAllowLan\":\"\",\"ShowLogs\":\"\",\"ServerMoveUp\":\"\",\"ServerMoveDown\":\"\",\"RegHotkeysAtStartup\":false}}";
|
||||||
std::string config_ss_win = "{\"server\":\"?server?\",\"server_port\":?port?,\"password\":\"?password?\",\"method\":\"?method?\",\"plugin\":\"?plugin?\",\"plugin_opts\":\"?plugin_opts?\",\"plugin_args\":\"\",\"remarks\":\"?remarks?\",\"timeout\":5}";
|
std::string config_ss_win = "{\"server\":\"?server?\",\"server_port\":?port?,\"password\":\"?password?\",\"method\":\"?method?\",\"plugin\":\"?plugin?\",\"plugin_opts\":\"?plugin_opts?\",\"plugin_args\":\"\",\"remarks\":\"?remarks?\",\"timeout\":5}";
|
||||||
std::string config_ss_libev = "{\"server\":\"?server?\",\"server_port\":?port?,\"password\":\"?password?\",\"method\":\"?method?\",\"plugin\":\"?plugin?\",\"plugin_opts\":\"?plugin_opts?\",\"plugin_args\":\"\",\"local_address\":\"127.0.0.1\",\"local_port\":?localport?}";
|
std::string config_ss_libev = "{\"server\":\"?server?\",\"server_port\":?port?,\"password\":\"?password?\",\"method\":\"?method?\",\"plugin\":\"?plugin?\",\"plugin_opts\":\"?plugin_opts?\",\"plugin_args\":\"\",\"local_address\":\"127.0.0.1\",\"local_port\":?localport?}";
|
||||||
@@ -321,15 +318,6 @@ void explodeVmessConf(std::string content, std::string custom_port, int local_po
|
|||||||
|
|
||||||
node.group = group;
|
node.group = group;
|
||||||
node.remarks = ps;
|
node.remarks = ps;
|
||||||
|
|
||||||
if(chkIgnore(node))
|
|
||||||
{
|
|
||||||
writeLog(LOG_TYPE_INFO, "Node " + node.group + " - " + node.remarks + " has been ignored and will not be tested.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
writeLog(LOG_TYPE_INFO, "Node " + node.group + " - " + node.remarks + " has been added.");
|
|
||||||
|
|
||||||
node.id = index;
|
node.id = index;
|
||||||
node.server = add;
|
node.server = add;
|
||||||
node.port = stoi(port);
|
node.port = stoi(port);
|
||||||
@@ -427,15 +415,6 @@ void explodeSSD(std::string link, bool libev, std::string custom_port, int local
|
|||||||
node.linkType = SPEEDTEST_MESSAGE_FOUNDSS;
|
node.linkType = SPEEDTEST_MESSAGE_FOUNDSS;
|
||||||
node.group = group;
|
node.group = group;
|
||||||
node.remarks = remarks;
|
node.remarks = remarks;
|
||||||
|
|
||||||
if(chkIgnore(node))
|
|
||||||
{
|
|
||||||
writeLog(LOG_TYPE_INFO, "Node " + node.group + " - " + node.remarks + " has been ignored and will not be tested.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
writeLog(LOG_TYPE_INFO, "Node " + node.group + " - " + node.remarks + " has been added.");
|
|
||||||
|
|
||||||
node.server = server;
|
node.server = server;
|
||||||
node.port = stoi(port);
|
node.port = stoi(port);
|
||||||
node.proxyStr = ssConstruct(server, port, password, method, plugin, pluginopts, remarks, local_port, libev);
|
node.proxyStr = ssConstruct(server, port, password, method, plugin, pluginopts, remarks, local_port, libev);
|
||||||
@@ -475,15 +454,6 @@ void explodeSSAndroid(std::string ss, bool libev, std::string custom_port, int l
|
|||||||
node.id = index;
|
node.id = index;
|
||||||
node.group = group;
|
node.group = group;
|
||||||
node.remarks = ps;
|
node.remarks = ps;
|
||||||
|
|
||||||
if(chkIgnore(node))
|
|
||||||
{
|
|
||||||
writeLog(LOG_TYPE_INFO, "Node " + node.group + " - " + node.remarks + " has been ignored and will not be tested.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
writeLog(LOG_TYPE_INFO, "Node " + node.group + " - " + node.remarks + " has been added.");
|
|
||||||
|
|
||||||
node.server = server;
|
node.server = server;
|
||||||
node.port = stoi(port);
|
node.port = stoi(port);
|
||||||
node.proxyStr = ssConstruct(server, port, password, method, "", "", ps, local_port, libev);
|
node.proxyStr = ssConstruct(server, port, password, method, "", "", ps, local_port, libev);
|
||||||
@@ -538,15 +508,6 @@ void explodeSSConf(std::string content, std::string custom_port, int local_port,
|
|||||||
node.linkType = SPEEDTEST_MESSAGE_FOUNDSS;
|
node.linkType = SPEEDTEST_MESSAGE_FOUNDSS;
|
||||||
node.group = group;
|
node.group = group;
|
||||||
node.remarks = ps;
|
node.remarks = ps;
|
||||||
|
|
||||||
if(chkIgnore(node))
|
|
||||||
{
|
|
||||||
writeLog(LOG_TYPE_INFO, "Node " + node.group + " - " + node.remarks + " has been ignored and will not be tested.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
writeLog(LOG_TYPE_INFO, "Node " + node.group + " - " + node.remarks + " has been added.");
|
|
||||||
|
|
||||||
node.id = index;
|
node.id = index;
|
||||||
node.server = server;
|
node.server = server;
|
||||||
node.port = stoi(port);
|
node.port = stoi(port);
|
||||||
@@ -671,15 +632,6 @@ void explodeSSRConf(std::string content, std::string custom_port, int local_port
|
|||||||
node.linkType = SPEEDTEST_MESSAGE_FOUNDSSR;
|
node.linkType = SPEEDTEST_MESSAGE_FOUNDSSR;
|
||||||
node.group = group;
|
node.group = group;
|
||||||
node.remarks = remarks;
|
node.remarks = remarks;
|
||||||
|
|
||||||
if(chkIgnore(node))
|
|
||||||
{
|
|
||||||
writeLog(LOG_TYPE_INFO, "Node " + node.group + " - " + node.remarks + " has been ignored and will not be tested.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
writeLog(LOG_TYPE_INFO, "Node " + node.group + " - " + node.remarks + " has been added.");
|
|
||||||
|
|
||||||
node.id = index;
|
node.id = index;
|
||||||
node.server = server;
|
node.server = server;
|
||||||
node.port = stoi(port);
|
node.port = stoi(port);
|
||||||
@@ -985,15 +937,6 @@ void explodeClash(Node yamlnode, std::string custom_port, int local_port, std::v
|
|||||||
|
|
||||||
node.group = group;
|
node.group = group;
|
||||||
node.remarks = ps;
|
node.remarks = ps;
|
||||||
|
|
||||||
if(chkIgnore(node))
|
|
||||||
{
|
|
||||||
writeLog(LOG_TYPE_INFO, "Node " + node.group + " - " + node.remarks + " has been ignored and will not be tested.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
writeLog(LOG_TYPE_INFO, "Node " + node.group + " - " + node.remarks + " has been added.");
|
|
||||||
|
|
||||||
node.server = server;
|
node.server = server;
|
||||||
node.port = stoi(port);
|
node.port = stoi(port);
|
||||||
node.id = index;
|
node.id = index;
|
||||||
@@ -1322,15 +1265,6 @@ bool explodeSurge(std::string surge, std::string custom_port, int local_port, st
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
node.remarks = remarks;
|
node.remarks = remarks;
|
||||||
|
|
||||||
if(chkIgnore(node))
|
|
||||||
{
|
|
||||||
writeLog(LOG_TYPE_INFO, "Node " + node.group + " - " + node.remarks + " has been ignored and will not be tested.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
writeLog(LOG_TYPE_INFO, "Node " + node.group + " - " + node.remarks + " has been added.");
|
|
||||||
|
|
||||||
node.server = server;
|
node.server = server;
|
||||||
node.port = stoi(port);
|
node.port = stoi(port);
|
||||||
node.id = index;
|
node.id = index;
|
||||||
@@ -1394,15 +1328,6 @@ void explodeSSTap(std::string sstap, std::string custom_port, int local_port, st
|
|||||||
|
|
||||||
node.group = group;
|
node.group = group;
|
||||||
node.remarks = remarks;
|
node.remarks = remarks;
|
||||||
|
|
||||||
if(chkIgnore(node))
|
|
||||||
{
|
|
||||||
writeLog(LOG_TYPE_INFO, "Node " + node.group + " - " + node.remarks + " has been ignored and will not be tested.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
writeLog(LOG_TYPE_INFO, "Node " + node.group + " - " + node.remarks + " has been added.");
|
|
||||||
|
|
||||||
node.id = index;
|
node.id = index;
|
||||||
node.server = server;
|
node.server = server;
|
||||||
node.port = stoi(port);
|
node.port = stoi(port);
|
||||||
@@ -1427,21 +1352,13 @@ void explodeNetchConf(std::string netch, bool ss_libev, bool ssr_libev, std::str
|
|||||||
{
|
{
|
||||||
explodeNetch("Netch://" + base64_encode(SerializeObject(json["Server"][i])), ss_libev, ssr_libev, custom_port, local_port, node);
|
explodeNetch("Netch://" + base64_encode(SerializeObject(json["Server"][i])), ss_libev, ssr_libev, custom_port, local_port, node);
|
||||||
|
|
||||||
if(chkIgnore(node))
|
|
||||||
{
|
|
||||||
writeLog(LOG_TYPE_INFO, "Node " + node.group + " - " + node.remarks + " has been ignored and will not be tested.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
writeLog(LOG_TYPE_INFO, "Node " + node.group + " - " + node.remarks + " has been added.");
|
|
||||||
|
|
||||||
node.id = index;
|
node.id = index;
|
||||||
nodes.push_back(node);
|
nodes.push_back(node);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool chkIgnore(nodeInfo &node)
|
bool chkIgnore(nodeInfo &node, string_array &exclude_remarks, string_array &include_remarks)
|
||||||
{
|
{
|
||||||
bool excluded = false, included = false;
|
bool excluded = false, included = false;
|
||||||
//std::string remarks = UTF8ToGBK(node.remarks);
|
//std::string remarks = UTF8ToGBK(node.remarks);
|
||||||
@@ -1469,7 +1386,7 @@ bool chkIgnore(nodeInfo &node)
|
|||||||
return excluded || !included;
|
return excluded || !included;
|
||||||
}
|
}
|
||||||
|
|
||||||
int explodeConf(std::string filepath, std::string custom_port, int local_port, bool sslibev, bool ssrlibev, std::vector<nodeInfo> &nodes)
|
int explodeConf(std::string filepath, std::string custom_port, int local_port, bool sslibev, bool ssrlibev, std::vector<nodeInfo> &nodes, string_array &exclude_remarks, string_array &include_remarks)
|
||||||
{
|
{
|
||||||
std::ifstream infile;
|
std::ifstream infile;
|
||||||
std::stringstream contentstrm;
|
std::stringstream contentstrm;
|
||||||
@@ -1478,10 +1395,10 @@ int explodeConf(std::string filepath, std::string custom_port, int local_port, b
|
|||||||
contentstrm << infile.rdbuf();
|
contentstrm << infile.rdbuf();
|
||||||
infile.close();
|
infile.close();
|
||||||
|
|
||||||
return explodeConfContent(contentstrm.str(), custom_port, local_port, sslibev, ssrlibev, nodes);
|
return explodeConfContent(contentstrm.str(), custom_port, local_port, sslibev, ssrlibev, nodes, exclude_remarks, include_remarks);
|
||||||
}
|
}
|
||||||
|
|
||||||
int explodeConfContent(std::string content, std::string custom_port, int local_port, bool sslibev, bool ssrlibev, std::vector<nodeInfo> &nodes)
|
int explodeConfContent(std::string content, std::string custom_port, int local_port, bool sslibev, bool ssrlibev, std::vector<nodeInfo> &nodes, string_array &exclude_remarks, string_array &include_remarks)
|
||||||
{
|
{
|
||||||
unsigned int index = 0;
|
unsigned int index = 0;
|
||||||
int filetype = -1;
|
int filetype = -1;
|
||||||
@@ -1524,7 +1441,7 @@ int explodeConfContent(std::string content, std::string custom_port, int local_p
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
//try to parse as a local subscription
|
//try to parse as a local subscription
|
||||||
explodeSub(content, sslibev, ssrlibev, custom_port, local_port, nodes);
|
explodeSub(content, sslibev, ssrlibev, custom_port, local_port, nodes, exclude_remarks, include_remarks);
|
||||||
if(nodes.size() == 0)
|
if(nodes.size() == 0)
|
||||||
return SPEEDTEST_ERROR_UNRECOGFILE;
|
return SPEEDTEST_ERROR_UNRECOGFILE;
|
||||||
else
|
else
|
||||||
@@ -1534,9 +1451,9 @@ int explodeConfContent(std::string content, std::string custom_port, int local_p
|
|||||||
iter = nodes.begin();
|
iter = nodes.begin();
|
||||||
while(iter != nodes.end())
|
while(iter != nodes.end())
|
||||||
{
|
{
|
||||||
if(chkIgnore(*iter))
|
if(chkIgnore(*iter, exclude_remarks, include_remarks))
|
||||||
{
|
{
|
||||||
writeLog(LOG_TYPE_INFO, "Node " + iter->group + " - " + iter->remarks + " has been ignored and will not be tested.");
|
writeLog(LOG_TYPE_INFO, "Node " + iter->group + " - " + iter->remarks + " has been ignored and will not be added.");
|
||||||
nodes.erase(iter);
|
nodes.erase(iter);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1565,29 +1482,30 @@ void explode(std::string link, bool sslibev, bool ssrlibev, std::string custom_p
|
|||||||
explodeNetch(link, sslibev, ssrlibev, custom_port, local_port, node);
|
explodeNetch(link, sslibev, ssrlibev, custom_port, local_port, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
void explodeSub(std::string sub, bool sslibev, bool ssrlibev, std::string custom_port, int local_port, std::vector<nodeInfo> &nodes)
|
void explodeSub(std::string sub, bool sslibev, bool ssrlibev, std::string custom_port, int local_port, std::vector<nodeInfo> &nodes, string_array &exclude_remarks, string_array &include_remarks)
|
||||||
{
|
{
|
||||||
std::stringstream strstream;
|
std::stringstream strstream;
|
||||||
std::string strLink;
|
std::string strLink;
|
||||||
|
bool processed = false;
|
||||||
nodeInfo node;
|
nodeInfo node;
|
||||||
|
|
||||||
//try to parse as SSD configuration
|
//try to parse as SSD configuration
|
||||||
if(strFind(sub, "ssd://"))
|
if(strFind(sub, "ssd://"))
|
||||||
{
|
{
|
||||||
explodeSSD(sub, sslibev, custom_port, local_port, nodes);
|
explodeSSD(sub, sslibev, custom_port, local_port, nodes);
|
||||||
return;
|
processed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//try to parse as clash configuration
|
//try to parse as clash configuration
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(strFind(sub, "Proxy"))
|
if(!processed && strFind(sub, "Proxy"))
|
||||||
{
|
{
|
||||||
Node yamlnode = Load(sub);
|
Node yamlnode = Load(sub);
|
||||||
if(yamlnode.size() && yamlnode["Proxy"])
|
if(yamlnode.size() && yamlnode["Proxy"])
|
||||||
{
|
{
|
||||||
explodeClash(yamlnode, custom_port, local_port, nodes, sslibev, ssrlibev);
|
explodeClash(yamlnode, custom_port, local_port, nodes, sslibev, ssrlibev);
|
||||||
return;
|
processed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1597,15 +1515,16 @@ void explodeSub(std::string sub, bool sslibev, bool ssrlibev, std::string custom
|
|||||||
}
|
}
|
||||||
|
|
||||||
//try to parse as surge configuration
|
//try to parse as surge configuration
|
||||||
if(explodeSurge(sub, custom_port, local_port, nodes, sslibev))
|
if(!processed && explodeSurge(sub, custom_port, local_port, nodes, sslibev))
|
||||||
{
|
{
|
||||||
return;
|
processed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//try to parse as normal subscription
|
//try to parse as normal subscription
|
||||||
|
if(!processed)
|
||||||
|
{
|
||||||
sub = urlsafe_base64_decode(sub);
|
sub = urlsafe_base64_decode(sub);
|
||||||
strstream << sub;
|
strstream << sub;
|
||||||
unsigned int index = nodes.size();
|
|
||||||
char delimiter = count(sub.begin(), sub.end(), '\n') < 1 ? count(sub.begin(), sub.end(), '\r') < 1 ? ' ' : '\r' : '\n';
|
char delimiter = count(sub.begin(), sub.end(), '\n') < 1 ? count(sub.begin(), sub.end(), '\r') < 1 ? ' ' : '\r' : '\n';
|
||||||
while(getline(strstream, strLink, delimiter))
|
while(getline(strstream, strLink, delimiter))
|
||||||
{
|
{
|
||||||
@@ -1614,21 +1533,25 @@ void explodeSub(std::string sub, bool sslibev, bool ssrlibev, std::string custom
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(chkIgnore(node))
|
|
||||||
{
|
|
||||||
writeLog(LOG_TYPE_INFO, "Node " + node.group + " - " + node.remarks + " has been ignored and will not be tested.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
writeLog(LOG_TYPE_INFO, "Node " + node.group + " - " + node.remarks + " has been added.");
|
|
||||||
node.id = index;
|
|
||||||
nodes.push_back(node);
|
nodes.push_back(node);
|
||||||
index++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void remarksInit(string_array &exclude, string_array &include)
|
int index = 0;
|
||||||
|
std::vector<nodeInfo>::iterator iter = nodes.begin();
|
||||||
|
while(iter != nodes.end())
|
||||||
{
|
{
|
||||||
exclude_remarks = exclude;
|
if(chkIgnore(*iter, exclude_remarks, include_remarks))
|
||||||
include_remarks = include;
|
{
|
||||||
|
writeLog(LOG_TYPE_INFO, "Node " + iter->group + " - " + iter->remarks + " has been ignored and will not be added.");
|
||||||
|
nodes.erase(iter);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
writeLog(LOG_TYPE_INFO, "Node " + iter->group + " - " + iter->remarks + " has been added.");
|
||||||
|
iter->id = index;
|
||||||
|
index++;
|
||||||
|
iter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+4
-5
@@ -20,10 +20,9 @@ void explodeShadowrocket(std::string kit, std::string custom_port, int local_por
|
|||||||
void explodeKitsunebi(std::string kit, std::string custom_port, int local_port, nodeInfo &node);
|
void explodeKitsunebi(std::string kit, std::string custom_port, int local_port, nodeInfo &node);
|
||||||
void explode(std::string link, bool sslibev, bool ssrlibev, std::string custom_port, int local_port, nodeInfo &node);
|
void explode(std::string link, bool sslibev, bool ssrlibev, std::string custom_port, int local_port, nodeInfo &node);
|
||||||
void explodeSSD(std::string link, bool libev, std::string custom_port, int local_port, std::vector<nodeInfo> &nodes);
|
void explodeSSD(std::string link, bool libev, std::string custom_port, int local_port, std::vector<nodeInfo> &nodes);
|
||||||
void explodeSub(std::string sub, bool sslibev, bool ssrlibev, std::string custom_port, int local_port, std::vector<nodeInfo> &nodes);
|
void explodeSub(std::string sub, bool sslibev, bool ssrlibev, std::string custom_port, int local_port, std::vector<nodeInfo> &nodes, string_array &exclude_remarks, string_array &include_remarks);
|
||||||
int explodeConf(std::string filepath, std::string custom_port, int local_port, bool sslibev, bool ssrlibev, std::vector<nodeInfo> &nodes);
|
int explodeConf(std::string filepath, std::string custom_port, int local_port, bool sslibev, bool ssrlibev, std::vector<nodeInfo> &nodes, string_array &exclude_remarks, string_array &include_remarks);
|
||||||
int explodeConfContent(std::string content, std::string custom_port, int local_port, bool sslibev, bool ssrlibev, std::vector<nodeInfo> &nodes);
|
int explodeConfContent(std::string content, std::string custom_port, int local_port, bool sslibev, bool ssrlibev, std::vector<nodeInfo> &nodes, string_array &exclude_remarks, string_array &include_remarks);
|
||||||
void remarksInit(string_array &exclude, string_array &include);
|
bool chkIgnore(nodeInfo &node, string_array &exclude_remarks, string_array &include_remarks);
|
||||||
bool chkIgnore(nodeInfo &node);
|
|
||||||
|
|
||||||
#endif // SPEEDTESTUTIL_H_INCLUDED
|
#endif // SPEEDTESTUTIL_H_INCLUDED
|
||||||
@@ -18,7 +18,6 @@ struct extra_settings
|
|||||||
bool udp = false;
|
bool udp = false;
|
||||||
bool tfo = false;
|
bool tfo = false;
|
||||||
bool nodelist = false;
|
bool nodelist = false;
|
||||||
string_array include_remarks;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user