Skip to content

Commit

Permalink
Enhancements
Browse files Browse the repository at this point in the history
Fix rule generation in Surge configs.
Refactor log output for curl verbose logs.
Optimize codes.
  • Loading branch information
tindy2013 committed Dec 6, 2023
1 parent a0e2515 commit 043c1fd
Show file tree
Hide file tree
Showing 37 changed files with 317 additions and 260 deletions.
2 changes: 1 addition & 1 deletion src/config/binding.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <toml.hpp>

#include "../handler/settings.h"
#include "handler/settings.h"
#include "crontask.h"
#include "proxygroup.h"
#include "regmatch.h"
Expand Down
4 changes: 2 additions & 2 deletions src/config/def.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include <tuple>
#include <cstdint>

#include "../utils/string.h"
#include "../utils/tribool.h"
#include "utils/string.h"
#include "utils/tribool.h"

using String = std::string;
using Integer = int32_t;
Expand Down
24 changes: 12 additions & 12 deletions src/generator/config/nodemanip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
#include <iostream>
#include <algorithm>

#include "../../handler/settings.h"
#include "../../handler/webget.h"
#include "../../parser/config/proxy.h"
#include "../../parser/infoparser.h"
#include "../../parser/subparser.h"
#include "../../script/script_quickjs.h"
#include "../../utils/file_extra.h"
#include "../../utils/logger.h"
#include "../../utils/map_extra.h"
#include "../../utils/network.h"
#include "../../utils/regexp.h"
#include "../../utils/urlencode.h"
#include "handler/settings.h"
#include "handler/webget.h"
#include "parser/config/proxy.h"
#include "parser/infoparser.h"
#include "parser/subparser.h"
#include "script/script_quickjs.h"
#include "utils/file_extra.h"
#include "utils/logger.h"
#include "utils/map_extra.h"
#include "utils/network.h"
#include "utils/regexp.h"
#include "utils/urlencode.h"
#include "nodemanip.h"
#include "subexport.h"

Expand Down
8 changes: 4 additions & 4 deletions src/generator/config/nodemanip.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
#include <quickjspp.hpp>
#endif // NO_JS_RUNTIME

#include "../../config/regmatch.h"
#include "../../parser/config/proxy.h"
#include "../../utils/map_extra.h"
#include "../../utils/string.h"
#include "config/regmatch.h"
#include "parser/config/proxy.h"
#include "utils/map_extra.h"
#include "utils/string.h"

struct parse_settings
{
Expand Down
19 changes: 9 additions & 10 deletions src/generator/config/ruleconvert.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include <string>

#include "../../handler/settings.h"
#include "../../utils/logger.h"
#include "../../utils/network.h"
#include "../../utils/regexp.h"
#include "../../utils/string.h"
#include "../../utils/rapidjson_extra.h"
#include "handler/settings.h"
#include "utils/logger.h"
#include "utils/network.h"
#include "utils/regexp.h"
#include "utils/string.h"
#include "utils/rapidjson_extra.h"
#include "subexport.h"

/// rule type lists
Expand Down Expand Up @@ -338,7 +338,7 @@ void rulesetToSurge(INIReader &base_rule, std::vector<RulesetContent> &ruleset_c
strLine = "RULE-SET," + remote_path_prefix + "/getruleset?type=1&url=" + urlSafeBase64Encode(rule_path_typed) + "," + rule_group;
if(x.update_interval)
strLine += ",update-interval=" + std::to_string(x.update_interval);
allRules.emplace_back(std::move(strLine));
allRules.emplace_back(strLine);
continue;
}
else if(surge_ver == -1 && !remote_path_prefix.empty())
Expand Down Expand Up @@ -372,7 +372,7 @@ void rulesetToSurge(INIReader &base_rule, std::vector<RulesetContent> &ruleset_c
if(x.update_interval)
strLine += ",update-interval=" + std::to_string(x.update_interval);

allRules.emplace_back(std::move(strLine));
allRules.emplace_back(strLine);
continue;
}
else if(surge_ver == -1 && !remote_path_prefix.empty())
Expand Down Expand Up @@ -447,7 +447,6 @@ void rulesetToSurge(INIReader &base_rule, std::vector<RulesetContent> &ruleset_c
strLine = trimWhitespace(strLine);
}

strLine += "," + rule_group;
if(surge_ver == -1 || surge_ver == -2)
{
if(startsWith(strLine, "IP-CIDR6"))
Expand All @@ -459,7 +458,7 @@ void rulesetToSurge(INIReader &base_rule, std::vector<RulesetContent> &ruleset_c
if(!startsWith(strLine, "AND") && !startsWith(strLine, "OR") && !startsWith(strLine, "NOT"))
strLine = transformRuleToCommon(temp, strLine, rule_group);
}
allRules.emplace_back(std::move(strLine));
allRules.emplace_back(strLine);
total_rules++;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/generator/config/ruleconvert.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <yaml-cpp/yaml.h>
#include <rapidjson/document.h>

#include "../../utils/ini_reader/ini_reader.h"
#include "utils/ini_reader/ini_reader.h"

enum ruleset_type
{
Expand Down
32 changes: 16 additions & 16 deletions src/generator/config/subexport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
#include <cmath>
#include <climits>

#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"
#include "../../utils/file_extra.h"
#include "../../utils/ini_reader/ini_reader.h"
#include "../../utils/logger.h"
#include "../../utils/network.h"
#include "../../utils/rapidjson_extra.h"
#include "../../utils/regexp.h"
#include "../../utils/stl_extra.h"
#include "../../utils/urlencode.h"
#include "../../utils/yamlcpp_extra.h"
#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"
#include "utils/file_extra.h"
#include "utils/ini_reader/ini_reader.h"
#include "utils/logger.h"
#include "utils/network.h"
#include "utils/rapidjson_extra.h"
#include "utils/regexp.h"
#include "utils/stl_extra.h"
#include "utils/urlencode.h"
#include "utils/yamlcpp_extra.h"
#include "nodemanip.h"
#include "ruleconvert.h"

Expand Down
12 changes: 6 additions & 6 deletions src/generator/config/subexport.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
#include <quickjspp.hpp>
#endif // NO_JS_RUNTIME

#include "../../config/proxygroup.h"
#include "../../config/regmatch.h"
#include "../../parser/config/proxy.h"
#include "../../utils/ini_reader/ini_reader.h"
#include "../../utils/string.h"
#include "../../utils/yamlcpp_extra.h"
#include "config/proxygroup.h"
#include "config/regmatch.h"
#include "parser/config/proxy.h"
#include "utils/ini_reader/ini_reader.h"
#include "utils/string.h"
#include "utils/yamlcpp_extra.h"
#include "ruleconvert.h"

struct extra_settings
Expand Down
4 changes: 2 additions & 2 deletions src/generator/template/template_jinja2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include <jinja2cpp/template.h>
#include <nlohmann/json.hpp>

#include "../../handler/interfaces.h"
#include "../../utils/regexp.h"
#include "handler/interfaces.h"
#include "utils/regexp.h"
#include "templates.h"

static inline void parse_json_pointer(nlohmann::json &json, const std::string &path, const std::string &value)
Expand Down
16 changes: 8 additions & 8 deletions src/generator/template/templates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
#include <inja.hpp>
#include <nlohmann/json.hpp>

#include "../../handler/interfaces.h"
#include "../../handler/settings.h"
#include "../../handler/webget.h"
#include "../../utils/logger.h"
#include "../../utils/network.h"
#include "../../utils/regexp.h"
#include "../../utils/urlencode.h"
#include "../../utils/yamlcpp_extra.h"
#include "handler/interfaces.h"
#include "handler/settings.h"
#include "handler/webget.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"

namespace inja
Expand Down
4 changes: 2 additions & 2 deletions src/generator/template/templates.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include <string>
#include <map>

#include "../../generator/config/subexport.h"
#include "../../utils/string.h"
#include "generator/config/subexport.h"
#include "utils/string.h"

struct template_args
{
Expand Down
42 changes: 21 additions & 21 deletions src/handler/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@
#include <inja.hpp>
#include <yaml-cpp/yaml.h>

#include "../config/binding.h"
#include "../generator/config/nodemanip.h"
#include "../generator/config/ruleconvert.h"
#include "../generator/config/subexport.h"
#include "../generator/template/templates.h"
#include "../script/cron.h"
#include "../script/script_quickjs.h"
#include "../server/webserver.h"
#include "../utils/base64/base64.h"
#include "../utils/file_extra.h"
#include "../utils/ini_reader/ini_reader.h"
#include "../utils/logger.h"
#include "../utils/network.h"
#include "../utils/regexp.h"
#include "../utils/stl_extra.h"
#include "../utils/string.h"
#include "../utils/string_hash.h"
#include "../utils/system.h"
#include "../utils/system.h"
#include "../utils/urlencode.h"
#include "../utils/yamlcpp_extra.h"
#include "config/binding.h"
#include "generator/config/nodemanip.h"
#include "generator/config/ruleconvert.h"
#include "generator/config/subexport.h"
#include "generator/template/templates.h"
#include "script/cron.h"
#include "script/script_quickjs.h"
#include "server/webserver.h"
#include "utils/base64/base64.h"
#include "utils/file_extra.h"
#include "utils/ini_reader/ini_reader.h"
#include "utils/logger.h"
#include "utils/network.h"
#include "utils/regexp.h"
#include "utils/stl_extra.h"
#include "utils/string.h"
#include "utils/string_hash.h"
#include "utils/system.h"
#include "utils/system.h"
#include "utils/urlencode.h"
#include "utils/yamlcpp_extra.h"
#include "interfaces.h"
#include "multithread.h"
#include "settings.h"
Expand Down
6 changes: 3 additions & 3 deletions src/handler/interfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include <map>
#include <inja.hpp>

#include "../config/ruleset.h"
#include "../generator/config/subexport.h"
#include "../server/webserver.h"
#include "config/ruleset.h"
#include "generator/config/subexport.h"
#include "server/webserver.h"

std::string parseProxy(const std::string &source);

Expand Down
4 changes: 2 additions & 2 deletions src/handler/multithread.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <future>
#include <thread>

#include "../handler/settings.h"
#include "../utils/network.h"
#include "handler/settings.h"
#include "utils/network.h"
#include "webget.h"
#include "multithread.h"
//#include "vfs.h"
Expand Down
6 changes: 3 additions & 3 deletions src/handler/multithread.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

#include <yaml-cpp/yaml.h>

#include "../config/regmatch.h"
#include "../utils/ini_reader/ini_reader.h"
#include "../utils/string.h"
#include "config/regmatch.h"
#include "utils/ini_reader/ini_reader.h"
#include "utils/string.h"

using guarded_mutex = std::lock_guard<std::mutex>;

Expand Down
12 changes: 6 additions & 6 deletions src/handler/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
#include <mutex>
#include <toml.hpp>

#include "../config/binding.h"
#include "../handler/webget.h"
#include "../script/cron.h"
#include "../server/webserver.h"
#include "../utils/logger.h"
#include "../utils/network.h"
#include "config/binding.h"
#include "handler/webget.h"
#include "script/cron.h"
#include "server/webserver.h"
#include "utils/logger.h"
#include "utils/network.h"
#include "interfaces.h"
#include "multithread.h"
#include "settings.h"
Expand Down
20 changes: 10 additions & 10 deletions src/handler/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@

#include <string>

#include "../config/crontask.h"
#include "../config/regmatch.h"
#include "../config/proxygroup.h"
#include "../config/ruleset.h"
#include "../generator/config/ruleconvert.h"
#include "../generator/template/templates.h"
#include "../utils/logger.h"
#include "../utils/string.h"
#include "../utils/stl_extra.h"
#include "../utils/tribool.h"
#include "config/crontask.h"
#include "config/regmatch.h"
#include "config/proxygroup.h"
#include "config/ruleset.h"
#include "generator/config/ruleconvert.h"
#include "generator/template/templates.h"
#include "utils/logger.h"
#include "utils/string.h"
#include "utils/stl_extra.h"
#include "utils/tribool.h"

struct Settings
{
Expand Down
8 changes: 4 additions & 4 deletions src/handler/upload.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <string>

#include "../utils/ini_reader/ini_reader.h"
#include "../utils/logger.h"
#include "../utils/rapidjson_extra.h"
#include "../utils/system.h"
#include "utils/ini_reader/ini_reader.h"
#include "utils/logger.h"
#include "utils/rapidjson_extra.h"
#include "utils/system.h"
#include "webget.h"

std::string buildGistData(std::string name, std::string content)
Expand Down
Loading

0 comments on commit 043c1fd

Please sign in to comment.