luci-app-passwall: sync upstream

last commit: bed4bc1012
This commit is contained in:
gitea-action 2024-12-30 16:00:19 +08:00
parent f4ba56b2bf
commit 36b9051135
9 changed files with 32 additions and 36 deletions

View File

@ -1,12 +1,12 @@
local api = require "luci.passwall.api" local api = require "luci.passwall.api"
local appname = "passwall" local appname = "passwall"
local uci = api.libuci local fs = api.fs
local sys = api.sys local sys = api.sys
local has_singbox = api.finded_com("singbox") local has_singbox = api.finded_com("singbox")
local has_xray = api.finded_com("xray") local has_xray = api.finded_com("xray")
local has_gfwlist = api.fs.access("/usr/share/passwall/rules/gfwlist") local has_gfwlist = fs.access("/usr/share/passwall/rules/gfwlist")
local has_chnlist = api.fs.access("/usr/share/passwall/rules/chnlist") local has_chnlist = fs.access("/usr/share/passwall/rules/chnlist")
local has_chnroute = api.fs.access("/usr/share/passwall/rules/chnroute") local has_chnroute = fs.access("/usr/share/passwall/rules/chnroute")
local port_validate = function(self, value, t) local port_validate = function(self, value, t)
return value:gsub("-", ":") return value:gsub("-", ":")
@ -146,7 +146,7 @@ end
sources.write = dynamicList_write sources.write = dynamicList_write
---- TCP No Redir Ports ---- 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 = s:option(Value, "tcp_no_redir_ports", translate("TCP No Redir Ports"))
o:value("", translate("Use global config") .. "(" .. TCP_NO_REDIR_PORTS .. ")") o:value("", translate("Use global config") .. "(" .. TCP_NO_REDIR_PORTS .. ")")
o:value("disable", translate("No patterns are used")) o:value("disable", translate("No patterns are used"))
@ -154,7 +154,7 @@ o:value("1:65535", translate("All"))
o.validate = port_validate o.validate = port_validate
---- UDP No Redir Ports ---- 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"), o = s:option(Value, "udp_no_redir_ports", translate("UDP No Redir Ports"),
"<font color='red'>" .. "<font color='red'>" ..
translate("Fill in the ports you don't want to be forwarded by the agent, with the highest priority.") .. 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 }) o:depends({ udp_node = "", ['!reverse'] = true })
---- TCP Proxy Drop Ports ---- 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 = s:option(Value, "tcp_proxy_drop_ports", translate("TCP Proxy Drop Ports"))
o:value("", translate("Use global config") .. "(" .. TCP_PROXY_DROP_PORTS .. ")") o:value("", translate("Use global config") .. "(" .. TCP_PROXY_DROP_PORTS .. ")")
o:value("disable", translate("No patterns are used")) o:value("disable", translate("No patterns are used"))
@ -212,7 +212,7 @@ o:depends({ use_global_config = true })
o:depends({ _tcp_node_bool = "1" }) o:depends({ _tcp_node_bool = "1" })
---- UDP Proxy Drop Ports ---- 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 = s:option(Value, "udp_proxy_drop_ports", translate("UDP Proxy Drop Ports"))
o:value("", translate("Use global config") .. "(" .. UDP_PROXY_DROP_PORTS .. ")") o:value("", translate("Use global config") .. "(" .. UDP_PROXY_DROP_PORTS .. ")")
o:value("disable", translate("No patterns are used")) o:value("disable", translate("No patterns are used"))
@ -222,7 +222,7 @@ o:depends({ use_global_config = true })
o:depends({ _tcp_node_bool = "1" }) o:depends({ _tcp_node_bool = "1" })
---- TCP Redir Ports ---- 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 = 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("", translate("Use global config") .. "(" .. TCP_REDIR_PORTS .. ")")
o:value("1:65535", translate("All")) o:value("1:65535", translate("All"))
@ -234,7 +234,7 @@ o:depends({ use_global_config = true })
o:depends({ _tcp_node_bool = "1" }) o:depends({ _tcp_node_bool = "1" })
---- UDP Redir Ports ---- 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 = 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("", translate("Use global config") .. "(" .. UDP_REDIR_PORTS .. ")")
o:value("1:65535", translate("All")) o:value("1:65535", translate("All"))

View File

@ -1,12 +1,12 @@
local api = require "luci.passwall.api" local api = require "luci.passwall.api"
local appname = "passwall" local appname = "passwall"
local uci = api.libuci
local datatypes = api.datatypes local datatypes = api.datatypes
local fs = api.fs
local has_singbox = api.finded_com("singbox") local has_singbox = api.finded_com("singbox")
local has_xray = api.finded_com("xray") local has_xray = api.finded_com("xray")
local has_gfwlist = api.fs.access("/usr/share/passwall/rules/gfwlist") local has_gfwlist = fs.access("/usr/share/passwall/rules/gfwlist")
local has_chnlist = api.fs.access("/usr/share/passwall/rules/chnlist") local has_chnlist = fs.access("/usr/share/passwall/rules/chnlist")
local has_chnroute = api.fs.access("/usr/share/passwall/rules/chnroute") local has_chnroute = fs.access("/usr/share/passwall/rules/chnroute")
local chinadns_tls = os.execute("chinadns-ng -V | grep -i wolfssl >/dev/null") local chinadns_tls = os.execute("chinadns-ng -V | grep -i wolfssl >/dev/null")
m = Map(appname) m = Map(appname)
@ -37,13 +37,13 @@ end
local socks_list = {} 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 = {} local socks_table = {}
socks_table[#socks_table + 1] = { socks_table[#socks_table + 1] = {
id = tcp_socks_server, id = tcp_socks_server,
remark = tcp_socks_server .. " - " .. translate("TCP Node") 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 if s.enabled == "1" and s.node then
local id, remark local id, remark
for k, n in pairs(nodes_table) do 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") --不存在的依赖,即始终隐藏 type:depends("tcp_node", "__hide") --不存在的依赖,即始终隐藏
end end
uci:foreach(appname, "shunt_rules", function(e) m.uci:foreach(appname, "shunt_rules", function(e)
local id = e[".name"] local id = e[".name"]
local node_option = vid .. "-" .. id .. "_node" local node_option = vid .. "-" .. id .. "_node"
if id and e.remarks then 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.default = "0"
o.rmempty = false 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.")) o = s:taboption("DNS", Button, "clear_ipset", translate("Clear NFTSET"), translate("Try this feature if the rule modification does not take effect."))
else else
o = s:taboption("DNS", Button, "clear_ipset", translate("Clear IPSET"), translate("Try this feature if the rule modification does not take effect.")) 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")) o = s2:option(ListValue, "node", translate("Socks Node"))
local n = 1 local n = 1
uci:foreach(appname, "socks", function(s) m.uci:foreach(appname, "socks", function(s)
if s[".name"] == section then if s[".name"] == section then
return false return false
end end

View File

@ -1,8 +1,7 @@
local api = require "luci.passwall.api" local api = require "luci.passwall.api"
local appname = "passwall" local appname = "passwall"
local sys = api.sys
local net = require "luci.model.network".init()
local datatypes = api.datatypes local datatypes = api.datatypes
local net = require "luci.model.network".init()
local nodes_table = {} local nodes_table = {}
for k, e in ipairs(api.get_valid_nodes()) do for k, e in ipairs(api.get_valid_nodes()) do

View File

@ -271,7 +271,7 @@ o.remove = function(self, section, value)
fs.writefile(hosts, "") fs.writefile(hosts, "")
end end
if api.fs.access(gfwlist_path) then if fs.access(gfwlist_path) then
s:tab("gfw_list", translate("GFW List")) s:tab("gfw_list", translate("GFW List"))
o = s:taboption("gfw_list", DummyValue, "_gfw_fieldset") o = s:taboption("gfw_list", DummyValue, "_gfw_fieldset")
o.rawhtml = true o.rawhtml = true
@ -284,7 +284,7 @@ if api.fs.access(gfwlist_path) then
]], translate("Read List")) ]], translate("Read List"))
end end
if api.fs.access(chnlist_path) then if fs.access(chnlist_path) then
s:tab("chn_list", translate("China List") .. "(" .. translate("Domain") .. ")") s:tab("chn_list", translate("China List") .. "(" .. translate("Domain") .. ")")
o = s:taboption("chn_list", DummyValue, "_chn_fieldset") o = s:taboption("chn_list", DummyValue, "_chn_fieldset")
o.rawhtml = true o.rawhtml = true
@ -297,7 +297,7 @@ if api.fs.access(chnlist_path) then
]], translate("Read List")) ]], translate("Read List"))
end end
if api.fs.access(chnroute_path) then if fs.access(chnroute_path) then
s:tab("chnroute_list", translate("China List") .. "(IP)") s:tab("chnroute_list", translate("China List") .. "(IP)")
o = s:taboption("chnroute_list", DummyValue, "_chnroute_fieldset") o = s:taboption("chnroute_list", DummyValue, "_chnroute_fieldset")
o.rawhtml = true o.rawhtml = true

View File

@ -1,6 +1,5 @@
local api = require "luci.passwall.api" local api = require "luci.passwall.api"
local appname = "passwall" local appname = "passwall"
local uci = api.libuci
local has_singbox = api.finded_com("singbox") local has_singbox = api.finded_com("singbox")
local has_xray = api.finded_com("xray") local has_xray = api.finded_com("xray")
@ -23,7 +22,7 @@ o.rmempty = false
local auto_switch_tip local auto_switch_tip
local current_node = api.get_cache_var("socks_" .. arg[1]) local current_node = api.get_cache_var("socks_" .. arg[1])
if current_node then 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 n then
if tonumber(m:get(arg[1], "enable_autoswitch") or 0) == 1 then if tonumber(m:get(arg[1], "enable_autoswitch") or 0) == 1 then
if n then if n then
@ -44,7 +43,7 @@ o = s:option(Flag, "bind_local", translate("Bind Local"), translate("When select
o.default = "0" o.default = "0"
local n = 1 local n = 1
uci:foreach(appname, "socks", function(s) m.uci:foreach(appname, "socks", function(s)
if s[".name"] == section then if s[".name"] == section then
return false return false
end end

View File

@ -8,7 +8,6 @@ end
local appname = "passwall" local appname = "passwall"
local jsonc = api.jsonc local jsonc = api.jsonc
local uci = api.libuci
local type_name = "Xray" local type_name = "Xray"
@ -86,7 +85,7 @@ for k, e in ipairs(api.get_valid_nodes()) do
end end
local socks_list = {} local socks_list = {}
uci:foreach(appname, "socks", function(s) m.uci:foreach(appname, "socks", function(s)
if s.enabled == "1" and s.node then if s.enabled == "1" and s.node then
socks_list[#socks_list + 1] = { socks_list[#socks_list + 1] = {
id = "Socks_" .. s[".name"], id = "Socks_" .. s[".name"],
@ -181,7 +180,7 @@ if #nodes_table > 0 then
o:value(v.id, v.remark) o:value(v.id, v.remark)
end end
end end
uci:foreach(appname, "shunt_rules", function(e) m.uci:foreach(appname, "shunt_rules", function(e)
if e[".name"] and e.remarks then if e[".name"] and e.remarks then
o = s:option(ListValue, _n(e[".name"]), string.format('* <a href="%s" target="_blank">%s</a>', api.url("shunt_rules", e[".name"]), e.remarks)) o = s:option(ListValue, _n(e[".name"]), string.format('* <a href="%s" target="_blank">%s</a>', api.url("shunt_rules", e[".name"]), e.remarks))
o:value("", translate("Close")) o:value("", translate("Close"))

View File

@ -11,7 +11,6 @@ end
local singbox_tags = luci.sys.exec(singbox_bin .. " version | grep 'Tags:' | awk '{print $2}'") local singbox_tags = luci.sys.exec(singbox_bin .. " version | grep 'Tags:' | awk '{print $2}'")
local appname = "passwall" local appname = "passwall"
local uci = api.libuci
local type_name = "sing-box" local type_name = "sing-box"
@ -83,7 +82,7 @@ for k, e in ipairs(api.get_valid_nodes()) do
end end
local socks_list = {} local socks_list = {}
uci:foreach(appname, "socks", function(s) m.uci:foreach(appname, "socks", function(s)
if s.enabled == "1" and s.node then if s.enabled == "1" and s.node then
socks_list[#socks_list + 1] = { socks_list[#socks_list + 1] = {
id = "Socks_" .. s[".name"], id = "Socks_" .. s[".name"],
@ -109,7 +108,7 @@ if #nodes_table > 0 then
o:value(v.id, v.remark) o:value(v.id, v.remark)
end end
end end
uci:foreach(appname, "shunt_rules", function(e) m.uci:foreach(appname, "shunt_rules", function(e)
if e[".name"] and e.remarks then if e[".name"] and e.remarks then
o = s:option(ListValue, _n(e[".name"]), string.format('* <a href="%s" target="_blank">%s</a>', api.url("shunt_rules", e[".name"]), e.remarks)) o = s:option(ListValue, _n(e[".name"]), string.format('* <a href="%s" target="_blank">%s</a>', api.url("shunt_rules", e[".name"]), e.remarks))
o:value("", translate("Close")) o:value("", translate("Close"))

View File

@ -2,7 +2,7 @@
<% <%
local api = require "luci.passwall.api" local api = require "luci.passwall.api"
local appname = 'passwall' 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 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 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" local vmess_type = uci:get(appname, "@global_subscribe[0]", "vmess_type") or "xray"

View File

@ -33,7 +33,7 @@ index 99c620f..ba84fc9 100644
if code ~= 0 then if code ~= 0 then
local use_time = luci.sys.exec("echo -n '" .. result .. "' | awk -F ':' '{print $2}'") 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 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 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua
+++ b/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)") @@ -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.default = "0"
o.rmempty = false 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 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 index e8d76ec..a872950 100644
--- a/luci-app-passwall/luasrc/view/passwall/global/status.htm --- a/luci-app-passwall/luasrc/view/passwall/global/status.htm