Skip to content

Commit

Permalink
Merge branch 'xiaorouji:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
esaaprillia authored Apr 22, 2024
2 parents 20d41ef + 3d4101e commit e145e15
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 17 deletions.
2 changes: 1 addition & 1 deletion luci-app-passwall2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:= \
Expand Down
6 changes: 3 additions & 3 deletions luci-app-passwall2/luasrc/controller/passwall2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
2 changes: 1 addition & 1 deletion luci-app-passwall2/luasrc/view/passwall2/global/status.htm
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ <h4 id="status_github"><%:GitHub Connection%><br /><span id="_github_status" cla
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) {
Expand Down
4 changes: 2 additions & 2 deletions luci-app-passwall2/po/zh-cn/passwall2.po
Original file line number Diff line number Diff line change
Expand Up @@ -1288,8 +1288,8 @@ msgstr "日志"
msgid "Log"
msgstr "日志"

msgid "Close Node Log"
msgstr "关闭节点日志"
msgid "Enable Node Log"
msgstr "启用节点日志"

msgid "Log Level"
msgstr "日志等级"
Expand Down
4 changes: 4 additions & 0 deletions luci-app-passwall2/root/etc/uci-defaults/luci-passwall2
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion luci-app-passwall2/root/usr/share/passwall2/app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
47 changes: 40 additions & 7 deletions luci-app-passwall2/root/usr/share/passwall2/subscribe.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"config": "passwall2_server",
"init": "passwall2_server"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"config": "passwall2",
"init": "passwall2"
}

0 comments on commit e145e15

Please sign in to comment.