From 36b90511356e71afd00dff8b33be1af0cf7ad9a5 Mon Sep 17 00:00:00 2001 From: gitea-action Date: Mon, 30 Dec 2024 16:00:19 +0800 Subject: [PATCH] luci-app-passwall: sync upstream last commit: https://github.com/xiaorouji/openwrt-passwall/commit/bed4bc101234a8fe2c1e5e65d137484a08d9c06d --- .../model/cbi/passwall/client/acl_config.lua | 20 +++++++++---------- .../model/cbi/passwall/client/global.lua | 18 ++++++++--------- .../model/cbi/passwall/client/haproxy.lua | 3 +-- .../model/cbi/passwall/client/rule_list.lua | 6 +++--- .../cbi/passwall/client/socks_config.lua | 5 ++--- .../model/cbi/passwall/client/type/ray.lua | 5 ++--- .../cbi/passwall/client/type/sing-box.lua | 5 ++--- .../passwall/node_list/link_share_man.htm | 2 +- patch-luci-app-passwall.patch | 4 ++-- 9 files changed, 32 insertions(+), 36 deletions(-) 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 5bc253108..b185a4dbd 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 @@ -1,12 +1,12 @@ local api = require "luci.passwall.api" local appname = "passwall" -local uci = api.libuci +local fs = api.fs local sys = api.sys local has_singbox = api.finded_com("singbox") local has_xray = api.finded_com("xray") -local has_gfwlist = api.fs.access("/usr/share/passwall/rules/gfwlist") -local has_chnlist = api.fs.access("/usr/share/passwall/rules/chnlist") -local has_chnroute = api.fs.access("/usr/share/passwall/rules/chnroute") +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") local port_validate = function(self, value, t) return value:gsub("-", ":") @@ -146,7 +146,7 @@ end sources.write = dynamicList_write ---- TCP No Redir Ports -local TCP_NO_REDIR_PORTS = uci:get(appname, "@global_forwarding[0]", "tcp_no_redir_ports") +local TCP_NO_REDIR_PORTS = m.uci:get(appname, "@global_forwarding[0]", "tcp_no_redir_ports") o = s:option(Value, "tcp_no_redir_ports", translate("TCP No Redir Ports")) o:value("", translate("Use global config") .. "(" .. TCP_NO_REDIR_PORTS .. ")") o:value("disable", translate("No patterns are used")) @@ -154,7 +154,7 @@ o:value("1:65535", translate("All")) o.validate = port_validate ---- UDP No Redir Ports -local UDP_NO_REDIR_PORTS = uci:get(appname, "@global_forwarding[0]", "udp_no_redir_ports") +local UDP_NO_REDIR_PORTS = m.uci:get(appname, "@global_forwarding[0]", "udp_no_redir_ports") o = s:option(Value, "udp_no_redir_ports", translate("UDP No Redir Ports"), "" .. translate("Fill in the ports you don't want to be forwarded by the agent, with the highest priority.") .. @@ -203,7 +203,7 @@ o.value = "1" o:depends({ udp_node = "", ['!reverse'] = true }) ---- TCP Proxy Drop Ports -local TCP_PROXY_DROP_PORTS = uci:get(appname, "@global_forwarding[0]", "tcp_proxy_drop_ports") +local TCP_PROXY_DROP_PORTS = m.uci:get(appname, "@global_forwarding[0]", "tcp_proxy_drop_ports") o = s:option(Value, "tcp_proxy_drop_ports", translate("TCP Proxy Drop Ports")) o:value("", translate("Use global config") .. "(" .. TCP_PROXY_DROP_PORTS .. ")") o:value("disable", translate("No patterns are used")) @@ -212,7 +212,7 @@ o:depends({ use_global_config = true }) o:depends({ _tcp_node_bool = "1" }) ---- UDP Proxy Drop Ports -local UDP_PROXY_DROP_PORTS = uci:get(appname, "@global_forwarding[0]", "udp_proxy_drop_ports") +local UDP_PROXY_DROP_PORTS = m.uci:get(appname, "@global_forwarding[0]", "udp_proxy_drop_ports") o = s:option(Value, "udp_proxy_drop_ports", translate("UDP Proxy Drop Ports")) o:value("", translate("Use global config") .. "(" .. UDP_PROXY_DROP_PORTS .. ")") o:value("disable", translate("No patterns are used")) @@ -222,7 +222,7 @@ o:depends({ use_global_config = true }) o:depends({ _tcp_node_bool = "1" }) ---- TCP Redir Ports -local TCP_REDIR_PORTS = uci:get(appname, "@global_forwarding[0]", "tcp_redir_ports") +local TCP_REDIR_PORTS = m.uci:get(appname, "@global_forwarding[0]", "tcp_redir_ports") o = s:option(Value, "tcp_redir_ports", translate("TCP Redir Ports"), translatef("Only work with using the %s node.", "TCP")) o:value("", translate("Use global config") .. "(" .. TCP_REDIR_PORTS .. ")") o:value("1:65535", translate("All")) @@ -234,7 +234,7 @@ o:depends({ use_global_config = true }) o:depends({ _tcp_node_bool = "1" }) ---- UDP Redir Ports -local UDP_REDIR_PORTS = uci:get(appname, "@global_forwarding[0]", "udp_redir_ports") +local UDP_REDIR_PORTS = m.uci:get(appname, "@global_forwarding[0]", "udp_redir_ports") o = s:option(Value, "udp_redir_ports", translate("UDP Redir Ports"), translatef("Only work with using the %s node.", "UDP")) o:value("", translate("Use global config") .. "(" .. UDP_REDIR_PORTS .. ")") o:value("1:65535", translate("All")) 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 0259d8fdc..c4321b58c 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua @@ -1,12 +1,12 @@ local api = require "luci.passwall.api" local appname = "passwall" -local uci = api.libuci local datatypes = api.datatypes +local fs = api.fs local has_singbox = api.finded_com("singbox") local has_xray = api.finded_com("xray") -local has_gfwlist = api.fs.access("/usr/share/passwall/rules/gfwlist") -local has_chnlist = api.fs.access("/usr/share/passwall/rules/chnlist") -local has_chnroute = api.fs.access("/usr/share/passwall/rules/chnroute") +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") local chinadns_tls = os.execute("chinadns-ng -V | grep -i wolfssl >/dev/null") m = Map(appname) @@ -37,13 +37,13 @@ end local socks_list = {} -local tcp_socks_server = "127.0.0.1" .. ":" .. (uci:get(appname, "@global[0]", "tcp_node_socks_port") or "1070") +local tcp_socks_server = "127.0.0.1" .. ":" .. (m.uci:get(appname, "@global[0]", "tcp_node_socks_port") or "1070") local socks_table = {} socks_table[#socks_table + 1] = { id = tcp_socks_server, remark = tcp_socks_server .. " - " .. translate("TCP Node") } -uci:foreach(appname, "socks", function(s) +m.uci:foreach(appname, "socks", function(s) if s.enabled == "1" and s.node then local id, remark for k, n in pairs(nodes_table) do @@ -199,7 +199,7 @@ if (has_singbox or has_xray) and #nodes_table > 0 then type:depends("tcp_node", "__hide") --不存在的依赖,即始终隐藏 end - uci:foreach(appname, "shunt_rules", function(e) + m.uci:foreach(appname, "shunt_rules", function(e) local id = e[".name"] local node_option = vid .. "-" .. id .. "_node" if id and e.remarks then @@ -600,7 +600,7 @@ o = s:taboption("DNS", Flag, "dns_redirect", translate("DNS Redirect"), translat o.default = "0" o.rmempty = false -if (uci:get(appname, "@global_forwarding[0]", "use_nft") or "0") == "1" then +if (m.uci:get(appname, "@global_forwarding[0]", "use_nft") or "0") == "1" then o = s:taboption("DNS", Button, "clear_ipset", translate("Clear NFTSET"), translate("Try this feature if the rule modification does not take effect.")) else o = s:taboption("DNS", Button, "clear_ipset", translate("Clear IPSET"), translate("Try this feature if the rule modification does not take effect.")) @@ -735,7 +735,7 @@ o.rmempty = false o = s2:option(ListValue, "node", translate("Socks Node")) local n = 1 -uci:foreach(appname, "socks", function(s) +m.uci:foreach(appname, "socks", function(s) if s[".name"] == section then return false end diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/haproxy.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/haproxy.lua index effc8fa2d..40a77bf84 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/haproxy.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/haproxy.lua @@ -1,8 +1,7 @@ local api = require "luci.passwall.api" local appname = "passwall" -local sys = api.sys -local net = require "luci.model.network".init() local datatypes = api.datatypes +local net = require "luci.model.network".init() local nodes_table = {} for k, e in ipairs(api.get_valid_nodes()) do diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/rule_list.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/rule_list.lua index 5c9abb15b..094b1dfd2 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/rule_list.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/rule_list.lua @@ -271,7 +271,7 @@ o.remove = function(self, section, value) fs.writefile(hosts, "") end -if api.fs.access(gfwlist_path) then +if fs.access(gfwlist_path) then s:tab("gfw_list", translate("GFW List")) o = s:taboption("gfw_list", DummyValue, "_gfw_fieldset") o.rawhtml = true @@ -284,7 +284,7 @@ if api.fs.access(gfwlist_path) then ]], translate("Read List")) end -if api.fs.access(chnlist_path) then +if fs.access(chnlist_path) then s:tab("chn_list", translate("China List") .. "(" .. translate("Domain") .. ")") o = s:taboption("chn_list", DummyValue, "_chn_fieldset") o.rawhtml = true @@ -297,7 +297,7 @@ if api.fs.access(chnlist_path) then ]], translate("Read List")) end -if api.fs.access(chnroute_path) then +if fs.access(chnroute_path) then s:tab("chnroute_list", translate("China List") .. "(IP)") o = s:taboption("chnroute_list", DummyValue, "_chnroute_fieldset") o.rawhtml = true diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/socks_config.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/socks_config.lua index b7afc57f1..187beaaa3 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/socks_config.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/socks_config.lua @@ -1,6 +1,5 @@ local api = require "luci.passwall.api" local appname = "passwall" -local uci = api.libuci local has_singbox = api.finded_com("singbox") local has_xray = api.finded_com("xray") @@ -23,7 +22,7 @@ o.rmempty = false local auto_switch_tip local current_node = api.get_cache_var("socks_" .. arg[1]) if current_node then - local n = uci:get_all(appname, current_node) + local n = m.uci:get_all(appname, current_node) if n then if tonumber(m:get(arg[1], "enable_autoswitch") or 0) == 1 then if n then @@ -44,7 +43,7 @@ o = s:option(Flag, "bind_local", translate("Bind Local"), translate("When select o.default = "0" local n = 1 -uci:foreach(appname, "socks", function(s) +m.uci:foreach(appname, "socks", function(s) if s[".name"] == section then return false end diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/type/ray.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/type/ray.lua index ddc998a3c..7718e3edd 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/type/ray.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/type/ray.lua @@ -8,7 +8,6 @@ end local appname = "passwall" local jsonc = api.jsonc -local uci = api.libuci local type_name = "Xray" @@ -86,7 +85,7 @@ for k, e in ipairs(api.get_valid_nodes()) do end local socks_list = {} -uci:foreach(appname, "socks", function(s) +m.uci:foreach(appname, "socks", function(s) if s.enabled == "1" and s.node then socks_list[#socks_list + 1] = { id = "Socks_" .. s[".name"], @@ -181,7 +180,7 @@ if #nodes_table > 0 then o:value(v.id, v.remark) end end -uci:foreach(appname, "shunt_rules", function(e) +m.uci:foreach(appname, "shunt_rules", function(e) if e[".name"] and e.remarks then o = s:option(ListValue, _n(e[".name"]), string.format('* %s', api.url("shunt_rules", e[".name"]), e.remarks)) o:value("", translate("Close")) 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 40eb13ce4..7e5ee34a6 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 @@ -11,7 +11,6 @@ end local singbox_tags = luci.sys.exec(singbox_bin .. " version | grep 'Tags:' | awk '{print $2}'") local appname = "passwall" -local uci = api.libuci local type_name = "sing-box" @@ -83,7 +82,7 @@ for k, e in ipairs(api.get_valid_nodes()) do end local socks_list = {} -uci:foreach(appname, "socks", function(s) +m.uci:foreach(appname, "socks", function(s) if s.enabled == "1" and s.node then socks_list[#socks_list + 1] = { id = "Socks_" .. s[".name"], @@ -109,7 +108,7 @@ if #nodes_table > 0 then o:value(v.id, v.remark) end end -uci:foreach(appname, "shunt_rules", function(e) +m.uci:foreach(appname, "shunt_rules", function(e) if e[".name"] and e.remarks then o = s:option(ListValue, _n(e[".name"]), string.format('* %s', api.url("shunt_rules", e[".name"]), e.remarks)) o:value("", translate("Close")) diff --git a/luci-app-passwall/luasrc/view/passwall/node_list/link_share_man.htm b/luci-app-passwall/luasrc/view/passwall/node_list/link_share_man.htm index d34003a99..250836ca8 100644 --- a/luci-app-passwall/luasrc/view/passwall/node_list/link_share_man.htm +++ b/luci-app-passwall/luasrc/view/passwall/node_list/link_share_man.htm @@ -2,7 +2,7 @@ <% local api = require "luci.passwall.api" local appname = 'passwall' -local uci = api.libuci +local uci = self.map.uci local ss_type = uci:get(appname, "@global_subscribe[0]", "ss_type") or "xray" local trojan_type = uci:get(appname, "@global_subscribe[0]", "trojan_type") or "xray" local vmess_type = uci:get(appname, "@global_subscribe[0]", "vmess_type") or "xray" diff --git a/patch-luci-app-passwall.patch b/patch-luci-app-passwall.patch index 501ae8d80..1a59440b6 100644 --- a/patch-luci-app-passwall.patch +++ b/patch-luci-app-passwall.patch @@ -33,7 +33,7 @@ index 99c620f..ba84fc9 100644 if code ~= 0 then local use_time = luci.sys.exec("echo -n '" .. result .. "' | awk -F ':' '{print $2}'") 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 d8719bb..0259d8f 100644 +index 4168039..c4321b5 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua @@ -492,6 +492,12 @@ o:value("9.9.9.9", "9.9.9.9 (Quad9)") @@ -57,7 +57,7 @@ index d8719bb..0259d8f 100644 +o.default = "0" o.rmempty = false - if (uci:get(appname, "@global_forwarding[0]", "use_nft") or "0") == "1" then + if (m.uci:get(appname, "@global_forwarding[0]", "use_nft") or "0") == "1" then diff --git a/luci-app-passwall/luasrc/view/passwall/global/status.htm b/luci-app-passwall/luasrc/view/passwall/global/status.htm index e8d76ec..a872950 100644 --- a/luci-app-passwall/luasrc/view/passwall/global/status.htm