luci-app-passwall: sync upstream

last commit: 440f94a6da
This commit is contained in:
gitea-action 2025-03-21 21:32:45 +08:00
parent a870f4b25a
commit 4913327c1d

View File

@ -15,9 +15,9 @@ local geoip_all_tag = {}
local srss_path = "/tmp/etc/" .. appname .."/srss/" local srss_path = "/tmp/etc/" .. appname .."/srss/"
local function convert_geofile() local function convert_geofile()
local geo_path = uci:get(appname, "@global_rules[0]", "v2ray_location_asset") or "/usr/share/v2ray/" local geo_dir = (uci:get(appname, "@global_rules[0]", "v2ray_location_asset") or "/usr/share/v2ray/"):match("^(.*)/")
local geosite_path = geo_path:match("^(.*)/") .. "/geosite.dat" local geosite_path = geo_dir .. "/geosite.dat"
local geoip_path = geo_path:match("^(.*)/") .. "/geoip.dat" local geoip_path = geo_dir .. "/geoip.dat"
if not api.is_finded("geoview") then if not api.is_finded("geoview") then
api.log("* 注意:缺少 geoview 组件Sing-Box 分流将无法启用!") api.log("* 注意:缺少 geoview 组件Sing-Box 分流将无法启用!")
return return
@ -25,24 +25,23 @@ local function convert_geofile()
if not fs.access(srss_path) then if not fs.access(srss_path) then
fs.mkdir(srss_path) fs.mkdir(srss_path)
end end
if next(geosite_all_tag) and fs.access(geosite_path) then local function convert(file_path, prefix, tags)
for k,v in pairs(geosite_all_tag) do if next(tags) and fs.access(file_path) then
local srs_file = srss_path .. "geosite-" .. k ..".srs" for k in pairs(tags) do
if not fs.access(srs_file) then local srs_file = srss_path .. prefix .. "-" .. k .. ".srs"
sys.exec("geoview -type geosite -action convert -input " .. geosite_path .. " -list '" .. k .. "' -output " .. srs_file .. " -lowmem=true") if not fs.access(srs_file) then
--api.log("* 转换geosite:" .. k .. " 到 Sing-Box 规则集二进制文件") local cmd = string.format("geoview -type %s -action convert -input %s -list '%s' -output %s -lowmem=true",
end prefix, file_path, k, srs_file)
end sys.exec(cmd)
end local status = fs.access(srs_file) and "成功。" or "失败!"
if next(geoip_all_tag) and fs.access(geoip_path) then api.log(string.format(" - 转换 %s:%s ... %s", prefix, k, status))
for k,v in pairs(geoip_all_tag) do end
local srs_file = srss_path .. "geoip-" .. k ..".srs"
if not fs.access(srs_file) then
sys.exec("geoview -type geoip -action convert -input " .. geoip_path .. " -list '" .. k .. "' -output " .. srs_file .. " -lowmem=true")
--api.log("* 转换geoip:" .. k .. " 到 Sing-Box 规则集二进制文件")
end end
end end
end end
api.log("Sing-Box 规则集转换:")
convert(geosite_path, "geosite", geosite_all_tag)
convert(geoip_path, "geoip", geoip_all_tag)
end end
local new_port local new_port