luci-app-passwall: merge upstream source
This commit is contained in:
parent
43a31e3b76
commit
4656f6934f
@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-passwall
|
||||
PKG_VERSION:=3.0
|
||||
PKG_RELEASE:=1-20200101
|
||||
PKG_RELEASE:=2-20200101
|
||||
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
PO2LMO:=./po2lmo
|
||||
|
||||
@ -51,10 +51,6 @@ function index()
|
||||
true
|
||||
entry({"admin", "vpn", "passwall", "check_port"}, call("check_port")).leaf =
|
||||
true
|
||||
entry({"admin", "vpn", "passwall", "auto_ping_node"}, call("auto_ping_node")).leaf =
|
||||
true
|
||||
entry({"admin", "vpn", "passwall", "auto_ping_node_list"},
|
||||
call("auto_ping_node_list")).leaf = true
|
||||
entry({"admin", "vpn", "passwall", "ping_node"}, call("ping_node")).leaf =
|
||||
true
|
||||
entry({"admin", "vpn", "passwall", "set_node"}, call("set_node")).leaf =
|
||||
@ -170,67 +166,23 @@ function connect_status()
|
||||
local e = {}
|
||||
if luci.http.formvalue("type") == "google" then
|
||||
e.status = luci.sys.call(
|
||||
"echo `/usr/share/passwall/test.sh test_url 'https://www.google.com'` | grep 200 >/dev/null") ==
|
||||
"echo `/usr/share/passwall/test.sh test_url 'www.google.com'` | grep 200 >/dev/null") ==
|
||||
0
|
||||
else
|
||||
e.status = luci.sys.call(
|
||||
"echo `/usr/share/passwall/test.sh test_url 'https://www.baidu.com'` | grep 200 >/dev/null") ==
|
||||
"echo `/usr/share/passwall/test.sh test_url 'www.baidu.com'` | grep 200 >/dev/null") ==
|
||||
0
|
||||
end
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
|
||||
function auto_ping_node()
|
||||
local index = luci.http.formvalue("index")
|
||||
local address = luci.http.formvalue("address")
|
||||
local port = luci.http.formvalue("port")
|
||||
local e = {}
|
||||
e.index = index
|
||||
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
|
||||
e.ping = luci.sys.exec(
|
||||
"echo -n `tcping -q -c 1 -i 1 -p " .. port .. " " ..
|
||||
address ..
|
||||
" 2>&1 | grep -o 'time=[0-9]*' | awk -F '=' '{print$2}'`")
|
||||
else
|
||||
e.ping = luci.sys.exec(
|
||||
"echo -n `ping -c 1 -W 1 %q 2>&1 | grep -o 'time=[0-9]*' | awk -F '=' '{print$2}'`" %
|
||||
address)
|
||||
end
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
|
||||
function auto_ping_node_list()
|
||||
local e = {}
|
||||
local index = luci.http.formvalue("index")
|
||||
local address = luci.http.formvalue("address")
|
||||
local port = luci.http.formvalue("port")
|
||||
|
||||
e.index = index
|
||||
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
|
||||
e.ping = luci.sys.exec(
|
||||
"echo -n `tcping -q -c 1 -i 1 -p " .. port .. " " ..
|
||||
address ..
|
||||
" 2>&1 | grep -o 'time=[0-9]*' | awk -F '=' '{print$2}'`")
|
||||
else
|
||||
e.ping = luci.sys.exec(
|
||||
"echo -n `ping -c 1 -W 1 %q 2>&1 | grep -o 'time=[0-9]*' | awk -F '=' '{print$2}'`" %
|
||||
address)
|
||||
end
|
||||
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
|
||||
function ping_node()
|
||||
local e = {}
|
||||
local index = luci.http.formvalue("index")
|
||||
local address = luci.http.formvalue("address")
|
||||
local port = luci.http.formvalue("port")
|
||||
local e = {}
|
||||
e.index = index
|
||||
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
|
||||
|
||||
@ -152,7 +152,7 @@ table td, .table .td {
|
||||
var port = document.getElementById("cbid.passwall." + cbi_id + ".port").value;
|
||||
<% end %>
|
||||
var json = JSON.stringify(auto_ping_value[index]);
|
||||
ajax.post('<%=dsp.build_url("admin/vpn/passwall/auto_ping_node_list")%>', {
|
||||
ajax.post('<%=dsp.build_url("admin/vpn/passwall/ping_node")%>', {
|
||||
index: index,
|
||||
address: address,
|
||||
port: port
|
||||
@ -199,4 +199,4 @@ table td, .table .td {
|
||||
<% end %>
|
||||
<input class="cbi-button cbi-button-remove" type="button" onclick="close_set_node_div()" value="<%:Close%>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -8,6 +8,7 @@ get_date() {
|
||||
}
|
||||
|
||||
test_url() {
|
||||
ps -ef | grep "$1" | grep -v grep | awk '{print $1}' | xargs kill -9
|
||||
status=$(/usr/bin/curl -I -o /dev/null -s --connect-timeout 3 -w %{http_code} "$1" | grep 200)
|
||||
[ "$?" != 0 ] && {
|
||||
status=$(/usr/bin/wget --no-check-certificate --spider --timeout=3 "$1")
|
||||
@ -140,4 +141,4 @@ test_url)
|
||||
*)
|
||||
start
|
||||
;;
|
||||
esac
|
||||
esac
|
||||
|
||||
Loading…
Reference in New Issue
Block a user