From 69aece8f3f7055c59ef01d71ddb4b8bb2be5ac60 Mon Sep 17 00:00:00 2001 From: actions-user Date: Wed, 5 Mar 2025 00:17:12 +0800 Subject: [PATCH] update 2025-03-05 00:17:12 --- .../luasrc/model/cbi/passwall/client/rule.lua | 47 ++++++++++++------- luci-app-passwall/po/zh-cn/passwall.po | 10 +++- .../root/usr/share/passwall/0_default_config | 2 + .../root/usr/share/passwall/app.sh | 23 ++++----- .../share/passwall/helper_chinadns_add.lua | 2 +- .../share/passwall/helper_smartdns_add.lua | 2 +- .../root/usr/share/passwall/rule_update.lua | 4 +- 7 files changed, 53 insertions(+), 37 deletions(-) diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/rule.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/rule.lua index 48395352..592823e3 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/rule.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/rule.lua @@ -45,7 +45,34 @@ o:value("https://fastly.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/chi o:value("https://fastly.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/apple-cn.txt", translate("Loyalsoldier/apple-cn")) o:value("https://fastly.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/google-cn.txt", translate("Loyalsoldier/google-cn")) -s:append(Template(appname .. "/rule/rule_version")) +if has_xray or has_singbox then + o = s:option(ListValue, "geoip_url", translate("GeoIP Update URL")) + o:value("https://api.github.com/repos/Loyalsoldier/v2ray-rules-dat/releases/latest", translate("Loyalsoldier/geoip")) + o:value("https://api.github.com/repos/MetaCubeX/meta-rules-dat/releases/latest", translate("MetaCubeX/geoip")) + o.default = "https://api.github.com/repos/Loyalsoldier/v2ray-rules-dat/releases/latest" + + o = s:option(ListValue, "geosite_url", translate("Geosite Update URL")) + o:value("https://api.github.com/repos/Loyalsoldier/v2ray-rules-dat/releases/latest", translate("Loyalsoldier/geosite")) + o:value("https://api.github.com/repos/MetaCubeX/meta-rules-dat/releases/latest", translate("MetaCubeX/geosite")) + o.default = "https://api.github.com/repos/Loyalsoldier/v2ray-rules-dat/releases/latest" + + o = s:option(Value, "v2ray_location_asset", translate("Location of Geo rule files"), translate("This variable specifies a directory where geoip.dat and geosite.dat files are.")) + o.default = "/usr/share/v2ray/" + o.placeholder = "/usr/share/v2ray/" + o.rmempty = false + + if api.is_finded("geoview") then + o = s:option(Flag, "enable_geoview", translate("Enable Geo Data Parsing")) + o.default = 0 + o.rmempty = false + o.description = "" + end +end ---- Auto Update o = s:option(Flag, "auto_update", translate("Enable auto update rules")) @@ -88,23 +115,9 @@ o.default = 2 o:depends("week_update", "8") o.rmempty = true +s:append(Template(appname .. "/rule/rule_version")) + if has_xray or has_singbox then - o = s:option(Value, "v2ray_location_asset", translate("Location of V2ray/Xray asset"), translate("This variable specifies a directory where geoip.dat and geosite.dat files are.")) - o.default = "/usr/share/v2ray/" - o.rmempty = false - - if api.is_finded("geoview") then - o = s:option(Flag, "enable_geoview", translate("Enable Geo Data Parsing")) - o.default = 0 - o.rmempty = false - o.description = "" - end - s = m:section(TypedSection, "shunt_rules", "Sing-Box/Xray " .. translate("Shunt Rule"), "" .. translate("Please note attention to the priority, the higher the order, the higher the priority.") .. "") s.template = "cbi/tblsection" s.anonymous = false diff --git a/luci-app-passwall/po/zh-cn/passwall.po b/luci-app-passwall/po/zh-cn/passwall.po index a831b184..929cd133 100644 --- a/luci-app-passwall/po/zh-cn/passwall.po +++ b/luci-app-passwall/po/zh-cn/passwall.po @@ -937,8 +937,14 @@ msgstr "小时" msgid "Hour" msgstr "小时" -msgid "Location of V2ray/Xray asset" -msgstr "V2ray/Xray 资源文件目录" +msgid "GeoIP Update URL" +msgstr "GeoIP 更新URL" + +msgid "Geosite Update URL" +msgstr "Geosite 更新URL" + +msgid "Location of Geo rule files" +msgstr "Geo 规则文件目录" msgid "This variable specifies a directory where geoip.dat and geosite.dat files are." msgstr "此变量指定 geoip.dat 和 geosite.dat 文件所在的目录。" diff --git a/luci-app-passwall/root/usr/share/passwall/0_default_config b/luci-app-passwall/root/usr/share/passwall/0_default_config index a99cf333..d665ed8e 100644 --- a/luci-app-passwall/root/usr/share/passwall/0_default_config +++ b/luci-app-passwall/root/usr/share/passwall/0_default_config @@ -72,6 +72,8 @@ config global_rules list chnlist_url 'https://fastly.jsdelivr.net/gh/felixonmars/dnsmasq-china-list/accelerated-domains.china.conf' list chnlist_url 'https://fastly.jsdelivr.net/gh/felixonmars/dnsmasq-china-list/apple.china.conf' option v2ray_location_asset '/usr/share/v2ray/' + option geoip_url 'https://api.github.com/repos/Loyalsoldier/v2ray-rules-dat/releases/latest' + option geosite_url 'https://api.github.com/repos/Loyalsoldier/v2ray-rules-dat/releases/latest' config global_app option singbox_file '/usr/bin/sing-box' diff --git a/luci-app-passwall/root/usr/share/passwall/app.sh b/luci-app-passwall/root/usr/share/passwall/app.sh index 189754cd..d125bedc 100755 --- a/luci-app-passwall/root/usr/share/passwall/app.sh +++ b/luci-app-passwall/root/usr/share/passwall/app.sh @@ -350,8 +350,7 @@ parse_doh() { get_geoip() { local geoip_code="$1" local geoip_type_flag="" - local geoip_path="$(config_t_get global_rules v2ray_location_asset)" - geoip_path="${geoip_path%*/}/geoip.dat" + local geoip_path="${V2RAY_LOCATION_ASSET%*/}/geoip.dat" [ -s "$geoip_path" ] || { echo ""; return 1; } case "$2" in "ipv4") geoip_type_flag="-ipv6=false" ;; @@ -777,9 +776,8 @@ run_redir() { sing-box) local protocol=$(config_n_get $node protocol) [ "$protocol" = "_shunt" ] && { - local geo_path="$(config_t_get global_rules v2ray_location_asset)" - local geoip_path="${geo_path%*/}/geoip.dat" - local geosite_path="${geo_path%*/}/geosite.dat" + local geoip_path="${V2RAY_LOCATION_ASSET%*/}/geoip.dat" + local geosite_path="${V2RAY_LOCATION_ASSET%*/}/geosite.dat" if [ ! -s "$geoip_path" ] || [ ! -s "$geosite_path" ]; then echolog "* 缺少Geo规则文件,UDP Sing-Box分流节点无法正常使用!" fi @@ -789,9 +787,8 @@ run_redir() { xray) local protocol=$(config_n_get $node protocol) [ "$protocol" = "_shunt" ] && { - local geo_path="$(config_t_get global_rules v2ray_location_asset)" - local geoip_path="${geo_path%*/}/geoip.dat" - local geosite_path="${geo_path%*/}/geosite.dat" + local geoip_path="${V2RAY_LOCATION_ASSET%*/}/geoip.dat" + local geosite_path="${V2RAY_LOCATION_ASSET%*/}/geosite.dat" if [ ! -s "$geoip_path" ] || [ ! -s "$geosite_path" ]; then echolog "* 缺少Geo规则文件,UDP Xray分流节点无法正常使用!" fi @@ -896,9 +893,8 @@ run_redir() { } [ "$protocol" = "_shunt" ] && { - local geo_path="$(config_t_get global_rules v2ray_location_asset)" - local geoip_path="${geo_path%*/}/geoip.dat" - local geosite_path="${geo_path%*/}/geosite.dat" + local geoip_path="${V2RAY_LOCATION_ASSET%*/}/geoip.dat" + local geosite_path="${V2RAY_LOCATION_ASSET%*/}/geosite.dat" if [ ! -s "$geoip_path" ] || [ ! -s "$geosite_path" ]; then echolog "* 缺少Geo规则文件,TCP Sing-Box分流节点无法正常使用!" fi @@ -983,9 +979,8 @@ run_redir() { } [ "$protocol" = "_shunt" ] && { - local geo_path="$(config_t_get global_rules v2ray_location_asset)" - local geoip_path="${geo_path%*/}/geoip.dat" - local geosite_path="${geo_path%*/}/geosite.dat" + local geoip_path="${V2RAY_LOCATION_ASSET%*/}/geoip.dat" + local geosite_path="${V2RAY_LOCATION_ASSET%*/}/geosite.dat" if [ ! -s "$geoip_path" ] || [ ! -s "$geosite_path" ]; then echolog "* 缺少Geo规则文件,TCP Xray分流节点无法正常使用!" fi diff --git a/luci-app-passwall/root/usr/share/passwall/helper_chinadns_add.lua b/luci-app-passwall/root/usr/share/passwall/helper_chinadns_add.lua index b7b06396..3542fc35 100644 --- a/luci-app-passwall/root/usr/share/passwall/helper_chinadns_add.lua +++ b/luci-app-passwall/root/usr/share/passwall/helper_chinadns_add.lua @@ -88,7 +88,7 @@ local function insert_array_after(array1, array2, target) --将array2插入到ar end local function get_geosite(list_arg, out_path) - local geosite_path = uci:get(appname, "@global_rules[0]", "v2ray_location_asset") + local geosite_path = uci:get(appname, "@global_rules[0]", "v2ray_location_asset") or "/usr/share/v2ray/" geosite_path = geosite_path:match("^(.*)/") .. "/geosite.dat" if not is_file_nonzero(geosite_path) then return 1 end if api.is_finded("geoview") and list_arg and out_path then diff --git a/luci-app-passwall/root/usr/share/passwall/helper_smartdns_add.lua b/luci-app-passwall/root/usr/share/passwall/helper_smartdns_add.lua index 3e71c5b2..97591ea8 100644 --- a/luci-app-passwall/root/usr/share/passwall/helper_smartdns_add.lua +++ b/luci-app-passwall/root/usr/share/passwall/helper_smartdns_add.lua @@ -92,7 +92,7 @@ local function insert_array_after(array1, array2, target) --将array2插入到ar end local function get_geosite(list_arg, out_path) - local geosite_path = uci:get(appname, "@global_rules[0]", "v2ray_location_asset") + local geosite_path = uci:get(appname, "@global_rules[0]", "v2ray_location_asset") or "/usr/share/v2ray/" geosite_path = geosite_path:match("^(.*)/") .. "/geosite.dat" if not is_file_nonzero(geosite_path) then return 1 end if api.is_finded("geoview") and list_arg and out_path then diff --git a/luci-app-passwall/root/usr/share/passwall/rule_update.lua b/luci-app-passwall/root/usr/share/passwall/rule_update.lua index 6f077cbe..b1aee975 100755 --- a/luci-app-passwall/root/usr/share/passwall/rule_update.lua +++ b/luci-app-passwall/root/usr/share/passwall/rule_update.lua @@ -33,8 +33,8 @@ local gfwlist_url = uci:get(name, "@global_rules[0]", "gfwlist_url") or {"https: local chnroute_url = uci:get(name, "@global_rules[0]", "chnroute_url") or {"https://ispip.clang.cn/all_cn.txt"} local chnroute6_url = uci:get(name, "@global_rules[0]", "chnroute6_url") or {"https://ispip.clang.cn/all_cn_ipv6.txt"} local chnlist_url = uci:get(name, "@global_rules[0]", "chnlist_url") or {"https://fastly.jsdelivr.net/gh/felixonmars/dnsmasq-china-list/accelerated-domains.china.conf","https://fastly.jsdelivr.net/gh/felixonmars/dnsmasq-china-list/apple.china.conf","https://fastly.jsdelivr.net/gh/felixonmars/dnsmasq-china-list/google.china.conf"} -local geoip_api = "https://api.github.com/repos/Loyalsoldier/v2ray-rules-dat/releases/latest" -local geosite_api = "https://api.github.com/repos/Loyalsoldier/v2ray-rules-dat/releases/latest" +local geoip_api = uci:get(name, "@global_rules[0]", "geoip_url") or "https://api.github.com/repos/Loyalsoldier/v2ray-rules-dat/releases/latest" +local geosite_api = uci:get(name, "@global_rules[0]", "geosite_url") or "https://api.github.com/repos/Loyalsoldier/v2ray-rules-dat/releases/latest" local asset_location = uci:get(name, "@global_rules[0]", "v2ray_location_asset") or "/usr/share/v2ray/" local use_nft = uci:get(name, "@global_forwarding[0]", "use_nft") or "0"