From 3a3aab545f2381cfde638e771b75df24cbdbacb1 Mon Sep 17 00:00:00 2001 From: CN_SZTL Date: Fri, 28 Feb 2020 18:38:43 +0800 Subject: [PATCH] luci-app-passwall: sync with upstream source --- package/lienol/luci-app-passwall/Makefile | 4 +- .../luasrc/controller/passwall.lua | 15 +- .../luasrc/view/passwall/global/status.htm | 26 ++- .../luasrc/view/passwall/global/status2.htm | 196 +++++++++++------- .../root/usr/share/passwall/app.sh | 11 +- .../root/usr/share/passwall/monitor.sh | 11 +- 6 files changed, 167 insertions(+), 96 deletions(-) diff --git a/package/lienol/luci-app-passwall/Makefile b/package/lienol/luci-app-passwall/Makefile index e1c222aca7..2cebd16aaf 100644 --- a/package/lienol/luci-app-passwall/Makefile +++ b/package/lienol/luci-app-passwall/Makefile @@ -7,8 +7,8 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-passwall PKG_VERSION:=3.6 -PKG_RELEASE:=5 -PKG_DATE:=20200227 +PKG_RELEASE:=6 +PKG_DATE:=20200228 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) diff --git a/package/lienol/luci-app-passwall/luasrc/controller/passwall.lua b/package/lienol/luci-app-passwall/luasrc/controller/passwall.lua index 42fef6bdf0..69cee959cc 100644 --- a/package/lienol/luci-app-passwall/luasrc/controller/passwall.lua +++ b/package/lienol/luci-app-passwall/luasrc/controller/passwall.lua @@ -120,14 +120,14 @@ function status() e.haproxy_status = luci.sys.call(string.format( "ps -w | grep -v grep | grep '%s/bin/' | grep haproxy >/dev/null", appname)) == 0 - e.kcptun_status = luci.sys.call( - "ps -w | grep -v grep | grep -i 'log /var/etc/" .. - appname .. "/kcptun' >/dev/null") == 0 - local tcp_node_num = luci.sys.exec( "echo -n `uci -q get %s.@global_other[0].tcp_node_num`" % appname) for i = 1, tcp_node_num, 1 do + e["kcptun_tcp_node%s_status" % i] = + luci.sys.call(string.format( + "ps -w | grep -v grep | grep '%s/bin/' | grep 'kcptun_tcp_%s' >/dev/null", + appname, i)) == 0 e["tcp_node%s_status" % i] = luci.sys.call( string.format( "ps -w | grep -v grep | grep '%s/bin/' | grep -i -E 'TCP_%s|brook_tcp_%s|ipt2socks_tcp_%s' >/dev/null", @@ -148,6 +148,10 @@ function status() "echo -n `uci -q get %s.@global_other[0].socks5_node_num`" % appname) for i = 1, socks5_node_num, 1 do + e["kcptun_socks_node%s_status" % i] = + luci.sys.call(string.format( + "ps -w | grep -v grep | grep '%s/bin/' | grep 'kcptun_socks_%s' >/dev/null", + appname, i)) == 0 e["socks5_node%s_status" % i] = luci.sys.call( string.format( "ps -w | grep -v grep | grep '%s/bin/' | grep -i -E 'SOCKS5_%s|brook_socks_%s' >/dev/null", @@ -185,6 +189,9 @@ function ping_node() if luci.sys.exec("echo -n `uci -q get %s.@global_other[0].use_tcping`" % appname) == "1" and luci.sys.exec("echo -n $(command -v tcping)") ~= "" then + luci.sys.call(string.format( + "ps -w | grep 'tcping -q -c 1 -i 1 -p %s %s' | grep -v grep | awk '{print $1}' | xargs kill -9 > /dev/null", + port, address)) e.ping = luci.sys.exec(string.format( "echo -n $(tcping -q -c 1 -i 1 -p %s %s 2>&1 | grep -o 'time=[0-9]*' | awk -F '=' '{print$2}')", port, address)) diff --git a/package/lienol/luci-app-passwall/luasrc/view/passwall/global/status.htm b/package/lienol/luci-app-passwall/luasrc/view/passwall/global/status.htm index 6c45e32cd1..51207299c5 100644 --- a/package/lienol/luci-app-passwall/luasrc/view/passwall/global/status.htm +++ b/package/lienol/luci-app-passwall/luasrc/view/passwall/global/status.htm @@ -283,6 +283,25 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md } status_tcp_node.innerHTML = text; } + var status_kcptun = document.getElementById('status_kcptun'); + if (status_kcptun) { + var text = 'Kcptun
'; + if (tcp_node_num == 1) { + if (data["kcptun_tcp_node1_status"]) + text += '<%:RUNNING%>'; + else + text += '<%:NOT RUNNING%>'; + } else { + for(var i = 0; i < tcp_node_num; i++) { + var k = i + 1; + if (data["kcptun_tcp_node" + k + "_status"]) + text += ''; + else + text += ' X'; + } + } + status_kcptun.innerHTML = text; + } } var udp_node_num = <%=udp_node_num%>; @@ -343,13 +362,6 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md status_haproxy.innerHTML = '<%:Load Balancing%>
<%:NOT RUNNING%>' } } - if (status_kcptun) { - if (data.kcptun_status) { - status_kcptun.innerHTML = 'Kcptun
<%:RUNNING%>' - } else { - status_kcptun.innerHTML = 'Kcptun
<%:NOT RUNNING%>' - } - } } }); diff --git a/package/lienol/luci-app-passwall/luasrc/view/passwall/global/status2.htm b/package/lienol/luci-app-passwall/luasrc/view/passwall/global/status2.htm index 159919befa..dd504d3153 100644 --- a/package/lienol/luci-app-passwall/luasrc/view/passwall/global/status2.htm +++ b/package/lienol/luci-app-passwall/luasrc/view/passwall/global/status2.htm @@ -64,53 +64,44 @@ local status_show_ip111 = api.uci_get_type("global_other", "status_show_ip111", <%:Running Status%>
- <% if tcp_node_num and tonumber(tcp_node_num) >= 1 then %> - <% for i = 1, tcp_node_num, 1 do %> -
- -
- <%:Collecting data...%> -
-
- <% end %> - <% end %> - - <% if udp_node_num and tonumber(udp_node_num) >= 1 then %> - <% for i = 1, udp_node_num, 1 do %> -
- -
- <%:Collecting data...%> -
-
- <% end %> - <% end %> - - <% if socks5_node_num and tonumber(socks5_node_num) >= 1 then %> - <% for i = 1, socks5_node_num, 1 do %> -
- -
- <%:Collecting data...%> -
-
- <% end %> - <% end %> -
-
<% end %> - <% if ipkg.installed("kcptun") or is_finded("kcptun*") then %> +
-