mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2026-11-02 01:33:04 +00:00
Enhancements
Fix HEAD method to /sub not working. Remove unused interfaces.
This commit is contained in:
6 files changed
+8
-134
No files matched your search
@@ -1245,72 +1245,6 @@ std::string getProfile(RESPONSE_CALLBACK_ARGS)
|
||||
return subconverter(request, response);
|
||||
}
|
||||
|
||||
std::string getScript(RESPONSE_CALLBACK_ARGS)
|
||||
{
|
||||
std::string &argument = request.argument;
|
||||
|
||||
std::string url = urlSafeBase64Decode(getUrlArg(argument, "url")), dev_id = getUrlArg(argument, "id");
|
||||
std::string output_content;
|
||||
|
||||
std::string proxy = parseProxy(global.proxyConfig);
|
||||
|
||||
output_content = fetchFile(url, proxy, global.cacheConfig);
|
||||
|
||||
if(!dev_id.size())
|
||||
dev_id = global.quanXDevID;
|
||||
|
||||
const std::string pattern = "(\\/\\*[\\s\\S]*?)^(.*?@supported )(.*?\\s?)$([\\s\\S]*\\*\\/\\s?";
|
||||
if(dev_id.size())
|
||||
{
|
||||
if(regFind(output_content, pattern))
|
||||
output_content = regReplace(output_content, pattern, "$1$2" + dev_id + "$4");
|
||||
else
|
||||
output_content = "/**\n * @supported " + dev_id + "\n * THIS COMMENT IS GENERATED BY SUBCONVERTER\n */\n\n" + output_content;
|
||||
}
|
||||
return output_content;
|
||||
}
|
||||
|
||||
std::string getRewriteRemote(RESPONSE_CALLBACK_ARGS)
|
||||
{
|
||||
std::string &argument = request.argument;
|
||||
|
||||
std::string url = urlSafeBase64Decode(getUrlArg(argument, "url")), dev_id = getUrlArg(argument, "id");
|
||||
std::string output_content;
|
||||
|
||||
std::string proxy = parseProxy(global.proxyConfig);
|
||||
|
||||
output_content = fetchFile(url, proxy, global.cacheConfig);
|
||||
|
||||
if(!dev_id.size())
|
||||
dev_id = global.quanXDevID;
|
||||
|
||||
if(dev_id.size())
|
||||
{
|
||||
std::stringstream ss;
|
||||
std::string strLine;
|
||||
const std::string pattern = "^(.*? url script-.*? )(.*?)$";
|
||||
string_size lineSize;
|
||||
char delimiter = getLineBreak(output_content);
|
||||
|
||||
ss << output_content;
|
||||
output_content.clear();
|
||||
while(getline(ss, strLine, delimiter))
|
||||
{
|
||||
lineSize = strLine.size();
|
||||
if(lineSize && strLine[lineSize - 1] == '\r') //remove line break
|
||||
strLine.erase(--lineSize);
|
||||
|
||||
if(!strLine.empty() && regMatch(strLine, pattern))
|
||||
{
|
||||
url = global.managedConfigPrefix + "/qx-script?id=" + dev_id + "&url=" + urlSafeBase64Encode(regReplace(strLine, pattern, "$2"));
|
||||
strLine = regReplace(strLine, pattern, "$1") + url;
|
||||
}
|
||||
output_content.append(strLine + "\n");
|
||||
}
|
||||
}
|
||||
return output_content;
|
||||
}
|
||||
|
||||
/*
|
||||
std::string jinja2_webGet(const std::string &url)
|
||||
{
|
||||
|
||||
@@ -17,10 +17,8 @@ int simpleGenerator();
|
||||
std::string convertRuleset(const std::string &content, int type);
|
||||
|
||||
std::string getConvertedRuleset(RESPONSE_CALLBACK_ARGS);
|
||||
std::string getScript(RESPONSE_CALLBACK_ARGS);
|
||||
std::string getProfile(RESPONSE_CALLBACK_ARGS);
|
||||
std::string getRuleset(RESPONSE_CALLBACK_ARGS);
|
||||
std::string getRewriteRemote(RESPONSE_CALLBACK_ARGS);
|
||||
|
||||
std::string subconverter(RESPONSE_CALLBACK_ARGS);
|
||||
std::string simpleToClashR(RESPONSE_CALLBACK_ARGS);
|
||||
|
||||
@@ -58,12 +58,12 @@ void safe_set_times(RegexMatchConfigs data)
|
||||
global.timeNodeRules.swap(data);
|
||||
}
|
||||
|
||||
std::shared_future<std::string> fetchFileAsync(const std::string &path, const std::string &proxy, int cache_ttl, bool async)
|
||||
std::shared_future<std::string> fetchFileAsync(const std::string &path, const std::string &proxy, int cache_ttl, bool find_local, bool async)
|
||||
{
|
||||
std::shared_future<std::string> retVal;
|
||||
/*if(vfs::vfs_exist(path))
|
||||
retVal = std::async(std::launch::async, [path](){return vfs::vfs_get(path);});
|
||||
else */if(fileExist(path, true))
|
||||
else */if(find_local && fileExist(path, true))
|
||||
retVal = std::async(std::launch::async, [path](){return fileGet(path, true);});
|
||||
else if(isLink(path))
|
||||
retVal = std::async(std::launch::async, [path, proxy, cache_ttl](){return webGet(path, proxy, cache_ttl);});
|
||||
@@ -74,7 +74,7 @@ std::shared_future<std::string> fetchFileAsync(const std::string &path, const st
|
||||
return retVal;
|
||||
}
|
||||
|
||||
std::string fetchFile(const std::string &path, const std::string &proxy, int cache_ttl)
|
||||
std::string fetchFile(const std::string &path, const std::string &proxy, int cache_ttl, bool find_local)
|
||||
{
|
||||
return fetchFileAsync(path, proxy, cache_ttl, false).get();
|
||||
return fetchFileAsync(path, proxy, cache_ttl, find_local, false).get();
|
||||
}
|
||||
@@ -22,7 +22,7 @@ void safe_set_emojis(RegexMatchConfigs data);
|
||||
void safe_set_renames(RegexMatchConfigs data);
|
||||
void safe_set_streams(RegexMatchConfigs data);
|
||||
void safe_set_times(RegexMatchConfigs data);
|
||||
std::shared_future<std::string> fetchFileAsync(const std::string &path, const std::string &proxy, int cache_ttl, bool async = false);
|
||||
std::string fetchFile(const std::string &path, const std::string &proxy, int cache_ttl);
|
||||
std::shared_future<std::string> fetchFileAsync(const std::string &path, const std::string &proxy, int cache_ttl, bool find_local = true, bool async = false);
|
||||
std::string fetchFile(const std::string &path, const std::string &proxy, int cache_ttl, bool find_local = true);
|
||||
|
||||
#endif // MULTITHREAD_H_INCLUDED
|
||||
Reference in new issue
Block a user