From 17dde9704e65f4e29198459d2284b2e74a85f083 Mon Sep 17 00:00:00 2001 From: actions Date: Tue, 23 Apr 2024 00:30:06 +0800 Subject: [PATCH] luci-app-passwall2: sync upstream --- luci-app-passwall2/Makefile | 2 +- .../luasrc/controller/passwall2.lua | 6 +-- .../model/cbi/passwall2/client/global.lua | 3 +- .../luasrc/view/passwall2/global/status.htm | 2 +- luci-app-passwall2/po/zh-cn/passwall2.po | 4 +- .../root/etc/uci-defaults/luci-passwall2 | 4 ++ .../root/usr/share/passwall2/0_default_config | 2 +- .../root/usr/share/passwall2/app.sh | 2 +- .../root/usr/share/passwall2/subscribe.lua | 47 ++++++++++++++++--- .../ucitrack/luci-app-passwall2-server.json | 4 ++ .../share/ucitrack/luci-app-passwall2.json | 4 ++ 11 files changed, 63 insertions(+), 17 deletions(-) create mode 100644 luci-app-passwall2/root/usr/share/ucitrack/luci-app-passwall2-server.json create mode 100644 luci-app-passwall2/root/usr/share/ucitrack/luci-app-passwall2.json diff --git a/luci-app-passwall2/Makefile b/luci-app-passwall2/Makefile index 03a39fafa..92c5ab933 100644 --- a/luci-app-passwall2/Makefile +++ b/luci-app-passwall2/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-passwall2 -PKG_VERSION:=1.28-7 +PKG_VERSION:=1.29-1 PKG_RELEASE:= PKG_CONFIG_DEPENDS:= \ diff --git a/luci-app-passwall2/luasrc/controller/passwall2.lua b/luci-app-passwall2/luasrc/controller/passwall2.lua index fe9c76339..14fed7fec 100644 --- a/luci-app-passwall2/luasrc/controller/passwall2.lua +++ b/luci-app-passwall2/luasrc/controller/passwall2.lua @@ -55,7 +55,7 @@ function index() entry({"admin", "services", appname, "get_socks_log"}, call("get_socks_log")).leaf = true entry({"admin", "services", appname, "get_log"}, call("get_log")).leaf = true entry({"admin", "services", appname, "clear_log"}, call("clear_log")).leaf = true - entry({"admin", "services", appname, "status"}, call("status")).leaf = true + entry({"admin", "services", appname, "index_status"}, call("index_status")).leaf = true entry({"admin", "services", appname, "haproxy_status"}, call("haproxy_status")).leaf = true entry({"admin", "services", appname, "socks_status"}, call("socks_status")).leaf = true entry({"admin", "services", appname, "connect_status"}, call("connect_status")).leaf = true @@ -189,9 +189,9 @@ function clear_log() luci.sys.call("echo '' > /tmp/log/passwall2.log") end -function status() +function index_status() local e = {} - e["global_status"] = luci.sys.call("/bin/busybox top -bn1 | grep -v 'grep' | grep '/tmp/etc/passwall2/bin/' | grep -v '_acl_' | grep 'global' >/dev/null") == 0 + e["global_status"] = luci.sys.call("/bin/busybox top -bn1 | grep -v 'grep' | grep '/tmp/etc/passwall2/bin/' | grep 'default' | grep 'global' >/dev/null") == 0 luci.http.prepare_content("application/json") luci.http.write_json(e) end diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/global.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/global.lua index e80474d43..29823e1c2 100644 --- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/global.lua +++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/global.lua @@ -329,7 +329,8 @@ for k, v in pairs(nodes_table) do end s:tab("log", translate("Log")) -o = s:taboption("log", Flag, "close_log", translate("Close Node Log")) +o = s:taboption("log", Flag, "log_node", translate("Enable Node Log")) +o.default = "1" o.rmempty = false loglevel = s:taboption("log", ListValue, "loglevel", translate("Log Level")) diff --git a/luci-app-passwall2/luasrc/view/passwall2/global/status.htm b/luci-app-passwall2/luasrc/view/passwall2/global/status.htm index 66ede8545..03b2e56d0 100644 --- a/luci-app-passwall2/luasrc/view/passwall2/global/status.htm +++ b/luci-app-passwall2/luasrc/view/passwall2/global/status.htm @@ -139,7 +139,7 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md document.getElementsByTagName('img')[i].setAttribute("oncontextmenu","return false;"); document.getElementsByTagName('img')[i].setAttribute("ondragstart","return false;"); } - XHR.poll(5, '<%=api.url("status")%>', null, + XHR.poll(5, '<%=api.url("index_status")%>', null, function (x, data) { if (data) { if (true) { diff --git a/luci-app-passwall2/po/zh-cn/passwall2.po b/luci-app-passwall2/po/zh-cn/passwall2.po index 261539e98..fabe10e8e 100644 --- a/luci-app-passwall2/po/zh-cn/passwall2.po +++ b/luci-app-passwall2/po/zh-cn/passwall2.po @@ -1288,8 +1288,8 @@ msgstr "日志" msgid "Log" msgstr "日志" -msgid "Close Node Log" -msgstr "关闭节点日志" +msgid "Enable Node Log" +msgstr "启用节点日志" msgid "Log Level" msgstr "日志等级" diff --git a/luci-app-passwall2/root/etc/uci-defaults/luci-passwall2 b/luci-app-passwall2/root/etc/uci-defaults/luci-passwall2 index f49a4eca5..6ec65ccd3 100755 --- a/luci-app-passwall2/root/etc/uci-defaults/luci-passwall2 +++ b/luci-app-passwall2/root/etc/uci-defaults/luci-passwall2 @@ -3,20 +3,24 @@ uci -q batch <<-EOF >/dev/null set dhcp.@dnsmasq[0].localuse=1 commit dhcp + [ -e "/etc/config/ucitrack" ] && { delete ucitrack.@passwall2[-1] add ucitrack passwall2 set ucitrack.@passwall2[-1].init=passwall2 commit ucitrack + } delete firewall.passwall2 set firewall.passwall2=include set firewall.passwall2.type=script set firewall.passwall2.path=/var/etc/passwall2.include set firewall.passwall2.reload=1 commit firewall + [ -e "/etc/config/ucitrack" ] && { delete ucitrack.@passwall2_server[-1] add ucitrack passwall2_server set ucitrack.@passwall2_server[-1].init=passwall2_server commit ucitrack + } delete firewall.passwall2_server set firewall.passwall2_server=include set firewall.passwall2_server.type=script diff --git a/luci-app-passwall2/root/usr/share/passwall2/0_default_config b/luci-app-passwall2/root/usr/share/passwall2/0_default_config index 464f5c84e..f129cc36b 100644 --- a/luci-app-passwall2/root/usr/share/passwall2/0_default_config +++ b/luci-app-passwall2/root/usr/share/passwall2/0_default_config @@ -14,7 +14,7 @@ config global option remote_dns_query_strategy 'UseIPv4' option dns_hosts 'cloudflare-dns.com 1.1.1.1 dns.google.com 8.8.8.8' - option close_log '0' + option log_node '1' option loglevel 'error' config global_haproxy diff --git a/luci-app-passwall2/root/usr/share/passwall2/app.sh b/luci-app-passwall2/root/usr/share/passwall2/app.sh index 3d653b675..22aa7b41c 100644 --- a/luci-app-passwall2/root/usr/share/passwall2/app.sh +++ b/luci-app-passwall2/root/usr/share/passwall2/app.sh @@ -688,7 +688,7 @@ run_global() { V2RAY_CONFIG=$TMP_ACL_PATH/default/global.json V2RAY_LOG=$TMP_ACL_PATH/default/global.log - [ "$(config_t_get global close_log 1)" = "1" ] && V2RAY_LOG="/dev/null" + [ "$(config_t_get global log_node 1)" != "1" ] && V2RAY_LOG="/dev/null" V2RAY_ARGS="${V2RAY_ARGS} log_file=${V2RAY_LOG} config_file=${V2RAY_CONFIG}" node_socks_port=$(config_t_get global node_socks_port 1070) diff --git a/luci-app-passwall2/root/usr/share/passwall2/subscribe.lua b/luci-app-passwall2/root/usr/share/passwall2/subscribe.lua index bce5a2c7a..6c6a5cdf7 100755 --- a/luci-app-passwall2/root/usr/share/passwall2/subscribe.lua +++ b/luci-app-passwall2/root/usr/share/passwall2/subscribe.lua @@ -220,9 +220,8 @@ do end) uci:foreach(appname, "nodes", function(node) + local node_id = node[".name"] if node.protocol and node.protocol == '_shunt' then - local node_id = node[".name"] - local rules = {} uci:foreach(appname, "shunt_rules", function(e) if e[".name"] and e.remarks then @@ -256,7 +255,6 @@ do end elseif node.protocol and node.protocol == '_balancing' then - local node_id = node[".name"] local nodes = {} local new_nodes = {} if node.balancing_node then @@ -268,7 +266,7 @@ do remarks = node, set = function(o, server) for kk, vv in pairs(CONFIG) do - if (vv.remarks == "负载均衡节点列表" .. node_id) then + if (vv.remarks == "Xray负载均衡节点[" .. node_id .. "]列表") then table.insert(vv.new_nodes, server) end end @@ -277,13 +275,12 @@ do end end CONFIG[#CONFIG + 1] = { - remarks = "负载均衡节点列表" .. node_id, + remarks = "Xray负载均衡节点[" .. node_id .. "]列表", nodes = nodes, new_nodes = new_nodes, set = function(o) for kk, vv in pairs(CONFIG) do - if (vv.remarks == "负载均衡节点列表" .. node_id) then - --log("刷新负载均衡节点列表") + if (vv.remarks == "Xray负载均衡节点[" .. node_id .. "]列表") then uci:foreach(appname, "nodes", function(node2) if node2[".name"] == node[".name"] then local section = uci:section(appname, "nodes", node_id) @@ -294,6 +291,42 @@ do end end } + + --后备节点 + local currentNode = uci:get_all(appname, node_id) or nil + if currentNode and currentNode.fallback_node then + CONFIG[#CONFIG + 1] = { + log = true, + id = node_id, + remarks = "Xray负载均衡节点[" .. node_id .. "]后备节点", + currentNode = uci:get_all(appname, currentNode.fallback_node) or nil, + set = function(o, server) + uci:set(appname, node_id, "fallback_node", server) + o.newNodeId = server + end, + delete = function(o) + uci:delete(appname, node_id, "fallback_node") + end + } + end + else + --落地节点 + local currentNode = uci:get_all(appname, node_id) or nil + if currentNode and currentNode.to_node then + CONFIG[#CONFIG + 1] = { + log = true, + id = node_id, + remarks = "节点[" .. node_id .. "]落地节点", + currentNode = uci:get_all(appname, currentNode.to_node) or nil, + set = function(o, server) + uci:set(appname, node_id, "to_node", server) + o.newNodeId = server + end, + delete = function(o) + uci:delete(appname, node_id, "to_node") + end + } + end end end) diff --git a/luci-app-passwall2/root/usr/share/ucitrack/luci-app-passwall2-server.json b/luci-app-passwall2/root/usr/share/ucitrack/luci-app-passwall2-server.json new file mode 100644 index 000000000..d73b5d109 --- /dev/null +++ b/luci-app-passwall2/root/usr/share/ucitrack/luci-app-passwall2-server.json @@ -0,0 +1,4 @@ +{ + "config": "passwall2_server", + "init": "passwall2_server" +} diff --git a/luci-app-passwall2/root/usr/share/ucitrack/luci-app-passwall2.json b/luci-app-passwall2/root/usr/share/ucitrack/luci-app-passwall2.json new file mode 100644 index 000000000..2ff857b0d --- /dev/null +++ b/luci-app-passwall2/root/usr/share/ucitrack/luci-app-passwall2.json @@ -0,0 +1,4 @@ +{ + "config": "passwall2", + "init": "passwall2" +}