fix: persistent community subnet storage & reboot fallback for Telegram in section Main
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "fe-app-tachyon",
|
||||
"version": "1.2.34",
|
||||
"version": "1.2.35",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
@@ -2159,6 +2159,7 @@ function import_builtin_subnets_from_rule(section, settings) {
|
||||
continue;
|
||||
|
||||
let cached_file = TMP_RULESET_FOLDER + "/community-subnets-" + as_string(service) + ".lst";
|
||||
let persistent_file = "/etc/tachyon/rulesets/community-subnets-" + as_string(service) + ".lst";
|
||||
let combined_lines = [];
|
||||
for (let url in urls) {
|
||||
let tmpfile = temp_path();
|
||||
@@ -2167,11 +2168,16 @@ function import_builtin_subnets_from_rule(section, settings) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!download_to_file(url, tmpfile, service_proxy_address(settings, "lists")) || !file_nonempty(tmpfile)) {
|
||||
log_message("Failed to download built-in " + as_string(service) + " subnet list; skipping it until the next successful update", "warn");
|
||||
let downloaded = download_to_file(url, tmpfile, service_proxy_address(settings, "lists")) && file_nonempty(tmpfile);
|
||||
if (!downloaded) {
|
||||
remove_file(tmpfile);
|
||||
if (file_exists_value(persistent_file)) {
|
||||
tmpfile = persistent_file;
|
||||
} else {
|
||||
log_message("Failed to download built-in " + as_string(service) + " subnet list; skipping it until next update", "warn");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
let lines = split(as_string(fs.readfile(tmpfile)), "\n");
|
||||
for (let l in lines) {
|
||||
@@ -2180,7 +2186,7 @@ function import_builtin_subnets_from_rule(section, settings) {
|
||||
push(combined_lines, l);
|
||||
}
|
||||
|
||||
if (!nft_module_success([
|
||||
nft_module_success([
|
||||
"nft-add-community-subnet-file-for-uci-section",
|
||||
section_name(section),
|
||||
service,
|
||||
@@ -2195,15 +2201,17 @@ function import_builtin_subnets_from_rule(section, settings) {
|
||||
NFT_COMMON6_SET_NAME,
|
||||
NFT_IP_PORT6_SET_NAME,
|
||||
NFT_DISCORD6_SET_NAME
|
||||
]))
|
||||
ok = false;
|
||||
]);
|
||||
|
||||
if (downloaded)
|
||||
remove_file(tmpfile);
|
||||
}
|
||||
|
||||
if (length(combined_lines) > 0) {
|
||||
ensure_dir(TMP_RULESET_FOLDER);
|
||||
write_file(cached_file, join("\n", combined_lines) + "\n");
|
||||
ensure_dir("/etc/tachyon/rulesets");
|
||||
write_file(persistent_file, join("\n", combined_lines) + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ function detect_installed_version() {
|
||||
}
|
||||
}
|
||||
|
||||
return "1.2.34";
|
||||
return "1.2.35";
|
||||
}
|
||||
|
||||
function constants_map() {
|
||||
|
||||
@@ -1121,23 +1121,23 @@ function add_excluded_ips_rule(config, section) {
|
||||
}
|
||||
|
||||
function load_community_subnet_cidrs(community) {
|
||||
let path = "/tmp/sing-box/rulesets/community-subnets-" + as_string(community) + ".lst";
|
||||
let paths = [
|
||||
"/tmp/sing-box/rulesets/community-subnets-" + as_string(community) + ".lst",
|
||||
"/etc/tachyon/rulesets/community-subnets-" + as_string(community) + ".lst",
|
||||
(ctx.runtime_ruleset_folder || runtime_ruleset_folder || "/tmp/sing-box/rulesets") + "/community-subnets-" + as_string(community) + ".lst"
|
||||
];
|
||||
for (let path in paths) {
|
||||
let content = fs.readfile(path);
|
||||
if (content == null || content == "") {
|
||||
let folder = ctx.runtime_ruleset_folder || runtime_ruleset_folder || "/tmp/sing-box/rulesets";
|
||||
path = folder + "/community-subnets-" + as_string(community) + ".lst";
|
||||
content = fs.readfile(path);
|
||||
}
|
||||
if (content == null || content == "")
|
||||
return [];
|
||||
|
||||
if (content != null && content != "") {
|
||||
let cidrs = [];
|
||||
for (let line in split(as_string(content), "\n")) {
|
||||
line = trim(replace(as_string(line), /\r/g, ""));
|
||||
if (line != "" && substr(line, 0, 1) != "#")
|
||||
push(cidrs, line);
|
||||
}
|
||||
return cidrs;
|
||||
}
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
function add_combined_route_for_section(config, section) {
|
||||
|
||||
Reference in New Issue
Block a user