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
|
||||
|
||||
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
|
||||
|
||||
include ../luci/luci.mk
|
||||
|
|
|
@ -358,13 +358,22 @@ end
|
|||
|
||||
function get_ip(interface)
|
||||
local dump = require("luci.util").ubus("network.interface.%s" % interface, "status", {})
|
||||
local ip
|
||||
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
|
||||
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
|
||||
end
|
||||
|
||||
|
@ -387,6 +396,19 @@ function get_gateway(interface)
|
|||
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
|
||||
end
|
||||
|
||||
|
@ -405,7 +427,7 @@ function interfaces_status()
|
|||
-- OpenMPTCProuter info
|
||||
mArray.openmptcprouter = {}
|
||||
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["local_addr"] = uci:get("network", "lan", "ipaddr")
|
||||
|
||||
|
@ -543,6 +565,7 @@ function interfaces_status()
|
|||
local ipaddr = net:ipaddr()
|
||||
local gateway = section['gateway'] or ""
|
||||
local multipath = section['multipath']
|
||||
local enabled = section['auto']
|
||||
|
||||
--if not ipaddr or not gateway then return end
|
||||
-- Don't show if0 in the overview
|
||||
|
@ -555,8 +578,9 @@ function interfaces_status()
|
|||
|
||||
--if multipath == "off" and not ifname:match("^tun.*") then return end
|
||||
if multipath == "off" then return end
|
||||
|
||||
if enabled == "0" then return end
|
||||
|
||||
local asn
|
||||
local connectivity
|
||||
|
||||
if ifname ~= "" and ifname ~= nil then
|
||||
|
@ -588,11 +612,21 @@ function interfaces_status()
|
|||
connectivity = 'WARNING'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if gateway == "" then
|
||||
else
|
||||
connectivity = 'ERROR'
|
||||
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
|
||||
-- Test if multipath can work on the connection
|
||||
|
@ -630,9 +664,8 @@ function interfaces_status()
|
|||
end
|
||||
end
|
||||
|
||||
local publicIP = "-"
|
||||
|
||||
local latency = "-"
|
||||
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 data = {
|
||||
label = section['label'] or interface,
|
||||
|
@ -645,11 +678,12 @@ function interfaces_status()
|
|||
status = connectivity,
|
||||
wanip = publicIP,
|
||||
latency = latency,
|
||||
whois = asn and asn.as_description or "unknown",
|
||||
whois = whois or "unknown",
|
||||
qos = section['trafficcontrol'],
|
||||
download = section['download'],
|
||||
upload = section['upload'],
|
||||
gw_ping = gw_ping,
|
||||
server_ping = server_ping,
|
||||
ipv6_discover = ipv6_discover,
|
||||
multipath_available = multipath_available,
|
||||
}
|
||||
|
|
|
@ -145,6 +145,9 @@
|
|||
if (mArray.openmptcprouter.tun6_state == "DOWN")
|
||||
{
|
||||
statusMessage += 'VPN IPv6 tunnel DOWN<br/>';
|
||||
} else if (mArray.openmptcprouter.wan_addr6 == '')
|
||||
{
|
||||
statusMessage += 'No IPv6 access<br/>';
|
||||
}
|
||||
if (statusMessage !== "")
|
||||
{
|
||||
|
@ -158,6 +161,7 @@
|
|||
if (mArray.wans)
|
||||
{
|
||||
temp += '<td><ul>';
|
||||
var master = 0;
|
||||
for( var i = 0; i < mArray.wans.length; i++ )
|
||||
{
|
||||
// Get link color
|
||||
|
@ -193,9 +197,14 @@
|
|||
var ipaddr = mArray.wans[i].ipaddr;
|
||||
var whois = mArray.wans[i].whois;
|
||||
var multipath = mArray.wans[i].multipath;
|
||||
if(multipath == 'master')
|
||||
{
|
||||
master++;
|
||||
}
|
||||
var latency = mArray.wans[i].latency;
|
||||
var gateway = mArray.wans[i].gateway;
|
||||
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 multipath_available = mArray.wans[i].multipath_available;
|
||||
// Generate template
|
||||
|
@ -210,6 +219,18 @@
|
|||
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 = "";
|
||||
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 == '')
|
||||
{
|
||||
statusMessage += 'No IP defined<br />'
|
||||
|
@ -224,14 +245,27 @@
|
|||
{
|
||||
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')
|
||||
{
|
||||
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)
|
||||
{
|
||||
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);
|
||||
|
||||
|
|
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
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
add_list dhcp.@dnsmasq[-1].ipset='/multipath-tcp.org/ss_rules_dst_bypass'
|
||||
commit dhcp
|
||||
EOF
|
||||
multipathip=$(dig +short A multipath-tcp.org | tr -d "\n")
|
||||
ipset add ss_rules_dst_bypass $multipathip
|
||||
curl -s -4 -m 3 --interface $1 http://www.multipath-tcp.org
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
del_list dhcp.@dnsmasq[-1].ipset='/multipath-tcp.org/ss_rules_dst_bypass'
|
||||
commit dhcp
|
||||
EOF
|
||||
ipset del ss_rules_dst_bypass $multipathip
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue