From cad59407bf3ef2262daa24ec36bd9ed0d97ebff4 Mon Sep 17 00:00:00 2001 From: gitea-action Date: Sun, 9 Mar 2025 18:00:27 +0800 Subject: [PATCH] luci-app-passwall: sync upstream last commit: https://github.com/xiaorouji/openwrt-passwall/commit/338d2ec9010f8ad756ed89e8810f44c1502033cb --- luci-app-passwall/Makefile | 2 +- .../model/cbi/passwall/client/acl_config.lua | 5 +- .../model/cbi/passwall/client/global.lua | 7 +- .../model/cbi/passwall/client/other.lua | 36 ----- .../luasrc/model/cbi/passwall/client/rule.lua | 47 ++++-- .../cbi/passwall/client/type/sing-box.lua | 5 +- .../luasrc/passwall/util_sing-box.lua | 116 +++++++++++--- .../view/passwall/node_list/node_list.htm | 145 ++++++++++-------- luci-app-passwall/po/zh-cn/passwall.po | 28 +--- .../root/usr/share/passwall/0_default_config | 6 +- .../root/usr/share/passwall/app.sh | 21 ++- .../share/passwall/helper_chinadns_add.lua | 2 +- .../share/passwall/helper_smartdns_add.lua | 2 +- .../root/usr/share/passwall/rule_update.lua | 4 +- patch-luci-app-passwall.patch | 10 +- 15 files changed, 243 insertions(+), 193 deletions(-) diff --git a/luci-app-passwall/Makefile b/luci-app-passwall/Makefile index 8b2659417..54b5f1a0d 100644 --- a/luci-app-passwall/Makefile +++ b/luci-app-passwall/Makefile @@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-passwall -PKG_VERSION:=25.3.2 +PKG_VERSION:=25.3.9 PKG_RELEASE:=1 PKG_CONFIG_DEPENDS:= \ diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/acl_config.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/acl_config.lua index f05358ea0..101b81548 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/acl_config.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/acl_config.lua @@ -13,6 +13,7 @@ local fs = api.fs local sys = api.sys local has_singbox = api.finded_com("singbox") local has_xray = api.finded_com("xray") +local has_geoview = api.is_finded("geoview") local has_gfwlist = fs.access("/usr/share/passwall/rules/gfwlist") local has_chnlist = fs.access("/usr/share/passwall/rules/chnlist") local has_chnroute = fs.access("/usr/share/passwall/rules/chnroute") @@ -23,7 +24,9 @@ end local nodes_table = {} for k, e in ipairs(api.get_valid_nodes()) do - nodes_table[#nodes_table + 1] = e + if not(e.type == "sing-box" and e.protocol == "_shunt" and not has_geoview) then --Sing-Box分流节点缺少geoview组件时不允许使用 + nodes_table[#nodes_table + 1] = e + end end local dynamicList_write = function(self, section, value) diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua index d33a67969..fa97b4a90 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua @@ -4,6 +4,7 @@ local datatypes = api.datatypes local fs = api.fs local has_singbox = api.finded_com("singbox") local has_xray = api.finded_com("xray") +local has_geoview = api.is_finded("geoview") local has_gfwlist = fs.access("/usr/share/passwall/rules/gfwlist") local has_chnlist = fs.access("/usr/share/passwall/rules/chnlist") local has_chnroute = fs.access("/usr/share/passwall/rules/chnroute") @@ -14,7 +15,9 @@ api.set_apply_on_parse(m) local nodes_table = {} for k, e in ipairs(api.get_valid_nodes()) do - nodes_table[#nodes_table + 1] = e + if not(e.type == "sing-box" and e.protocol == "_shunt" and not has_geoview) then --Sing-Box分流节点缺少geoview组件时不允许使用 + nodes_table[#nodes_table + 1] = e + end end local normal_list = {} @@ -165,7 +168,7 @@ if (has_singbox or has_xray) and #nodes_table > 0 then local vid = v.id -- shunt node type, Sing-Box or Xray local type = s:taboption("Main", ListValue, vid .. "-type", translate("Type")) - if has_singbox then + if has_singbox and has_geoview then type:value("sing-box", "Sing-Box") end if has_xray then diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/other.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/other.lua index ff462fcdf..87501e9ca 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/other.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/other.lua @@ -242,42 +242,6 @@ if has_singbox then o.default = 0 o.rmempty = false o.description = translate("Override the connection destination address with the sniffed domain.
When enabled, traffic will match only by domain, ignoring IP rules.
If using shunt nodes, configure the domain shunt rules correctly.") - - o = s:option(Value, "geoip_path", translate("Custom geoip Path")) - o.default = "/usr/share/singbox/geoip.db" - o.rmempty = false - - o = s:option(Value, "geoip_url", translate("Custom geoip URL")) - o.default = "https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip.db" - o:value("https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip.db") - o:value("https://github.com/1715173329/sing-geoip/releases/latest/download/geoip.db") - o:value("https://github.com/lyc8503/sing-box-rules/releases/latest/download/geoip.db") - o.rmempty = false - - o = s:option(Value, "geosite_path", translate("Custom geosite Path")) - o.default = "/usr/share/singbox/geosite.db" - o.rmempty = false - - o = s:option(Value, "geosite_url", translate("Custom geosite URL")) - o.default = "https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geosite.db" - o:value("https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geosite.db") - o:value("https://github.com/1715173329/sing-geosite/releases/latest/download/geosite.db") - o:value("https://github.com/lyc8503/sing-box-rules/releases/latest/download/geosite.db") - o.rmempty = false - - o = s:option(Button, "_remove_resource", translate("Remove resource files")) - o.description = translate("Sing-Box will automatically download resource files when starting, you can use this feature achieve upgrade resource files.") - o.inputstyle = "remove" - function o.write(self, section, value) - local geoip_path = s.fields["geoip_path"] and s.fields["geoip_path"]:formvalue(section) or nil - if geoip_path then - os.remove(geoip_path) - end - local geosite_path = s.fields["geosite_path"] and s.fields["geosite_path"]:formvalue(section) or nil - if geosite_path then - os.remove(geosite_path) - end - end end return m 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 483953529..592823e3d 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/luasrc/model/cbi/passwall/client/type/sing-box.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/type/sing-box.lua index d826f3360..eb90c5da9 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/type/sing-box.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/type/sing-box.lua @@ -3,6 +3,7 @@ local m, s = ... local api = require "luci.passwall.api" local singbox_bin = api.finded_com("singbox") +local geoview_bin = api.is_finded("geoview") if not singbox_bin then return @@ -57,7 +58,9 @@ if singbox_tags:find("with_quic") then o:value("hysteria2", "Hysteria2") end o:value("_urltest", translate("URLTest")) -o:value("_shunt", translate("Shunt")) +if geoview_bin then --缺少geoview时禁用分流 + o:value("_shunt", translate("Shunt")) +end o:value("_iface", translate("Custom Interface")) o = s:option(Value, _n("iface"), translate("Interface")) diff --git a/luci-app-passwall/luasrc/passwall/util_sing-box.lua b/luci-app-passwall/luasrc/passwall/util_sing-box.lua index bd3a2688c..c4a26a761 100644 --- a/luci-app-passwall/luasrc/passwall/util_sing-box.lua +++ b/luci-app-passwall/luasrc/passwall/util_sing-box.lua @@ -10,6 +10,41 @@ local split = api.split local local_version = api.get_app_version("singbox") local version_ge_1_11_0 = api.compare_versions(local_version:match("[^v]+"), ">=", "1.11.0") +local geosite_all_tag = {} +local geoip_all_tag = {} +local srss_path = "/tmp/etc/" .. appname .."/srss/" + +local function convert_geofile() + local geo_path = uci:get(appname, "@global_rules[0]", "v2ray_location_asset") or "/usr/share/v2ray/" + local geosite_path = geo_path:match("^(.*)/") .. "/geosite.dat" + local geoip_path = geo_path:match("^(.*)/") .. "/geoip.dat" + if not api.is_finded("geoview") then + api.log("* 注意:缺少 geoview 组件,Sing-Box 分流将无法启用!") + return + end + if not fs.access(srss_path) then + fs.mkdir(srss_path) + end + if next(geosite_all_tag) and fs.access(geosite_path) then + for k,v in pairs(geosite_all_tag) do + local srs_file = srss_path .. "geosite-" .. k ..".srs" + if not fs.access(srs_file) then + sys.exec("geoview -type geosite -action convert -input " .. geosite_path .. " -list '" .. k .. "' -output " .. srs_file .. " -lowmem=true") + --api.log("* 转换geosite:" .. k .. " 到 Sing-Box 规则集二进制文件") + end + end + end + if next(geoip_all_tag) and fs.access(geoip_path) then + for k,v in pairs(geoip_all_tag) do + 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 + local new_port local function get_new_port() @@ -802,17 +837,7 @@ function gen_config(var) local singbox_settings = uci:get_all(appname, "@global_singbox[0]") or {} local route = { - rules = {}, - geoip = { - path = singbox_settings.geoip_path or "/usr/share/singbox/geoip.db", - download_url = singbox_settings.geoip_url or nil, - download_detour = nil, - }, - geosite = { - path = singbox_settings.geosite_path or "/usr/share/singbox/geosite.db", - download_url = singbox_settings.geosite_url or nil, - download_detour = nil, - }, + rules = {} } local experimental = nil @@ -1183,17 +1208,21 @@ function gen_config(var) end if e.source then - local source_geoip = {} local source_ip_cidr = {} + local is_private = false string.gsub(e.source, '[^' .. " " .. ']+', function(w) if w:find("geoip") == 1 then - table.insert(source_geoip, w) + local _geoip = w:sub(1 + #"geoip:") --适配srs + if _geoip == "private" then + is_private = true + end else table.insert(source_ip_cidr, w) end end) - rule.source_geoip = #source_geoip > 0 and source_geoip or nil + rule.source_ip_is_private = is_private and true or nil rule.source_ip_cidr = #source_ip_cidr > 0 and source_ip_cidr or nil + if is_private or #source_ip_cidr > 0 then rule.rule_set_ip_cidr_match_source = true end end if e.sourcePort then @@ -1224,6 +1253,8 @@ function gen_config(var) rule.port_range = #port_range > 0 and port_range or nil end + local rule_set_tag = {} + if e.domain_list then local domain_table = { outboundTag = outboundTag, @@ -1231,12 +1262,15 @@ function gen_config(var) domain_suffix = {}, domain_keyword = {}, domain_regex = {}, - geosite = {}, + rule_set = {}, } string.gsub(e.domain_list, '[^' .. "\r\n" .. ']+', function(w) if w:find("#") == 1 then return end if w:find("geosite:") == 1 then - table.insert(domain_table.geosite, w:sub(1 + #"geosite:")) + local _geosite = w:sub(1 + #"geosite:") --适配srs + geosite_all_tag[_geosite] = true + table.insert(rule_set_tag, "geosite-" .. _geosite) + table.insert(domain_table.rule_set, "geosite-" .. _geosite) elseif w:find("regexp:") == 1 then table.insert(domain_table.domain_regex, w:sub(1 + #"regexp:")) elseif w:find("full:") == 1 then @@ -1251,7 +1285,6 @@ function gen_config(var) rule.domain_suffix = #domain_table.domain_suffix > 0 and domain_table.domain_suffix or nil rule.domain_keyword = #domain_table.domain_keyword > 0 and domain_table.domain_keyword or nil rule.domain_regex = #domain_table.domain_regex > 0 and domain_table.domain_regex or nil - rule.geosite = #domain_table.geosite > 0 and domain_table.geosite or nil if outboundTag then table.insert(dns_domain_rules, api.clone(domain_table)) @@ -1260,20 +1293,28 @@ function gen_config(var) if e.ip_list then local ip_cidr = {} - local geoip = {} + local is_private = false string.gsub(e.ip_list, '[^' .. "\r\n" .. ']+', function(w) if w:find("#") == 1 then return end if w:find("geoip:") == 1 then - table.insert(geoip, w:sub(1 + #"geoip:")) + local _geoip = w:sub(1 + #"geoip:") --适配srs + if _geoip == "private" then + is_private = true + else + geoip_all_tag[_geoip] = true + table.insert(rule_set_tag, "geoip-" .. _geoip) + end else table.insert(ip_cidr, w) end end) + rule.ip_is_private = is_private and true or nil rule.ip_cidr = #ip_cidr > 0 and ip_cidr or nil - rule.geoip = #geoip > 0 and geoip or nil end + rule.rule_set = #rule_set_tag > 0 and rule_set_tag or nil --适配srs + table.insert(rules, rule) end end) @@ -1281,6 +1322,34 @@ function gen_config(var) for index, value in ipairs(rules) do table.insert(route.rules, rules[index]) end + + local rule_set = {} --适配srs + if next(geosite_all_tag) then + for k,v in pairs(geosite_all_tag) do + local srs_file = srss_path .. "geosite-" .. k ..".srs" + local _rule_set = { + tag = "geosite-" .. k, + type = "local", + format = "binary", + path = srs_file + } + table.insert(rule_set, _rule_set) + end + end + if next(geoip_all_tag) then + for k,v in pairs(geoip_all_tag) do + local srs_file = srss_path .. "geoip-" .. k ..".srs" + local _rule_set = { + tag = "geoip-" .. k, + type = "local", + format = "binary", + path = srs_file + } + table.insert(rule_set, _rule_set) + end + end + route.rule_set = #rule_set >0 and rule_set or nil + elseif node.protocol == "_urltest" then if node.urltest_node then COMMON.default_outbound_tag = gen_urltest(node) @@ -1470,14 +1539,14 @@ function gen_config(var) --按分流顺序DNS if dns_domain_rules and #dns_domain_rules > 0 then for index, value in ipairs(dns_domain_rules) do - if value.outboundTag and (value.domain or value.domain_suffix or value.domain_keyword or value.domain_regex or value.geosite) then + if value.outboundTag and (value.domain or value.domain_suffix or value.domain_keyword or value.domain_regex or value.rule_set) then local dns_rule = { server = value.outboundTag, domain = (value.domain and #value.domain > 0) and value.domain or nil, domain_suffix = (value.domain_suffix and #value.domain_suffix > 0) and value.domain_suffix or nil, domain_keyword = (value.domain_keyword and #value.domain_keyword > 0) and value.domain_keyword or nil, domain_regex = (value.domain_regex and #value.domain_regex > 0) and value.domain_regex or nil, - geosite = (value.geosite and #value.geosite > 0) and value.geosite or nil, + rule_set = (value.rule_set and #value.rule_set > 0) and value.rule_set or nil, --适配srs disable_cache = false, } if value.outboundTag ~= "block" and value.outboundTag ~= "direct" then @@ -1737,5 +1806,8 @@ if arg[1] then local func =_G[arg[1]] if func then print(func(api.get_function_args(arg))) + if next(geosite_all_tag) or next(geoip_all_tag) then + convert_geofile() + end end end diff --git a/luci-app-passwall/luasrc/view/passwall/node_list/node_list.htm b/luci-app-passwall/luasrc/view/passwall/node_list/node_list.htm index 6bbd2b0bf..ef64abace 100644 --- a/luci-app-passwall/luasrc/view/passwall/node_list/node_list.htm +++ b/luci-app-passwall/luasrc/view/passwall/node_list/node_list.htm @@ -313,82 +313,84 @@ table td, .table .td { } /* 自动Ping */ - if (auto_detection_time == "icmp" || auto_detection_time == "tcping") { - var nodes = []; - const ping_value = document.getElementsByClassName(auto_detection_time == "tcping" ? 'tcping_value' : 'ping_value'); - for (var i = 0; i < ping_value.length; i++) { - var cbi_id = ping_value[i].getAttribute("cbiid"); - var full = get_address_full(cbi_id); - if (full != null) { - var flag = false; - //当有多个相同地址和端口时合在一起 - for (var j = 0; j < nodes.length; j++) { - if (nodes[j].address == full.address && nodes[j].port == full.port) { - nodes[j].indexs = nodes[j].indexs + "," + i; - flag = true; - break; + function pingAllNodes() { + if (auto_detection_time == "icmp" || auto_detection_time == "tcping") { + var nodes = []; + const ping_value = document.getElementsByClassName(auto_detection_time == "tcping" ? 'tcping_value' : 'ping_value'); + for (var i = 0; i < ping_value.length; i++) { + var cbi_id = ping_value[i].getAttribute("cbiid"); + var full = get_address_full(cbi_id); + if (full != null) { + var flag = false; + //当有多个相同地址和端口时合在一起 + for (var j = 0; j < nodes.length; j++) { + if (nodes[j].address == full.address && nodes[j].port == full.port) { + nodes[j].indexs = nodes[j].indexs + "," + i; + flag = true; + break; + } } + if (flag) + continue; + nodes.push({ + indexs: i + "", + address: full.address, + port: full.port + }); } - if (flag) - continue; - nodes.push({ - indexs: i + "", - address: full.address, - port: full.port - }); } - } - const _xhr = (index) => { - return new Promise((res) => { - const dom = nodes[index]; - if (!dom) res() - ajax.post('<%=api.url("ping_node")%>', { - index: dom.indexs, - address: dom.address, - port: dom.port, - type: auto_detection_time - }, - function(x, result) { - if (x && x.status == 200) { - var strs = dom.indexs.split(","); - for (var i = 0; i < strs.length; i++) { - if (result.ping == null || result.ping.trim() == "") { - ping_value[strs[i]].innerHTML = "<%:Timeout%>"; - } else { - var ping = parseInt(result.ping); - if (ping < 100) - ping_value[strs[i]].innerHTML = "" + result.ping + " ms" + ""; - else if (ping < 200) - ping_value[strs[i]].innerHTML = "" + result.ping + " ms" + ""; - else if (ping >= 200) - ping_value[strs[i]].innerHTML = "" + result.ping + " ms" + ""; + const _xhr = (index) => { + return new Promise((res) => { + const dom = nodes[index]; + if (!dom) res() + ajax.post('<%=api.url("ping_node")%>', { + index: dom.indexs, + address: dom.address, + port: dom.port, + type: auto_detection_time + }, + function(x, result) { + if (x && x.status == 200) { + var strs = dom.indexs.split(","); + for (var i = 0; i < strs.length; i++) { + if (result.ping == null || result.ping.trim() == "") { + ping_value[strs[i]].innerHTML = "<%:Timeout%>"; + } else { + var ping = parseInt(result.ping); + if (ping < 100) + ping_value[strs[i]].innerHTML = "" + result.ping + " ms" + ""; + else if (ping < 200) + ping_value[strs[i]].innerHTML = "" + result.ping + " ms" + ""; + else if (ping >= 200) + ping_value[strs[i]].innerHTML = "" + result.ping + " ms" + ""; + } } } + res(); + }, + 5000, + function(x) { + var strs = dom.indexs.split(","); + for (var i = 0; i < strs.length; i++) { + ping_value[strs[i]].innerHTML = "<%:Timeout%>"; + } + res(); } - res(); - }, - 5000, - function(x) { - var strs = dom.indexs.split(","); - for (var i = 0; i < strs.length; i++) { - ping_value[strs[i]].innerHTML = "<%:Timeout%>"; - } - res(); - } - ); - }) - } - - let task = -1; - const thread = () => { - task = task + 1 - if (nodes[task]) { - _xhr(task).then(thread); + ); + }) + } + + let task = -1; + const thread = () => { + task = task + 1 + if (nodes[task]) { + _xhr(task).then(thread); + } + } + for (let i = 0; i < 20; i++) { + thread() } - } - for (let i = 0; i < 20; i++) { - thread() } } @@ -445,6 +447,13 @@ table td, .table .td { } document.getElementById("div_node_count").innerHTML = "
" + str + "
"; } + + //UI渲染完成后再自动Ping + window.onload = function () { + setTimeout(function () { + pingAllNodes(); + }, 800); + }; //]]> diff --git a/luci-app-passwall/po/zh-cn/passwall.po b/luci-app-passwall/po/zh-cn/passwall.po index 4c93e477c..929cd133b 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 文件所在的目录。" @@ -1633,24 +1639,6 @@ msgstr "端口跳跃额外端口" msgid "HeartbeatPeriod(second)" msgstr "心跳周期(单位:秒)" -msgid "Custom geoip Path" -msgstr "自定义 geoip 文件路径" - -msgid "Custom geoip URL" -msgstr "自定义 geoip 文件更新链接" - -msgid "Custom geosite Path" -msgstr "自定义 geosite 文件路径" - -msgid "Custom geosite URL" -msgstr "自定义 geosite 文件更新链接" - -msgid "Remove resource files" -msgstr "删除资源文件" - -msgid "Sing-Box will automatically download resource files when starting, you can use this feature achieve upgrade resource files." -msgstr "Sing-Box 会在启动时自动下载资源文件,您可以使用此功能实现升级资源文件。" - msgid "Override the connection destination address" msgstr "覆盖连接目标地址" 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 3fe0cade2..3e8b9cdf0 100644 --- a/luci-app-passwall/root/usr/share/passwall/0_default_config +++ b/luci-app-passwall/root/usr/share/passwall/0_default_config @@ -51,10 +51,6 @@ config global_xray config global_singbox option sniff_override_destination '0' - option geoip_path '/usr/share/singbox/geoip.db' - option geoip_url 'https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip.db' - option geosite_path '/usr/share/singbox/geosite.db' - option geosite_url 'https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geosite.db' config global_other option auto_detection_time 'tcping' @@ -76,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 39d35af28..d125bedc3 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,8 +776,8 @@ run_redir() { sing-box) local protocol=$(config_n_get $node protocol) [ "$protocol" = "_shunt" ] && { - local geoip_path="$(config_t_get global_singbox geoip_path)" - local geosite_path="$(config_t_get global_singbox geosite_path)" + 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 @@ -788,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 @@ -895,8 +893,8 @@ run_redir() { } [ "$protocol" = "_shunt" ] && { - local geoip_path="$(config_t_get global_singbox geoip_path)" - local geosite_path="$(config_t_get global_singbox geosite_path)" + 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 @@ -981,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 b7b06396f..3542fc354 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 3e71c5b27..97591ea8f 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 6f077cbee..b1aee9751 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" diff --git a/patch-luci-app-passwall.patch b/patch-luci-app-passwall.patch index 747c356ba..710305c0b 100644 --- a/patch-luci-app-passwall.patch +++ b/patch-luci-app-passwall.patch @@ -1,5 +1,5 @@ diff --git a/luci-app-passwall/Makefile b/luci-app-passwall/Makefile -index aca3e70..8b26594 100644 +index ae464ba..54b5f1a 100644 --- a/luci-app-passwall/Makefile +++ b/luci-app-passwall/Makefile @@ -67,7 +67,7 @@ config PACKAGE_$(PKG_NAME)_Nftables_Transparent_Proxy @@ -20,10 +20,10 @@ index aca3e70..8b26594 100644 define Package/$(PKG_NAME)/postrm diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua -index 908dc46..d33a679 100644 +index 12adebe..fa97b4a 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua -@@ -506,6 +506,12 @@ o:value("9.9.9.9", "9.9.9.9 (Quad9)") +@@ -509,6 +509,12 @@ o:value("9.9.9.9", "9.9.9.9 (Quad9)") o:value("149.112.112.112", "149.112.112.112 (Quad9)") o:value("208.67.220.220", "208.67.220.220 (OpenDNS)") o:value("208.67.222.222", "208.67.222.222 (OpenDNS)") @@ -36,7 +36,7 @@ index 908dc46..d33a679 100644 o:depends({dns_mode = "dns2socks"}) o:depends({dns_mode = "tcp"}) o:depends({dns_mode = "udp"}) -@@ -605,7 +611,7 @@ if api.is_finded("smartdns") then +@@ -608,7 +614,7 @@ if api.is_finded("smartdns") then end o = s:taboption("DNS", Flag, "dns_redirect", translate("DNS Redirect"), translate("Force special DNS server to need proxy devices.")) @@ -93,7 +93,7 @@ index eb5527e..133c295 100644 cursor: pointer; } 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 2d4242e..3fe0cad 100644 +index d665ed8..3e8b9cd 100644 --- a/luci-app-passwall/root/usr/share/passwall/0_default_config +++ b/luci-app-passwall/root/usr/share/passwall/0_default_config @@ -32,7 +32,7 @@ config global_haproxy