mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2025-10-29 04:42:33 +00:00
Bug fixes
Fix Surge SSID groups not being correctly generated. Fix snippet importing not filtering line break. Add SSID group example.
This commit is contained in:
@@ -124,6 +124,7 @@ surge_ruleset=!!import:snippets/rulesets.txt
|
||||
;custom_proxy_group=UrlTest`url-test`.*`http://www.gstatic.com/generate_204`300
|
||||
;custom_proxy_group=FallBack`fallback`.*`http://www.gstatic.com/generate_204`300
|
||||
;custom_proxy_group=LoadBalance`load-balance`.*`http://www.gstatic.com/generate_204`300
|
||||
;custom_proxy_group=SSID`ssid`default_group`celluar=group0,ssid1=group1,ssid2=group2
|
||||
|
||||
;custom_proxy_group=g1`select`!!GROUPID=0
|
||||
;custom_proxy_group=g2`select`!!GROUPID=1
|
||||
|
||||
151
base/pref.yml
151
base/pref.yml
@@ -1,75 +1,76 @@
|
||||
common:
|
||||
api_mode: false
|
||||
api_access_token: password
|
||||
default_url: []
|
||||
exclude_remarks: ["(到期|剩余流量|时间|官网|产品)"]
|
||||
include_remarks: []
|
||||
clash_rule_base: base/simple_base.yml
|
||||
surge_rule_base: base/surge.conf
|
||||
surfboard_rule_base: base/surfboard.conf
|
||||
mellow_rule_base: base/mellow.conf
|
||||
quan_rule_base: base/quan.conf
|
||||
quanx_rule_base: base/quanx.conf
|
||||
proxy_ruleset: SYSTEM
|
||||
proxy_subscription: NONE
|
||||
append_proxy_type: false
|
||||
|
||||
userinfo:
|
||||
stream_rule:
|
||||
- {match: "^剩余流量:(.*?) (.*)$", replace: "total=$1&left=$2"}
|
||||
- {match: "^Bandwidth: (.*?)/(.*)$", replace: "used=$1&total=$2"}
|
||||
- {match: "^.*剩余(.*?)(?:\\s*?)@(?:.*)$", replace: "total=$1"}
|
||||
time_rule:
|
||||
- {match: "^过期时间:(\\d+)-(\\d+)-(\\d+) (\\d+):(\\d+):(\\d+)$", replace: "$1:$2:$3:$4:$5:$6"}
|
||||
- {match: "^到期时间:(\\d+)-(\\d+)-(\\d+)$", replace: "$1:$2:$3:0:0:0"}
|
||||
- {match: "^Smart Access expire: (\\d+)/(\\d+)/(\\d+)$", replace: "$1:$2:$3:0:0:0"}
|
||||
|
||||
node_pref:
|
||||
udp_flag: false
|
||||
tcp_fast_open_flag: false
|
||||
sort_flag: false
|
||||
skip_cert_verify_flag: false
|
||||
rename_node:
|
||||
# - {match: "\\(?((x|X)?(\\d+)(\\.?\\d+)?)((\\s?倍率?)|(x|X))\\)?", replace: "$1x"}
|
||||
- {import: snippets/rename_node.txt}
|
||||
|
||||
managed_config:
|
||||
write_managed_config: true
|
||||
managed_config_prefix: "http://127.0.0.1:25500"
|
||||
|
||||
surge_external_proxy:
|
||||
surge_ssr_path: "" # /usr/bin/ssr-local
|
||||
|
||||
emojis:
|
||||
add_emoji: true
|
||||
remove_old_emoji: true
|
||||
rules:
|
||||
# - {match: "(流量|时间|应急)", emoji: "🏳️🌈"}
|
||||
- {import: snippets/emoji.txt}
|
||||
|
||||
ruleset:
|
||||
enabled: true
|
||||
overwrite_original_rules: false
|
||||
update_ruleset_on_request: false
|
||||
surge_ruleset:
|
||||
# - {rule: "GEOIP,CN", group: "DIRECT"}
|
||||
# - {ruleset: "rules/LocalAreaNetwork.list", group: "DIRECT"}
|
||||
- {import: snippets/rulesets.txt}
|
||||
|
||||
proxy_group:
|
||||
custom_proxy_group:
|
||||
# - {name: UrlTest, type: url-test, rule: [".*"], url: http://www.gstatic.com/generate_204, interval: 300}
|
||||
# - {name: Proxy, type: select, rule: [".*"]}
|
||||
# - {name: group1, type: select, rule: ["!!GROUPID=0"]}
|
||||
# - {name: v2ray, type: select, rule: ["!!GROUP=V2RayProvider"]}
|
||||
# - {import: snippets/groups_forcerule.txt}
|
||||
- {import: snippets/groups.txt}
|
||||
|
||||
server:
|
||||
listen: 0.0.0.0
|
||||
port: 25500
|
||||
|
||||
advanced:
|
||||
print_debug_info: false
|
||||
max_pending_connections: 10240
|
||||
max_concurrent_threads: 4
|
||||
common:
|
||||
api_mode: false
|
||||
api_access_token: password
|
||||
default_url: []
|
||||
exclude_remarks: ["(到期|剩余流量|时间|官网|产品)"]
|
||||
include_remarks: []
|
||||
clash_rule_base: base/simple_base.yml
|
||||
surge_rule_base: base/surge.conf
|
||||
surfboard_rule_base: base/surfboard.conf
|
||||
mellow_rule_base: base/mellow.conf
|
||||
quan_rule_base: base/quan.conf
|
||||
quanx_rule_base: base/quanx.conf
|
||||
proxy_ruleset: SYSTEM
|
||||
proxy_subscription: NONE
|
||||
append_proxy_type: false
|
||||
|
||||
userinfo:
|
||||
stream_rule:
|
||||
- {match: "^剩余流量:(.*?) (.*)$", replace: "total=$1&left=$2"}
|
||||
- {match: "^Bandwidth: (.*?)/(.*)$", replace: "used=$1&total=$2"}
|
||||
- {match: "^.*剩余(.*?)(?:\\s*?)@(?:.*)$", replace: "total=$1"}
|
||||
time_rule:
|
||||
- {match: "^过期时间:(\\d+)-(\\d+)-(\\d+) (\\d+):(\\d+):(\\d+)$", replace: "$1:$2:$3:$4:$5:$6"}
|
||||
- {match: "^到期时间:(\\d+)-(\\d+)-(\\d+)$", replace: "$1:$2:$3:0:0:0"}
|
||||
- {match: "^Smart Access expire: (\\d+)/(\\d+)/(\\d+)$", replace: "$1:$2:$3:0:0:0"}
|
||||
|
||||
node_pref:
|
||||
udp_flag: false
|
||||
tcp_fast_open_flag: false
|
||||
sort_flag: false
|
||||
skip_cert_verify_flag: false
|
||||
rename_node:
|
||||
# - {match: "\\(?((x|X)?(\\d+)(\\.?\\d+)?)((\\s?倍率?)|(x|X))\\)?", replace: "$1x"}
|
||||
- {import: snippets/rename_node.txt}
|
||||
|
||||
managed_config:
|
||||
write_managed_config: true
|
||||
managed_config_prefix: "http://127.0.0.1:25500"
|
||||
|
||||
surge_external_proxy:
|
||||
surge_ssr_path: "" # /usr/bin/ssr-local
|
||||
|
||||
emojis:
|
||||
add_emoji: true
|
||||
remove_old_emoji: true
|
||||
rules:
|
||||
# - {match: "(流量|时间|应急)", emoji: "🏳️🌈"}
|
||||
- {import: snippets/emoji.txt}
|
||||
|
||||
ruleset:
|
||||
enabled: true
|
||||
overwrite_original_rules: false
|
||||
update_ruleset_on_request: false
|
||||
surge_ruleset:
|
||||
# - {rule: "GEOIP,CN", group: "DIRECT"}
|
||||
# - {ruleset: "rules/LocalAreaNetwork.list", group: "DIRECT"}
|
||||
- {import: snippets/rulesets.txt}
|
||||
|
||||
proxy_group:
|
||||
custom_proxy_group:
|
||||
# - {name: UrlTest, type: url-test, rule: [".*"], url: http://www.gstatic.com/generate_204, interval: 300}
|
||||
# - {name: Proxy, type: select, rule: [".*"]}
|
||||
# - {name: group1, type: select, rule: ["!!GROUPID=0"]}
|
||||
# - {name: v2ray, type: select, rule: ["!!GROUP=V2RayProvider"]}
|
||||
# - {import: snippets/groups_forcerule.txt}
|
||||
# - {name: ssid group, type: ssid, rule: ["default_group", "celluar=group0,ssid1=group1,ssid2=group2"]}
|
||||
- {import: snippets/groups.txt}
|
||||
|
||||
server:
|
||||
listen: 0.0.0.0
|
||||
port: 25500
|
||||
|
||||
advanced:
|
||||
print_debug_info: false
|
||||
max_pending_connections: 10240
|
||||
max_concurrent_threads: 4
|
||||
|
||||
17
src/main.cpp
17
src/main.cpp
@@ -118,6 +118,11 @@ int importItems(string_array &target)
|
||||
while(getline(ss, strLine, delimiter))
|
||||
{
|
||||
lineSize = strLine.size();
|
||||
if(strLine[lineSize - 1] == '\r') //remove line break
|
||||
{
|
||||
strLine = strLine.substr(0, lineSize - 1);
|
||||
lineSize--;
|
||||
}
|
||||
if(!lineSize || strLine[0] == ';' || strLine[0] == '#' || (lineSize >= 2 && strLine[0] == '/' && strLine[1] == '/')) //empty lines and comments are ignored
|
||||
continue;
|
||||
result.emplace_back(strLine);
|
||||
@@ -205,19 +210,17 @@ void readGroup(YAML::Node node, string_array &dest)
|
||||
object["type"] >> type;
|
||||
tempArray.emplace_back(name);
|
||||
tempArray.emplace_back(type);
|
||||
if(object["url"].as<std::string>().size())
|
||||
object["url"] >> url;
|
||||
if(object["interval"].as<std::string>().size())
|
||||
object["interval"] >> interval;
|
||||
object["url"] >> url;
|
||||
object["interval"] >> interval;
|
||||
for(j = 0; j < object["rule"].size(); j++)
|
||||
tempArray.emplace_back(object["rule"][i].as<std::string>());
|
||||
if(type != "select")
|
||||
tempArray.emplace_back(object["rule"][j].as<std::string>());
|
||||
if(type != "select" && type != "ssid")
|
||||
{
|
||||
tempArray.emplace_back(url);
|
||||
tempArray.emplace_back(interval);
|
||||
}
|
||||
|
||||
if((type == "select" && tempArray.size() < 3) || (type != "select" && tempArray.size() < 5))
|
||||
if((type == "select" && tempArray.size() < 3) || (type == "ssid" && tempArray.size() < 4) || (type != "select" && type != "ssid" && tempArray.size() < 5))
|
||||
continue;
|
||||
|
||||
strLine = std::accumulate(std::next(tempArray.begin()), tempArray.end(), tempArray[0], [](std::string a, std::string b) -> std::string
|
||||
|
||||
@@ -955,8 +955,8 @@ std::string netchToSurge(std::vector<nodeInfo> &nodes, std::string &base_conf, s
|
||||
{
|
||||
if(vArray.size() < 4)
|
||||
continue;
|
||||
proxy = vArray[1] + ",default=" + vArray[2];
|
||||
proxy += std::accumulate(vArray.begin() + 3, vArray.end(), vArray[3], [](std::string a, std::string b)
|
||||
proxy = vArray[1] + ",default=" + vArray[2] + ",";
|
||||
proxy += std::accumulate(vArray.begin() + 4, vArray.end(), vArray[3], [](std::string a, std::string b)
|
||||
{
|
||||
return std::move(a) + "," + std::move(b);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user