mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-11-02 21:33:56 +08:00
update 2026-10-24 00:18:10
This commit is contained in:
1 parent
0dc3af034c
commit
015941ec68
78 files changed
+23
-21821
No files matched your search
@@ -45,12 +45,10 @@ local function log(...)
|
||||
end
|
||||
|
||||
local function is_file_nonzero(path)
|
||||
if path and #path > 1 then
|
||||
if sys.exec('[ -s "%s" ] && echo -n 1' % path) == "1" then
|
||||
return true
|
||||
end
|
||||
if path and #path > 1 and (fs.stat(path, "size") or 0) > 0 then
|
||||
return true
|
||||
end
|
||||
return nil
|
||||
return false
|
||||
end
|
||||
|
||||
local function insert_unique(dest_table, value, lookup_table)
|
||||
|
||||
@@ -63,15 +63,8 @@ function stretch()
|
||||
if not _flag and dnsmasq_noresolv == "1" then
|
||||
api.uci_del("dhcp", "@dnsmasq[0]", "noresolv")
|
||||
local RESOLVFILE = "/tmp/resolv.conf.d/resolv.conf.auto"
|
||||
local file = io.open(RESOLVFILE, "r")
|
||||
if not file then
|
||||
if (fs.stat(RESOLVFILE, "size") or 0) == 0 then
|
||||
RESOLVFILE = "/tmp/resolv.conf.auto"
|
||||
else
|
||||
local size = file:seek("end")
|
||||
file:close()
|
||||
if size == 0 then
|
||||
RESOLVFILE = "/tmp/resolv.conf.auto"
|
||||
end
|
||||
end
|
||||
api.uci_set("dhcp", "@dnsmasq[0]", "resolvfile", RESOLVFILE)
|
||||
api.uci_save(nil, "dhcp", true)
|
||||
|
||||
@@ -58,12 +58,10 @@ local function log(...)
|
||||
end
|
||||
|
||||
local function is_file_nonzero(path)
|
||||
if path and #path > 1 then
|
||||
if sys.exec('[ -s "%s" ] && echo -n 1' % path) == "1" then
|
||||
return true
|
||||
end
|
||||
if path and #path > 1 and (fs.stat(path, "size") or 0) > 0 then
|
||||
return true
|
||||
end
|
||||
return nil
|
||||
return false
|
||||
end
|
||||
|
||||
local function insert_unique(dest_table, value, lookup_table)
|
||||
|
||||
@@ -402,20 +402,18 @@ local function GeoToRule(rule_name, rule_type, out_path)
|
||||
log("[警告] Geoview 组件缺失或版本过低,规则生成流程已被跳过。")
|
||||
return false
|
||||
end
|
||||
local geosite_path = asset_location .. "geosite.dat"
|
||||
local geoip_path = asset_location .. "geoip.dat"
|
||||
local file_path = (rule_type == "domain") and geosite_path or geoip_path
|
||||
local geo_arg
|
||||
if rule_type == "domain" then
|
||||
if rule_name == "gfwlist" then
|
||||
geo_arg = "-type geosite -list gfw"
|
||||
else
|
||||
geo_arg = "-type geosite -list cn"
|
||||
end
|
||||
elseif rule_type == "ip4" then
|
||||
geo_arg = "-type geoip -list cn -ipv6=false"
|
||||
local geo_type = (rule_type == "domain") and "geosite" or "geoip"
|
||||
local geo_tag = (rule_type == "domain" and rule_name == "gfwlist") and "gfw" or "cn"
|
||||
local file_path = asset_location .. geo_type .. ".dat"
|
||||
if sys.call(string.format('"%s" -type %s -input "%s" | grep -q "^%s$"', bin, geo_type, file_path, geo_tag:upper())) ~= 0 then
|
||||
log(string.format("%s 生成失败:%s.dat 中缺少 %s 标签。", rule_name, geo_type, geo_tag))
|
||||
return false
|
||||
end
|
||||
local geo_arg = "-type " .. geo_type .. " -list " .. geo_tag
|
||||
if rule_type == "ip4" then
|
||||
geo_arg = geo_arg .. " -ipv6=false"
|
||||
elseif rule_type == "ip6" then
|
||||
geo_arg = "-type geoip -list cn -ipv4=false"
|
||||
geo_arg = geo_arg .. " -ipv4=false"
|
||||
end
|
||||
local cmd = string.format(bin .. " -input '%s' %s -lowmem=true -output '%s'", file_path, geo_arg, out_path)
|
||||
sys.exec(cmd)
|
||||
|
||||
Reference in new issue
Block a user