mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
More info and checks in status page
This commit is contained in:
parent
05c4fe5ad0
commit
c3f51af9a2
5 changed files with 89 additions and 21 deletions
|
@ -6,7 +6,7 @@
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
LUCI_TITLE:=LuCI Support for OpenMPTCProuter
|
LUCI_TITLE:=LuCI Support for OpenMPTCProuter
|
||||||
LUCI_DEPENDS:=+luci-lib-json +rdisc6 +curl
|
LUCI_DEPENDS:=+luci-lib-json +rdisc6 +curl +whois +bind-dig
|
||||||
PKG_LICENSE:=GPLv3
|
PKG_LICENSE:=GPLv3
|
||||||
|
|
||||||
include ../luci/luci.mk
|
include ../luci/luci.mk
|
||||||
|
|
|
@ -358,13 +358,22 @@ end
|
||||||
|
|
||||||
function get_ip(interface)
|
function get_ip(interface)
|
||||||
local dump = require("luci.util").ubus("network.interface.%s" % interface, "status", {})
|
local dump = require("luci.util").ubus("network.interface.%s" % interface, "status", {})
|
||||||
local ip
|
local ip = ""
|
||||||
if dump and dump['ipv4-address'] then
|
if dump and dump['ipv4-address'] then
|
||||||
local _, ipv4address
|
local _, ipv4address
|
||||||
for _, ipv4address in ipairs(dump['ipv4-address']) do
|
for _, ipv4address in ipairs(dump['ipv4-address']) do
|
||||||
ip = dump['ipv4-address'][_].address
|
ip = dump['ipv4-address'][_].address
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if ip == "" then
|
||||||
|
local dump = require("luci.util").ubus("network.interface.%s_4" % interface, "status", {})
|
||||||
|
if dump and dump['ipv4-address'] then
|
||||||
|
local _, ipv4address
|
||||||
|
for _, ipv4address in ipairs(dump['ipv4-address']) do
|
||||||
|
ip = dump['ipv4-address'][_].address
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
return ip
|
return ip
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -387,6 +396,19 @@ function get_gateway(interface)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if gateway == "" then
|
||||||
|
dump = require("luci.util").ubus("network.interface.%s_4" % interface, "status", {})
|
||||||
|
|
||||||
|
if dump and dump.route then
|
||||||
|
local _, route
|
||||||
|
for _, route in ipairs(dump.route) do
|
||||||
|
if dump.route[_].target == "0.0.0.0" then
|
||||||
|
gateway = dump.route[_].nexthop
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
return gateway
|
return gateway
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -405,7 +427,7 @@ function interfaces_status()
|
||||||
-- OpenMPTCProuter info
|
-- OpenMPTCProuter info
|
||||||
mArray.openmptcprouter = {}
|
mArray.openmptcprouter = {}
|
||||||
mArray.openmptcprouter["version"] = ut.trim(sys.exec("cat /etc/os-release | grep VERSION= | sed -e 's:VERSION=::'"))
|
mArray.openmptcprouter["version"] = ut.trim(sys.exec("cat /etc/os-release | grep VERSION= | sed -e 's:VERSION=::'"))
|
||||||
-- Check that requester is in same network
|
|
||||||
mArray.openmptcprouter["service_addr"] = uci:get("shadowsocks-libev", "proxy", "server") or "0.0.0.0"
|
mArray.openmptcprouter["service_addr"] = uci:get("shadowsocks-libev", "proxy", "server") or "0.0.0.0"
|
||||||
mArray.openmptcprouter["local_addr"] = uci:get("network", "lan", "ipaddr")
|
mArray.openmptcprouter["local_addr"] = uci:get("network", "lan", "ipaddr")
|
||||||
|
|
||||||
|
@ -543,6 +565,7 @@ function interfaces_status()
|
||||||
local ipaddr = net:ipaddr()
|
local ipaddr = net:ipaddr()
|
||||||
local gateway = section['gateway'] or ""
|
local gateway = section['gateway'] or ""
|
||||||
local multipath = section['multipath']
|
local multipath = section['multipath']
|
||||||
|
local enabled = section['auto']
|
||||||
|
|
||||||
--if not ipaddr or not gateway then return end
|
--if not ipaddr or not gateway then return end
|
||||||
-- Don't show if0 in the overview
|
-- Don't show if0 in the overview
|
||||||
|
@ -556,7 +579,8 @@ function interfaces_status()
|
||||||
--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
|
if multipath == "off" then return end
|
||||||
|
|
||||||
local asn
|
if enabled == "0" then return end
|
||||||
|
|
||||||
local connectivity
|
local connectivity
|
||||||
|
|
||||||
if ifname ~= "" and ifname ~= nil then
|
if ifname ~= "" and ifname ~= nil then
|
||||||
|
@ -588,12 +612,22 @@ function interfaces_status()
|
||||||
connectivity = 'WARNING'
|
connectivity = 'WARNING'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
else
|
||||||
|
|
||||||
if gateway == "" then
|
|
||||||
connectivity = 'ERROR'
|
connectivity = 'ERROR'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local latency = "-"
|
||||||
|
local server_ping = 'UP'
|
||||||
|
local server_ping_test = sys.exec("ping -W 1 -c 1 -I " .. ifname .. " " .. mArray.openmptcprouter["wan_addr"])
|
||||||
|
local server_ping_result = ut.trim(sys.exec("echo '" .. server_ping_test .. "' | grep '100% packet loss'"))
|
||||||
|
if server_ping_result ~= "" then
|
||||||
|
server_ping = 'DOWN'
|
||||||
|
if connectivity == "OK" then
|
||||||
|
connectivity = 'WARNING'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local latency = ut.trim(sys.exec("echo '" .. server_ping_test .. "' | cut -d '/' -s -f4 | cut -d '.' -f1"))
|
||||||
|
|
||||||
if mArray.openmptcprouter["dns"] == true and ifname ~= nil and gateway ~= "" and gw_ping == "UP" then
|
if mArray.openmptcprouter["dns"] == true and ifname ~= nil and gateway ~= "" and gw_ping == "UP" then
|
||||||
-- Test if multipath can work on the connection
|
-- Test if multipath can work on the connection
|
||||||
local multipath_available
|
local multipath_available
|
||||||
|
@ -630,9 +664,8 @@ function interfaces_status()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local publicIP = "-"
|
local publicIP = ut.trim(sys.exec("omr-ip-intf " .. ifname))
|
||||||
|
local whois = ut.trim(sys.exec("whois " .. publicIP .. " | grep -i 'netname' | awk '{print $2}'"))
|
||||||
local latency = "-"
|
|
||||||
|
|
||||||
local data = {
|
local data = {
|
||||||
label = section['label'] or interface,
|
label = section['label'] or interface,
|
||||||
|
@ -645,11 +678,12 @@ function interfaces_status()
|
||||||
status = connectivity,
|
status = connectivity,
|
||||||
wanip = publicIP,
|
wanip = publicIP,
|
||||||
latency = latency,
|
latency = latency,
|
||||||
whois = asn and asn.as_description or "unknown",
|
whois = whois or "unknown",
|
||||||
qos = section['trafficcontrol'],
|
qos = section['trafficcontrol'],
|
||||||
download = section['download'],
|
download = section['download'],
|
||||||
upload = section['upload'],
|
upload = section['upload'],
|
||||||
gw_ping = gw_ping,
|
gw_ping = gw_ping,
|
||||||
|
server_ping = server_ping,
|
||||||
ipv6_discover = ipv6_discover,
|
ipv6_discover = ipv6_discover,
|
||||||
multipath_available = multipath_available,
|
multipath_available = multipath_available,
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,6 +145,9 @@
|
||||||
if (mArray.openmptcprouter.tun6_state == "DOWN")
|
if (mArray.openmptcprouter.tun6_state == "DOWN")
|
||||||
{
|
{
|
||||||
statusMessage += 'VPN IPv6 tunnel DOWN<br/>';
|
statusMessage += 'VPN IPv6 tunnel DOWN<br/>';
|
||||||
|
} else if (mArray.openmptcprouter.wan_addr6 == '')
|
||||||
|
{
|
||||||
|
statusMessage += 'No IPv6 access<br/>';
|
||||||
}
|
}
|
||||||
if (statusMessage !== "")
|
if (statusMessage !== "")
|
||||||
{
|
{
|
||||||
|
@ -158,6 +161,7 @@
|
||||||
if (mArray.wans)
|
if (mArray.wans)
|
||||||
{
|
{
|
||||||
temp += '<td><ul>';
|
temp += '<td><ul>';
|
||||||
|
var master = 0;
|
||||||
for( var i = 0; i < mArray.wans.length; i++ )
|
for( var i = 0; i < mArray.wans.length; i++ )
|
||||||
{
|
{
|
||||||
// Get link color
|
// Get link color
|
||||||
|
@ -193,9 +197,14 @@
|
||||||
var ipaddr = mArray.wans[i].ipaddr;
|
var ipaddr = mArray.wans[i].ipaddr;
|
||||||
var whois = mArray.wans[i].whois;
|
var whois = mArray.wans[i].whois;
|
||||||
var multipath = mArray.wans[i].multipath;
|
var multipath = mArray.wans[i].multipath;
|
||||||
|
if(multipath == 'master')
|
||||||
|
{
|
||||||
|
master++;
|
||||||
|
}
|
||||||
var latency = mArray.wans[i].latency;
|
var latency = mArray.wans[i].latency;
|
||||||
var gateway = mArray.wans[i].gateway;
|
var gateway = mArray.wans[i].gateway;
|
||||||
var gw_ping = mArray.wans[i].gw_ping;
|
var gw_ping = mArray.wans[i].gw_ping;
|
||||||
|
var server_ping = mArray.wans[i].server_ping;
|
||||||
var ipv6_discover = mArray.wans[i].ipv6_discover;
|
var ipv6_discover = mArray.wans[i].ipv6_discover;
|
||||||
var multipath_available = mArray.wans[i].multipath_available;
|
var multipath_available = mArray.wans[i].multipath_available;
|
||||||
// Generate template
|
// Generate template
|
||||||
|
@ -210,6 +219,18 @@
|
||||||
var title = mArray.wans[i].label + " (" + mArray.wans[i].gateway + ")";
|
var title = mArray.wans[i].label + " (" + mArray.wans[i].gateway + ")";
|
||||||
//var content = String.format('%s<br />wan address: <strong>%s</strong><br />whois: %s<br />latency: %s ms<br />multipath: %s', stat, wanip, whois, latency, multipath);
|
//var content = String.format('%s<br />wan address: <strong>%s</strong><br />whois: %s<br />latency: %s ms<br />multipath: %s', stat, wanip, whois, latency, multipath);
|
||||||
var content = "";
|
var content = "";
|
||||||
|
if(wanip !== '')
|
||||||
|
{
|
||||||
|
content += String.format('wan address: <strong>%s</strong><br />', wanip);
|
||||||
|
}
|
||||||
|
if(whois !== '')
|
||||||
|
{
|
||||||
|
content += String.format('whois: %s<br />', whois);
|
||||||
|
}
|
||||||
|
if(latency !== '')
|
||||||
|
{
|
||||||
|
content += String.format('latency: %s ms<br />', latency);
|
||||||
|
}
|
||||||
if(ipaddr == '')
|
if(ipaddr == '')
|
||||||
{
|
{
|
||||||
statusMessage += 'No IP defined<br />'
|
statusMessage += 'No IP defined<br />'
|
||||||
|
@ -224,14 +245,27 @@
|
||||||
{
|
{
|
||||||
statusMessage += 'Multipath blocked on the connection<br />'
|
statusMessage += 'Multipath blocked on the connection<br />'
|
||||||
}
|
}
|
||||||
|
if(server_ping == 'DOWN')
|
||||||
|
{
|
||||||
|
statusMessage += 'Can\'t ping server<br />'
|
||||||
|
}
|
||||||
|
if(multipath == 'master' && master > 1)
|
||||||
|
{
|
||||||
|
statusMessage += 'Multipath master already defined<br />';
|
||||||
|
statusMessageClass = "error";
|
||||||
|
}
|
||||||
if(ipv6_discover == 'DETECTED')
|
if(ipv6_discover == 'DETECTED')
|
||||||
{
|
{
|
||||||
statusMessage += 'IPv6 route received<br />'
|
statusMessage += 'IPv6 route received<br />'
|
||||||
}
|
}
|
||||||
content += String.format('ip address: <strong>%s</strong><br />multipath: %s', ipaddr,multipath);
|
if(ipaddr != '')
|
||||||
|
{
|
||||||
|
content += String.format('ip address: <strong>%s</strong><br />', ipaddr);
|
||||||
|
}
|
||||||
|
content += String.format('multipath: %s<br />',multipath);
|
||||||
if(mArray.wans[i].qos && mArray.wans[i].download > 0 && mArray.wans[i].upload > 0)
|
if(mArray.wans[i].qos && mArray.wans[i].download > 0 && mArray.wans[i].upload > 0)
|
||||||
{
|
{
|
||||||
content += String.format('<br />traffic control: %s/%s kbps (%s)', mArray.wans[i].download, mArray.wans[i].upload, mArray.wans[i].qos)
|
content += String.format('traffic control: %s/%s kbps (%s)', mArray.wans[i].download, mArray.wans[i].upload, mArray.wans[i].qos)
|
||||||
}
|
}
|
||||||
temp += getNetworkNodeTemplate(equipmentIcon, statusIcon, title, statusMessageClass,statusMessage,content);
|
temp += getNetworkNodeTemplate(equipmentIcon, statusIcon, title, statusMessageClass,statusMessage,content);
|
||||||
|
|
||||||
|
|
5
luci-app-openmptcprouter/root/bin/omr-ip-intf
Executable file
5
luci-app-openmptcprouter/root/bin/omr-ip-intf
Executable file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/sh
|
||||||
|
checkip=$(dig +short A ip.openmptcprouter.com | tr -d "\n")
|
||||||
|
ipset add ss_rules_dst_bypass $checkip
|
||||||
|
curl -s -4 -m 3 --interface $1 http://ip.openmptcprouter.com
|
||||||
|
ipset del ss_rules_dst_bypass $checkip
|
|
@ -1,10 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
uci -q batch <<-EOF >/dev/null
|
multipathip=$(dig +short A multipath-tcp.org | tr -d "\n")
|
||||||
add_list dhcp.@dnsmasq[-1].ipset='/multipath-tcp.org/ss_rules_dst_bypass'
|
ipset add ss_rules_dst_bypass $multipathip
|
||||||
commit dhcp
|
|
||||||
EOF
|
|
||||||
curl -s -4 -m 3 --interface $1 http://www.multipath-tcp.org
|
curl -s -4 -m 3 --interface $1 http://www.multipath-tcp.org
|
||||||
uci -q batch <<-EOF >/dev/null
|
ipset del ss_rules_dst_bypass $multipathip
|
||||||
del_list dhcp.@dnsmasq[-1].ipset='/multipath-tcp.org/ss_rules_dst_bypass'
|
|
||||||
commit dhcp
|
|
||||||
EOF
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue