luci-app-passwall2: sync upstream

This commit is contained in:
actions 2024-04-23 00:30:06 +08:00
parent edd97447b8
commit 17dde9704e
11 changed files with 63 additions and 17 deletions

View File

@ -5,7 +5,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-passwall2 PKG_NAME:=luci-app-passwall2
PKG_VERSION:=1.28-7 PKG_VERSION:=1.29-1
PKG_RELEASE:= PKG_RELEASE:=
PKG_CONFIG_DEPENDS:= \ PKG_CONFIG_DEPENDS:= \

View File

@ -55,7 +55,7 @@ function index()
entry({"admin", "services", appname, "get_socks_log"}, call("get_socks_log")).leaf = true 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, "get_log"}, call("get_log")).leaf = true
entry({"admin", "services", appname, "clear_log"}, call("clear_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, "haproxy_status"}, call("haproxy_status")).leaf = true
entry({"admin", "services", appname, "socks_status"}, call("socks_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 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") luci.sys.call("echo '' > /tmp/log/passwall2.log")
end end
function status() function index_status()
local e = {} 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.prepare_content("application/json")
luci.http.write_json(e) luci.http.write_json(e)
end end

View File

@ -329,7 +329,8 @@ for k, v in pairs(nodes_table) do
end end
s:tab("log", translate("Log")) 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 o.rmempty = false
loglevel = s:taboption("log", ListValue, "loglevel", translate("Log Level")) loglevel = s:taboption("log", ListValue, "loglevel", translate("Log Level"))

View File

@ -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("oncontextmenu","return false;");
document.getElementsByTagName('img')[i].setAttribute("ondragstart","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) { function (x, data) {
if (data) { if (data) {
if (true) { if (true) {

View File

@ -1288,8 +1288,8 @@ msgstr "日志"
msgid "Log" msgid "Log"
msgstr "日志" msgstr "日志"
msgid "Close Node Log" msgid "Enable Node Log"
msgstr "关闭节点日志" msgstr "启用节点日志"
msgid "Log Level" msgid "Log Level"
msgstr "日志等级" msgstr "日志等级"

View File

@ -3,20 +3,24 @@
uci -q batch <<-EOF >/dev/null uci -q batch <<-EOF >/dev/null
set dhcp.@dnsmasq[0].localuse=1 set dhcp.@dnsmasq[0].localuse=1
commit dhcp commit dhcp
[ -e "/etc/config/ucitrack" ] && {
delete ucitrack.@passwall2[-1] delete ucitrack.@passwall2[-1]
add ucitrack passwall2 add ucitrack passwall2
set ucitrack.@passwall2[-1].init=passwall2 set ucitrack.@passwall2[-1].init=passwall2
commit ucitrack commit ucitrack
}
delete firewall.passwall2 delete firewall.passwall2
set firewall.passwall2=include set firewall.passwall2=include
set firewall.passwall2.type=script set firewall.passwall2.type=script
set firewall.passwall2.path=/var/etc/passwall2.include set firewall.passwall2.path=/var/etc/passwall2.include
set firewall.passwall2.reload=1 set firewall.passwall2.reload=1
commit firewall commit firewall
[ -e "/etc/config/ucitrack" ] && {
delete ucitrack.@passwall2_server[-1] delete ucitrack.@passwall2_server[-1]
add ucitrack passwall2_server add ucitrack passwall2_server
set ucitrack.@passwall2_server[-1].init=passwall2_server set ucitrack.@passwall2_server[-1].init=passwall2_server
commit ucitrack commit ucitrack
}
delete firewall.passwall2_server delete firewall.passwall2_server
set firewall.passwall2_server=include set firewall.passwall2_server=include
set firewall.passwall2_server.type=script set firewall.passwall2_server.type=script

View File

@ -14,7 +14,7 @@ config global
option remote_dns_query_strategy 'UseIPv4' option remote_dns_query_strategy 'UseIPv4'
option dns_hosts 'cloudflare-dns.com 1.1.1.1 option dns_hosts 'cloudflare-dns.com 1.1.1.1
dns.google.com 8.8.8.8' dns.google.com 8.8.8.8'
option close_log '0' option log_node '1'
option loglevel 'error' option loglevel 'error'
config global_haproxy config global_haproxy

View File

@ -688,7 +688,7 @@ run_global() {
V2RAY_CONFIG=$TMP_ACL_PATH/default/global.json V2RAY_CONFIG=$TMP_ACL_PATH/default/global.json
V2RAY_LOG=$TMP_ACL_PATH/default/global.log 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}" V2RAY_ARGS="${V2RAY_ARGS} log_file=${V2RAY_LOG} config_file=${V2RAY_CONFIG}"
node_socks_port=$(config_t_get global node_socks_port 1070) node_socks_port=$(config_t_get global node_socks_port 1070)

View File

@ -220,9 +220,8 @@ do
end) end)
uci:foreach(appname, "nodes", function(node) uci:foreach(appname, "nodes", function(node)
if node.protocol and node.protocol == '_shunt' then
local node_id = node[".name"] local node_id = node[".name"]
if node.protocol and node.protocol == '_shunt' then
local rules = {} local rules = {}
uci:foreach(appname, "shunt_rules", function(e) uci:foreach(appname, "shunt_rules", function(e)
if e[".name"] and e.remarks then if e[".name"] and e.remarks then
@ -256,7 +255,6 @@ do
end end
elseif node.protocol and node.protocol == '_balancing' then elseif node.protocol and node.protocol == '_balancing' then
local node_id = node[".name"]
local nodes = {} local nodes = {}
local new_nodes = {} local new_nodes = {}
if node.balancing_node then if node.balancing_node then
@ -268,7 +266,7 @@ do
remarks = node, remarks = node,
set = function(o, server) set = function(o, server)
for kk, vv in pairs(CONFIG) do 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) table.insert(vv.new_nodes, server)
end end
end end
@ -277,13 +275,12 @@ do
end end
end end
CONFIG[#CONFIG + 1] = { CONFIG[#CONFIG + 1] = {
remarks = "负载均衡节点列表" .. node_id, remarks = "Xray负载均衡节点[" .. node_id .. "]列表",
nodes = nodes, nodes = nodes,
new_nodes = new_nodes, new_nodes = new_nodes,
set = function(o) set = function(o)
for kk, vv in pairs(CONFIG) do for kk, vv in pairs(CONFIG) do
if (vv.remarks == "负载均衡节点列表" .. node_id) then if (vv.remarks == "Xray负载均衡节点[" .. node_id .. "]列表") then
--log("刷新负载均衡节点列表")
uci:foreach(appname, "nodes", function(node2) uci:foreach(appname, "nodes", function(node2)
if node2[".name"] == node[".name"] then if node2[".name"] == node[".name"] then
local section = uci:section(appname, "nodes", node_id) local section = uci:section(appname, "nodes", node_id)
@ -294,6 +291,42 @@ do
end end
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
end) end)

View File

@ -0,0 +1,4 @@
{
"config": "passwall2_server",
"init": "passwall2_server"
}

View File

@ -0,0 +1,4 @@
{
"config": "passwall2",
"init": "passwall2"
}