mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-02-14 19:41:51 +00:00
Add tunnel status
This commit is contained in:
parent
b579c8847d
commit
5fa80cad83
2 changed files with 28 additions and 2 deletions
|
@ -158,6 +158,18 @@ function settings_add()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function get_ip(interface)
|
||||||
|
local dump = require("luci.util").ubus("network.interface.%s" % interface, "status", {})
|
||||||
|
local ip
|
||||||
|
if dump and dump['ipv4-address'] then
|
||||||
|
local _, ipv4address
|
||||||
|
for _, ipv4address in ipairs(dump['ipv4-address']) do
|
||||||
|
ip = dump['ipv4-address'][_].address
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return ip
|
||||||
|
end
|
||||||
|
|
||||||
-- This function come from OverTheBox by OVH with very small changes
|
-- This function come from OverTheBox by OVH with very small changes
|
||||||
function interfaces_status()
|
function interfaces_status()
|
||||||
local ut = require "luci.util"
|
local ut = require "luci.util"
|
||||||
|
@ -190,7 +202,16 @@ function interfaces_status()
|
||||||
mArray.openmptcprouter["tun_service"] = false
|
mArray.openmptcprouter["tun_service"] = false
|
||||||
if string.find(sys.exec("/usr/bin/pgrep '^(/usr/sbin/)?glorytun(-udp)?$'"), "%d+") then
|
if string.find(sys.exec("/usr/bin/pgrep '^(/usr/sbin/)?glorytun(-udp)?$'"), "%d+") then
|
||||||
mArray.openmptcprouter["tun_service"] = true
|
mArray.openmptcprouter["tun_service"] = true
|
||||||
|
mArray.openmptcprouter["tun_ip"] = get_ip("glorytun")
|
||||||
|
local tunnel_ping_test = ut.trim(sys.exec("ping -W 1 -c 1 10.0.0.1 | grep '100% packet loss'"))
|
||||||
|
if tunnel_ping_test == "" then
|
||||||
|
mArray.openmptcprouter["tun_state"] = 'UP'
|
||||||
|
else
|
||||||
|
mArray.openmptcprouter["tun_state"] = 'DOWN'
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
mArray.openmptcprouter["socks_service"] = false
|
mArray.openmptcprouter["socks_service"] = false
|
||||||
if string.find(sys.exec("/usr/bin/pgrep ss-redir"), "%d+") then
|
if string.find(sys.exec("/usr/bin/pgrep ss-redir"), "%d+") then
|
||||||
mArray.openmptcprouter["socks_service"] = true
|
mArray.openmptcprouter["socks_service"] = true
|
||||||
|
@ -251,7 +272,8 @@ function interfaces_status()
|
||||||
--if interface == "lo" then return end
|
--if interface == "lo" then return end
|
||||||
|
|
||||||
local ifname = section['ifname'] or ""
|
local ifname = section['ifname'] or ""
|
||||||
if multipath == "off" and not ifname:match("^tun.*") then return end
|
--if multipath == "off" and not ifname:match("^tun.*") then return end
|
||||||
|
if multipath == "off" then return end
|
||||||
|
|
||||||
local asn
|
local asn
|
||||||
|
|
||||||
|
|
|
@ -118,8 +118,12 @@
|
||||||
{
|
{
|
||||||
statusMessageClass = "error";
|
statusMessageClass = "error";
|
||||||
statusIcon = "<%=resource%>/openmptcprouter/images/statusError.png";
|
statusIcon = "<%=resource%>/openmptcprouter/images/statusError.png";
|
||||||
|
} else if (mArray.openmptcprouter.tun_state == "DOWN")
|
||||||
|
{
|
||||||
|
statusMessageClass = "warning";
|
||||||
|
statusIcon = "<%=resource%>/openmptcprouter/images/statusWarning.png";
|
||||||
|
statusMessage += 'Glorytun VPN tunnel DOWN';
|
||||||
}
|
}
|
||||||
|
|
||||||
temp += getNetworkNodeTemplate(equipmentIcon, statusIcon, title, statusMessageClass,statusMessage,content);
|
temp += getNetworkNodeTemplate(equipmentIcon, statusIcon, title, statusMessageClass,statusMessage,content);
|
||||||
temp += '</a></td>'
|
temp += '</a></td>'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue