update 2026-10-01 01:27:34

This commit is contained in:
action committed 2026-10-01 01:27:34 +08:00
1 parent 9f80d5fed4
commit 4596096d87
1983 files changed
+794 -1523373

No files matched your search

@@ -153,7 +153,7 @@ function copy_instance(var)
tinsert(conf_lines, "port=" .. LISTEN_PORT)
if TMP_DNSMASQ_PATH then
sys.call("rm -rf " .. TMP_DNSMASQ_PATH .. "/*passwall*")
api.remove(TMP_DNSMASQ_PATH .. "/*passwall*")
end
if var["-return"] == "1" then
return conf_lines
@@ -193,7 +193,7 @@ function add_rule(var)
local CACHE_TEXT_FILE = CACHE_DNS_PATH .. ".txt"
local USE_CHINADNS_NG = "0"
local IS_SHUNT_NODE = api.uci_get_c(NODE, "protocol") == "_shunt"
local USE_GEOVIEW = api.uci_get_c("@global_rules[0]", "enable_geoview")
local USE_GEOVIEW = api.uci_get_c("@global_rules[0]", "enable_geoview") or "0"
local list1 = {}
local excluded_domain = {}
@@ -333,10 +333,8 @@ function add_rule(var)
pipe:close()
end
local function get_dns_config_hash()
local nodes_address_md5 = sys.exec([[uci show passwall | grep -E '\.(address|download_address|domain_resolver_dns|domain_resolver_dns_https)=' | cut -d "'" -f 2 | sort -u | md5sum | awk '{printf "%s", $1}']])
local sub_url_md5 = sys.exec([[uci show passwall | grep -E '^passwall\.sub_[^.]+\.url=' | cut -d "'" -f 2 | sort -u | md5sum | awk '{printf "%s", $1}']])
nodes_address_md5 = nodes_address_md5 .. sub_url_md5
local function get_dns_config_key()
local address_md5 = api.md5_string(sys.exec([[uci show passwall | grep -E '\.(address|download_address|domain_resolver_dns|domain_resolver_dns_https)=|^passwall\.sub_[^.]+\.url=' | cut -d "'" -f 2 | sort -u]]))
local new_rules = sys.exec([[
for f in \
/usr/share/passwall/rules/chnlist \
@@ -358,8 +356,8 @@ function add_rule(var)
end
end)
end
new_rules = new_rules .. sys.exec("printf '%s' " .. api.base64Encode(SHUNT_LIST) .. " | md5sum | awk '{printf \"%s\", $1}'")
return TMP_DNSMASQ_PATH .. DNSMASQ_CONF_FILE .. DEFAULT_DNS .. LOCAL_DNS .. TUN_DNS .. USE_DEFAULT_DNS .. CHINADNS_DNS .. USE_DIRECT_LIST .. USE_PROXY_LIST .. USE_BLOCK_LIST .. USE_GFW_LIST .. CHN_LIST .. DEFAULT_PROXY_MODE .. NO_PROXY_IPV6 .. nodes_address_md5 .. new_rules .. NFTFLAG
new_rules = new_rules .. api.md5_string(SHUNT_LIST)
return TMP_DNSMASQ_PATH .. DNSMASQ_CONF_FILE .. DEFAULT_DNS .. LOCAL_DNS .. TUN_DNS .. USE_DEFAULT_DNS .. CHINADNS_DNS .. USE_DIRECT_LIST .. USE_PROXY_LIST .. USE_BLOCK_LIST .. USE_GFW_LIST .. CHN_LIST .. DEFAULT_PROXY_MODE .. NO_PROXY_IPV6 .. address_md5 .. new_rules .. NFTFLAG .. USE_GEOVIEW
end
local dnsmasq_default_dns
@@ -397,8 +395,8 @@ function add_rule(var)
cache_text = line
end
end
new_text = get_dns_config_hash()
if cache_text ~= new_text then
new_text = get_dns_config_key()
if cache_text == "" or new_text == "" or cache_text ~= new_text then
api.remove(CACHE_DNS_PATH .. "*")
end
else
@@ -393,7 +393,7 @@ local function GeoToRule(rule_name, rule_type, out_path)
sys.exec(cmd)
local local_file_size = tonumber(fs.stat(out_path, "size") or 0)
if local_file_size == 0 then
os.remove(out_path)
api.remove(out_path)
log(rule_name .. " 生成失败,请确保 Geo 文件正确且包含目标规则。")
return false
end
@@ -425,7 +425,7 @@ local function fetch_rule(rule_name, rule_type, url, exclude_domain, max_retries
success = true
break
end
os.remove(current_file)
api.remove(current_file)
log(string.format("%s 第%d条规则下载失败 (HTTP:%s),正在进行第%d次尝试...", rule_name, k, tostring(http_code), i))
end
else
@@ -488,7 +488,7 @@ local function fetch_rule(rule_name, rule_type, url, exclude_domain, max_retries
sret = 1
log(string.format("%s 第%d条规则: %s 下载失败!", rule_name, k, v))
end
os.remove(current_file)
api.remove(current_file)
end
if sret == 0 then
@@ -502,8 +502,8 @@ local function fetch_rule(rule_name, rule_type, url, exclude_domain, max_retries
out:close()
end
local old_md5 = sys.exec(string.format("md5sum %s 2>/dev/null | awk '{print $1}'", rule_final_path)):gsub("\n", "")
local new_md5 = sys.exec(string.format("md5sum %s 2>/dev/null | awk '{print $1}'", file_tmp)):gsub("\n", "")
local old_md5 = api.md5_file(rule_final_path)
local new_md5 = api.md5_file(file_tmp)
if old_md5 ~= new_md5 then
if api.is_finded("fw4") and (rule_type == "ip4" or rule_type == "ip6") then
@@ -521,11 +521,11 @@ local function fetch_rule(rule_name, rule_type, url, exclude_domain, max_retries
log(string.format("%s 更新成功,总规则数 %d 条。", rule_name, #result_list))
else
log(rule_name .. " 版本一致,无需更新。")
os.remove(file_tmp)
api.remove(file_tmp)
end
else
log(rule_name .. " 更新失败(部分或全部资源无法下载)。")
os.remove(file_tmp)
api.remove(file_tmp)
end
return 0
end
@@ -568,7 +568,7 @@ local function fetch_geofile(geo_name, geo_type, url)
local sret_tmp, _, header = curl(url, tmp_path)
if sret_tmp == 0 and non_file_check(tmp_path, header) then
log(geo_type .. " 下载文件过程出错,尝试重新下载。")
os.remove(tmp_path)
api.remove(tmp_path)
sret_tmp, _, header= curl(url, tmp_path)
if sret_tmp == 0 and non_file_check(tmp_path, header) then
sret_tmp = 1
@@ -685,7 +685,7 @@ local function check_instance(action)
luci.sys.call("touch " .. rule_lock)
end
elseif action == "end" then
luci.sys.call("rm -f " .. rule_lock)
api.remove(rule_lock)
return
end
@@ -709,8 +709,8 @@ local function safe_call(func, err_msg)
end
local function remove_tmp_geofile(name)
os.remove("/tmp/" .. name .. ".dat")
os.remove("/tmp/" .. name .. ".dat.sha256sum")
api.remove("/tmp/" .. name .. ".dat")
api.remove("/tmp/" .. name .. ".dat.sha256sum")
end
if geo2rule == "1" then
@@ -1804,7 +1804,7 @@ local function curl(url, file, ua, mode)
header_str = header_str:gsub("\r", "")
end
luci.sys.call('rm -f "%s"' % cookie_file)
api.remove(cookie_file)
return return_code, http_code, header_str
end
@@ -2245,7 +2245,7 @@ local execute = function()
return_code, value.http_code, headers = curl(url, tmp_file, ua, access_mode)
if return_code ~= 0 then
fail_list[#fail_list + 1] = value
luci.sys.call("rm -f " .. tmp_file)
api.remove(tmp_file)
end
end
if fs.access(tmp_file) then
@@ -2255,8 +2255,8 @@ local execute = function()
f:close()
local raw_data = api.trim(stdout)
local old_md5 = value.md5 or ""
local new_md5 = luci.sys.exec("md5sum " .. tmp_file .. " 2>/dev/null | awk '{printf \"%s\", $1}'")
if not manual_sub and old_md5 == new_md5 then
local new_md5 = api.md5_file(tmp_file)
if not manual_sub and new_md5 ~= "" and old_md5 == new_md5 then
log('订阅:【' .. remark .. '】没有变化,无需更新。')
else
raw_data = parseClashNode(raw_data)
@@ -2268,7 +2268,7 @@ local execute = function()
fail_list[#fail_list + 1] = value
end
if not url_is_local then
luci.sys.call("rm -f " .. tmp_file)
api.remove(tmp_file)
end
end
end
@@ -2297,7 +2297,7 @@ local function check_instance(action)
uci:revert(c_config)
end
elseif action == "end" then
luci.sys.call("rm -f " .. sub_lock)
api.remove(sub_lock)
return
end
@@ -2328,7 +2328,7 @@ if arg[1] then
f:close()
parse_link(raw, "1", arg[2])
update_node(1)
luci.sys.call("rm -f /tmp/links.conf")
api.remove("/tmp/links.conf")
elseif arg[1] == "truncate" then
truncate_nodes(arg[2])
end