Skip to content

Commit

Permalink
luci-app-passwall: merge upstream source
Browse files Browse the repository at this point in the history
  • Loading branch information
1715173329 committed Jan 1, 2020
1 parent 43a31e3 commit 4656f69
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 55 deletions.
2 changes: 1 addition & 1 deletion package/lienol/luci-app-passwall/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
54 changes: 3 additions & 51 deletions package/lienol/luci-app-passwall/luasrc/controller/passwall.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -170,18 +166,18 @@ 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()
function ping_node()
local index = luci.http.formvalue("index")
local address = luci.http.formvalue("address")
local port = luci.http.formvalue("port")
Expand All @@ -203,50 +199,6 @@ function auto_ping_node()
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 address = luci.http.formvalue("address")
local port = luci.http.formvalue("port")
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 set_node()
local protocol = luci.http.formvalue("protocol")
local number = luci.http.formvalue("number")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
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
Expand Down Expand Up @@ -199,4 +199,4 @@
<% end %>
<input class="cbi-button cbi-button-remove" type="button" onclick="close_set_node_div()" value="<%:Close%>">
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -140,4 +141,4 @@ test_url)
*)
start
;;
esac
esac

0 comments on commit 4656f69

Please sign in to comment.