mirror of
https://github.com/MetaCubeX/subconverter.git
synced 2025-11-04 18:19:42 +08:00
Bugs fix
Fix build error. Fix max_allowed_download_size option has no effect (#409). Clean up codes.
This commit is contained in:
parent
08d00dd3d7
commit
4639ee483e
@ -94,6 +94,7 @@ FIND_LIBRARY(YAML_CPP_LIBRARY NAMES yaml-cpp yaml-cppd PATHS ${YAML_CPP_LIBRARY_
|
|||||||
LINK_DIRECTORIES(${YAML_CPP_LIBRARY_DIRS})
|
LINK_DIRECTORIES(${YAML_CPP_LIBRARY_DIRS})
|
||||||
INCLUDE_DIRECTORIES(${YAML_CPP_INCLUDE_DIRS})
|
INCLUDE_DIRECTORIES(${YAML_CPP_INCLUDE_DIRS})
|
||||||
TARGET_LINK_LIBRARIES(subconverter ${YAML_CPP_LIBRARY})
|
TARGET_LINK_LIBRARIES(subconverter ${YAML_CPP_LIBRARY})
|
||||||
|
ADD_DEFINITIONS(-DYAML_CPP_STATIC_DEFINE)
|
||||||
|
|
||||||
#IF(USING_STD_REGEX STREQUAL "ON")
|
#IF(USING_STD_REGEX STREQUAL "ON")
|
||||||
# ADD_DEFINITIONS(-DUSE_STD_REGEX)
|
# ADD_DEFINITIONS(-DUSE_STD_REGEX)
|
||||||
|
|||||||
@ -1298,25 +1298,3 @@ int loadExternalConfig(std::string &path, ExternalConfig &ext)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|||||||
@ -28,8 +28,8 @@ struct Settings
|
|||||||
bool printDbgInfo = false, CFWChildProcess = false, appendUserinfo = true, asyncFetchRuleset = false, surgeResolveHostname = true;
|
bool printDbgInfo = false, CFWChildProcess = false, appendUserinfo = true, asyncFetchRuleset = false, surgeResolveHostname = true;
|
||||||
std::string accessToken, basePath = "base";
|
std::string accessToken, basePath = "base";
|
||||||
std::string custom_group;
|
std::string custom_group;
|
||||||
int logLevel;
|
int logLevel = 0;
|
||||||
long maxAllowedDownloadSize;
|
long maxAllowedDownloadSize = 1048576L;
|
||||||
string_map aliases;
|
string_map aliases;
|
||||||
|
|
||||||
//global variables for template
|
//global variables for template
|
||||||
@ -97,6 +97,25 @@ extern Settings global;
|
|||||||
|
|
||||||
int importItems(string_array &target, bool scope_limit = true);
|
int importItems(string_array &target, bool scope_limit = true);
|
||||||
int loadExternalConfig(std::string &path, ExternalConfig &ext);
|
int loadExternalConfig(std::string &path, ExternalConfig &ext);
|
||||||
void parseGroupTimes(const std::string &src, int *interval, int *tolerance, int *timeout);
|
|
||||||
|
template <class... Args>
|
||||||
|
void parseGroupTimes(const std::string &src, Args... args)
|
||||||
|
{
|
||||||
|
std::array<int*, sizeof...(args)> ptrs {args...};
|
||||||
|
string_size bpos = 0, epos = src.find(",");
|
||||||
|
for(int *x : ptrs)
|
||||||
|
{
|
||||||
|
if(x != nullptr)
|
||||||
|
*x = to_int(src.substr(bpos, epos - bpos), 0);
|
||||||
|
if(epos != src.npos)
|
||||||
|
{
|
||||||
|
bpos = epos + 1;
|
||||||
|
epos = src.find(",", bpos);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // SETTINGS_H_INCLUDED
|
#endif // SETTINGS_H_INCLUDED
|
||||||
|
|||||||
@ -93,8 +93,6 @@ public:
|
|||||||
|
|
||||||
RWLock cache_rw_lock;
|
RWLock cache_rw_lock;
|
||||||
|
|
||||||
long gMaxAllowedDownloadSize = 1048576L;
|
|
||||||
|
|
||||||
//std::string user_agent_str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36";
|
//std::string user_agent_str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36";
|
||||||
static std::string user_agent_str = "subconverter/" VERSION " cURL/" LIBCURL_VERSION;
|
static std::string user_agent_str = "subconverter/" VERSION " cURL/" LIBCURL_VERSION;
|
||||||
|
|
||||||
@ -190,7 +188,7 @@ static int curlGet(const FetchArgument &argument, FetchResult &result)
|
|||||||
curl_easy_setopt(curl_handle, CURLOPT_PROXY, argument.proxy.data());
|
curl_easy_setopt(curl_handle, CURLOPT_PROXY, argument.proxy.data());
|
||||||
}
|
}
|
||||||
curl_progress_data limit;
|
curl_progress_data limit;
|
||||||
limit.size_limit = gMaxAllowedDownloadSize;
|
limit.size_limit = global.maxAllowedDownloadSize;
|
||||||
curl_set_common_options(curl_handle, new_url.data(), &limit);
|
curl_set_common_options(curl_handle, new_url.data(), &limit);
|
||||||
list = curl_slist_append(list, "Content-Type: application/json;charset='utf-8'");
|
list = curl_slist_append(list, "Content-Type: application/json;charset='utf-8'");
|
||||||
if(argument.request_headers)
|
if(argument.request_headers)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user