Enhancements

Add support for parsing Clash subscriptions in JSON format.
Add retry for downloading files.
Optimize codes.
Update local rulesets and configs.
This commit is contained in:
Tindy X committed 2020-06-05 10:52:59 +08:00
1 parent ac11260747
commit 8d0fc42ad3
69 files changed
+807 -1285

No files matched your search

+1 -1
View File
@@ -2012,7 +2012,7 @@ void explodeSub(std::string sub, bool sslibev, bool ssrlibev, const std::string
//try to parse as clash configuration
try
{
if(!processed && (strFind(sub, "Proxy:") || strFind(sub, "proxies:")))
if(!processed && regFind(sub, "\"?(Proxy|proxies)\"?:"))
{
regGetMatch(sub, R"(^(?:Proxy|proxies):$\s(?:(?:^ +?.*$| *?-.*$|)\s)+)", 1, &sub);
Node yamlnode = Load(sub);
+6 -3
View File
@@ -1136,7 +1136,8 @@ void netchToClash(std::vector<nodeInfo> &nodes, YAML::Node &yamlnode, string_arr
case "ws"_hash:
singleproxy["network"] = transproto;
singleproxy["ws-path"] = path;
singleproxy["ws-headers"]["Host"] = host;
if(host.size())
singleproxy["ws-headers"]["Host"] = host;
if(edge.size())
singleproxy["ws-headers"]["Edge"] = edge;
break;
@@ -1144,7 +1145,8 @@ void netchToClash(std::vector<nodeInfo> &nodes, YAML::Node &yamlnode, string_arr
singleproxy["network"] = transproto;
singleproxy["http-opts"]["method"] = "GET";
singleproxy["http-opts"]["path"].push_back(path);
singleproxy["http-opts"]["headers"]["Host"].push_back(host);
if(host.size())
singleproxy["http-opts"]["headers"]["Host"].push_back(host);
if(edge.size())
singleproxy["http-opts"]["headers"]["Edge"].push_back(edge);
default:
@@ -1217,7 +1219,8 @@ void netchToClash(std::vector<nodeInfo> &nodes, YAML::Node &yamlnode, string_arr
if(obfs.size())
{
singleproxy["obfs-opts"]["mode"] = obfs;
singleproxy["obfs-opts"]["host"] = host;
if(host.size())
singleproxy["obfs-opts"]["host"] = host;
}
if(std::all_of(password.begin(), password.end(), ::isdigit) && !password.empty())
singleproxy["password"].SetTag("str");
+10 -1
View File
@@ -95,7 +95,16 @@ static std::string curlGet(const std::string &url, const std::string &proxy, std
curl_easy_setopt(curl_handle, CURLOPT_HEADERFUNCTION, writer);
curl_easy_setopt(curl_handle, CURLOPT_HEADERDATA, &response_headers);
return_code = curl_easy_perform(curl_handle);
unsigned int fail_count = 0, max_fails = 1;
while(true)
{
return_code = curl_easy_perform(curl_handle);
if(return_code == CURLE_OK || max_fails >= fail_count)
break;
else
fail_count++;
}
curl_easy_getinfo(curl_handle, CURLINFO_HTTP_CODE, &retVal);
curl_easy_cleanup(curl_handle);
-4
View File
@@ -3,10 +3,6 @@
#include <string>
#ifdef _WIN32
#include <ws2tcpip.h>
#endif // _WIN32
#include "misc.h"
std::string webGet(const std::string &url, const std::string &proxy);