mwan3-luci update to version 1.4-3

Fixed two issues in Chaos Calmer and trunk:
-troubleshooting page not displaying
-UCI arguments out of order because of switch to musl c library from uclibc

Signed-off-by: Aedan "arfett" Renner <chipdankly@gmail.com>
This commit is contained in:
arfett 2015-07-06 03:44:15 -07:00 committed by Steven Barth
parent b75488123b
commit 2150ffa21f
7 changed files with 30 additions and 28 deletions

View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-mwan3 PKG_NAME:=luci-app-mwan3
PKG_VERSION:=1.4 PKG_VERSION:=1.4
PKG_RELEASE:=2 PKG_RELEASE:=3
PKG_MAINTAINER:=Aedan Renner <chipdankly@gmail.com> PKG_MAINTAINER:=Aedan Renner <chipdankly@gmail.com>
PKG_LICENSE:=GPLv2 PKG_LICENSE:=GPLv2

View File

@ -13,7 +13,7 @@ send_alert()
gather_event_info() gather_event_info()
{ {
# create event information message # create event information message
local EVENT_INFO="Interface [ "$INTERFACE" ($DEVICE) ] on router [ "$(uci get -p /var/state system.@system[0].hostname)" ] has triggered a hotplug [ "$ACTION" ] event on "$(date +"%a %b %d %Y %T %Z")"" local EVENT_INFO="Interface [ "$INTERFACE" ($DEVICE) ] on router [ "$(uci -p /var/state get system.@system[0].hostname)" ] has triggered a hotplug [ "$ACTION" ] event on "$(date +"%a %b %d %Y %T %Z")""
# get current interface, policy and rule status # get current interface, policy and rule status
local CURRENT_STATUS="$(/usr/sbin/mwan3 status)" local CURRENT_STATUS="$(/usr/sbin/mwan3 status)"

View File

@ -60,9 +60,9 @@ function index()
end end
function getInterfaceStatus(ruleNumber, interfaceName) function getInterfaceStatus(ruleNumber, interfaceName)
if ut.trim(sys.exec("uci get -p /var/state mwan3." .. interfaceName .. ".enabled")) == "1" then if ut.trim(sys.exec("uci -p /var/state get mwan3." .. interfaceName .. ".enabled")) == "1" then
if ut.trim(sys.exec("ip route list table " .. ruleNumber)) ~= "" then if ut.trim(sys.exec("ip route list table " .. ruleNumber)) ~= "" then
if ut.trim(sys.exec("uci get -p /var/state mwan3." .. interfaceName .. ".track_ip")) ~= "" then if ut.trim(sys.exec("uci -p /var/state get mwan3." .. interfaceName .. ".track_ip")) ~= "" then
return "online" return "online"
else else
return "notMonitored" return "notMonitored"
@ -98,7 +98,7 @@ function interfaceStatus()
wansid = {} wansid = {}
for wanName, interfaceState in string.gfind(statusString, "([^%[]+)%[([^%]]+)%]") do for wanName, interfaceState in string.gfind(statusString, "([^%[]+)%[([^%]]+)%]") do
local wanInterfaceName = ut.trim(sys.exec("uci get -p /var/state network." .. wanName .. ".ifname")) local wanInterfaceName = ut.trim(sys.exec("uci -p /var/state get network." .. wanName .. ".ifname"))
if wanInterfaceName == "" then if wanInterfaceName == "" then
wanInterfaceName = "X" wanInterfaceName = "X"
end end
@ -159,7 +159,7 @@ function diagnosticsData(interface, tool, task)
results = "MWAN3 started" results = "MWAN3 started"
end end
else else
local interfaceDevice = ut.trim(sys.exec("uci get -p /var/state network." .. interface .. ".ifname")) local interfaceDevice = ut.trim(sys.exec("uci -p /var/state get network." .. interface .. ".ifname"))
if interfaceDevice ~= "" then if interfaceDevice ~= "" then
if tool == "ping" then if tool == "ping" then
local gateway = ut.trim(sys.exec("route -n | awk '{if ($8 == \"" .. interfaceDevice .. "\" && $1 == \"0.0.0.0\" && $3 == \"0.0.0.0\") print $2}'")) local gateway = ut.trim(sys.exec("route -n | awk '{if ($8 == \"" .. interfaceDevice .. "\" && $1 == \"0.0.0.0\" && $3 == \"0.0.0.0\") print $2}'"))
@ -168,7 +168,7 @@ function diagnosticsData(interface, tool, task)
local pingCommand = "ping -c 3 -W 2 -I " .. interfaceDevice .. " " .. gateway local pingCommand = "ping -c 3 -W 2 -I " .. interfaceDevice .. " " .. gateway
results = pingCommand .. "\n\n" .. sys.exec(pingCommand) results = pingCommand .. "\n\n" .. sys.exec(pingCommand)
else else
local tracked = ut.trim(sys.exec("uci get -p /var/state mwan3." .. interface .. ".track_ip")) local tracked = ut.trim(sys.exec("uci -p /var/state get mwan3." .. interface .. ".track_ip"))
if tracked ~= "" then if tracked ~= "" then
for z in tracked:gmatch("[^ ]+") do for z in tracked:gmatch("[^ ]+") do
local pingCommand = "ping -c 3 -W 2 -I " .. interfaceDevice .. " " .. z local pingCommand = "ping -c 3 -W 2 -I " .. interfaceDevice .. " " .. z
@ -223,16 +223,18 @@ function diagnosticsData(interface, tool, task)
end end
function troubleshootingData() function troubleshootingData()
local ver = require "luci.version"
local mArray = {} local mArray = {}
-- software versions -- software versions
local wrtRelease = ut.trim(luci.version.distversion) local wrtRelease = ut.trim(ver.distversion)
if wrtRelease ~= "" then if wrtRelease ~= "" then
wrtRelease = "OpenWrt - " .. wrtRelease wrtRelease = "OpenWrt - " .. wrtRelease
else else
wrtRelease = "OpenWrt - unknown" wrtRelease = "OpenWrt - unknown"
end end
local luciRelease = ut.trim(luci.version.luciversion) local luciRelease = ut.trim(ver.luciversion)
if luciRelease ~= "" then if luciRelease ~= "" then
luciRelease = "\nLuCI - " .. luciRelease luciRelease = "\nLuCI - " .. luciRelease
else else
@ -300,7 +302,7 @@ function troubleshootingData()
mArray.routelist = { routeString } mArray.routelist = { routeString }
-- default firewall output policy -- default firewall output policy
local firewallOut = ut.trim(sys.exec("uci get -p /var/state firewall.@defaults[0].output")) local firewallOut = ut.trim(sys.exec("uci -p /var/state get firewall.@defaults[0].output"))
if firewallOut == "" then if firewallOut == "" then
firewallOut = "No data found" firewallOut = "No data found"
end end

View File

@ -6,7 +6,7 @@ function interfaceCheck() -- find issues with too many interfaces, reliability a
local interfaceName = section[".name"] local interfaceName = section[".name"]
interfaceNumber = interfaceNumber+1 -- count number of mwan interfaces configured interfaceNumber = interfaceNumber+1 -- count number of mwan interfaces configured
-- create list of metrics for none and duplicate checking -- create list of metrics for none and duplicate checking
local metricValue = ut.trim(sys.exec("uci get -p /var/state network." .. interfaceName .. ".metric")) local metricValue = ut.trim(sys.exec("uci -p /var/state get network." .. interfaceName .. ".metric"))
if metricValue == "" then if metricValue == "" then
errorFound = 1 errorFound = 1
errorNoMetricList = errorNoMetricList .. interfaceName .. " " errorNoMetricList = errorNoMetricList .. interfaceName .. " "
@ -14,17 +14,17 @@ function interfaceCheck() -- find issues with too many interfaces, reliability a
metricList = metricList .. interfaceName .. " " .. metricValue .. "\n" metricList = metricList .. interfaceName .. " " .. metricValue .. "\n"
end end
-- check if any interfaces have a higher reliability requirement than tracking IPs configured -- check if any interfaces have a higher reliability requirement than tracking IPs configured
local trackingNumber = tonumber(ut.trim(sys.exec("echo $(uci get -p /var/state mwan3." .. interfaceName .. ".track_ip) | wc -w"))) local trackingNumber = tonumber(ut.trim(sys.exec("echo $(uci -p /var/state get mwan3." .. interfaceName .. ".track_ip) | wc -w")))
if trackingNumber > 0 then if trackingNumber > 0 then
local reliabilityNumber = tonumber(ut.trim(sys.exec("uci get -p /var/state mwan3." .. interfaceName .. ".reliability"))) local reliabilityNumber = tonumber(ut.trim(sys.exec("uci -p /var/state get mwan3." .. interfaceName .. ".reliability")))
if reliabilityNumber and reliabilityNumber > trackingNumber then if reliabilityNumber and reliabilityNumber > trackingNumber then
errorFound = 1 errorFound = 1
errorReliabilityList = errorReliabilityList .. interfaceName .. " " errorReliabilityList = errorReliabilityList .. interfaceName .. " "
end end
end end
-- check if any interfaces are not properly configured in /etc/config/network or have no default route in main routing table -- check if any interfaces are not properly configured in /etc/config/network or have no default route in main routing table
if ut.trim(sys.exec("uci get -p /var/state network." .. interfaceName)) == "interface" then if ut.trim(sys.exec("uci -p /var/state get network." .. interfaceName)) == "interface" then
local interfaceDevice = ut.trim(sys.exec("uci get -p /var/state network." .. interfaceName .. ".ifname")) local interfaceDevice = ut.trim(sys.exec("uci -p /var/state get network." .. interfaceName .. ".ifname"))
if interfaceDevice == "uci: Entry not found" or interfaceDevice == "" then if interfaceDevice == "uci: Entry not found" or interfaceDevice == "" then
errorFound = 1 errorFound = 1
errorNetConfigList = errorNetConfigList .. interfaceName .. " " errorNetConfigList = errorNetConfigList .. interfaceName .. " "
@ -220,7 +220,7 @@ up = mwan_interface:option(DummyValue, "up", translate("Interface up"))
metric = mwan_interface:option(DummyValue, "metric", translate("Metric")) metric = mwan_interface:option(DummyValue, "metric", translate("Metric"))
metric.rawhtml = true metric.rawhtml = true
function metric.cfgvalue(self, s) function metric.cfgvalue(self, s)
local metricValue = sys.exec("uci get -p /var/state network." .. s .. ".metric") local metricValue = sys.exec("uci -p /var/state get network." .. s .. ".metric")
if metricValue ~= "" then if metricValue ~= "" then
return metricValue return metricValue
else else

View File

@ -1,13 +1,13 @@
-- ------ extra functions ------ -- -- ------ extra functions ------ --
function interfaceCheck() function interfaceCheck()
metricValue = ut.trim(sys.exec("uci get -p /var/state network." .. arg[1] .. ".metric")) metricValue = ut.trim(sys.exec("uci -p /var/state get network." .. arg[1] .. ".metric"))
if metricValue == "" then -- no metric if metricValue == "" then -- no metric
errorNoMetric = 1 errorNoMetric = 1
else -- if metric exists create list of interface metrics to compare against for duplicates else -- if metric exists create list of interface metrics to compare against for duplicates
uci.cursor():foreach("mwan3", "interface", uci.cursor():foreach("mwan3", "interface",
function (section) function (section)
local metricValue = ut.trim(sys.exec("uci get -p /var/state network." .. section[".name"] .. ".metric")) local metricValue = ut.trim(sys.exec("uci -p /var/state get network." .. section[".name"] .. ".metric"))
metricList = metricList .. section[".name"] .. " " .. metricValue .. "\n" metricList = metricList .. section[".name"] .. " " .. metricValue .. "\n"
end end
) )
@ -22,16 +22,16 @@ function interfaceCheck()
end end
end end
-- check if this interface has a higher reliability requirement than track IPs configured -- check if this interface has a higher reliability requirement than track IPs configured
local trackingNumber = tonumber(ut.trim(sys.exec("echo $(uci get -p /var/state mwan3." .. arg[1] .. ".track_ip) | wc -w"))) local trackingNumber = tonumber(ut.trim(sys.exec("echo $(uci -p /var/state get mwan3." .. arg[1] .. ".track_ip) | wc -w")))
if trackingNumber > 0 then if trackingNumber > 0 then
local reliabilityNumber = tonumber(ut.trim(sys.exec("uci get -p /var/state mwan3." .. arg[1] .. ".reliability"))) local reliabilityNumber = tonumber(ut.trim(sys.exec("uci -p /var/state get mwan3." .. arg[1] .. ".reliability")))
if reliabilityNumber and reliabilityNumber > trackingNumber then if reliabilityNumber and reliabilityNumber > trackingNumber then
errorReliability = 1 errorReliability = 1
end end
end end
-- check if any interfaces are not properly configured in /etc/config/network or have no default route in main routing table -- check if any interfaces are not properly configured in /etc/config/network or have no default route in main routing table
if ut.trim(sys.exec("uci get -p /var/state network." .. arg[1])) == "interface" then if ut.trim(sys.exec("uci -p /var/state get network." .. arg[1])) == "interface" then
local interfaceDevice = ut.trim(sys.exec("uci get -p /var/state network." .. arg[1] .. ".ifname")) local interfaceDevice = ut.trim(sys.exec("uci -p /var/state get network." .. arg[1] .. ".ifname"))
if interfaceDevice == "uci: Entry not found" or interfaceDevice == "" then if interfaceDevice == "uci: Entry not found" or interfaceDevice == "" then
errorNetConfig = 1 errorNetConfig = 1
errorRoute = 1 errorRoute = 1

View File

@ -3,10 +3,10 @@
function ruleCheck() -- determine if rules needs a proper protocol configured function ruleCheck() -- determine if rules needs a proper protocol configured
uci.cursor():foreach("mwan3", "rule", uci.cursor():foreach("mwan3", "rule",
function (section) function (section)
local sourcePort = ut.trim(sys.exec("uci get -p /var/state mwan3." .. section[".name"] .. ".src_port")) local sourcePort = ut.trim(sys.exec("uci -p /var/state get mwan3." .. section[".name"] .. ".src_port"))
local destPort = ut.trim(sys.exec("uci get -p /var/state mwan3." .. section[".name"] .. ".dest_port")) local destPort = ut.trim(sys.exec("uci -p /var/state get mwan3." .. section[".name"] .. ".dest_port"))
if sourcePort ~= "" or destPort ~= "" then -- ports configured if sourcePort ~= "" or destPort ~= "" then -- ports configured
local protocol = ut.trim(sys.exec("uci get -p /var/state mwan3." .. section[".name"] .. ".proto")) local protocol = ut.trim(sys.exec("uci -p /var/state get mwan3." .. section[".name"] .. ".proto"))
if protocol == "" or protocol == "all" then -- no or improper protocol if protocol == "" or protocol == "all" then -- no or improper protocol
error_protocol_list = error_protocol_list .. section[".name"] .. " " error_protocol_list = error_protocol_list .. section[".name"] .. " "
end end

View File

@ -1,10 +1,10 @@
-- ------ extra functions ------ -- -- ------ extra functions ------ --
function ruleCheck() -- determine if rule needs a protocol specified function ruleCheck() -- determine if rule needs a protocol specified
local sourcePort = ut.trim(sys.exec("uci get -p /var/state mwan3." .. arg[1] .. ".src_port")) local sourcePort = ut.trim(sys.exec("uci -p /var/state get mwan3." .. arg[1] .. ".src_port"))
local destPort = ut.trim(sys.exec("uci get -p /var/state mwan3." .. arg[1] .. ".dest_port")) local destPort = ut.trim(sys.exec("uci -p /var/state get mwan3." .. arg[1] .. ".dest_port"))
if sourcePort ~= "" or destPort ~= "" then -- ports configured if sourcePort ~= "" or destPort ~= "" then -- ports configured
local protocol = ut.trim(sys.exec("uci get -p /var/state mwan3." .. arg[1] .. ".proto")) local protocol = ut.trim(sys.exec("uci -p /var/state get mwan3." .. arg[1] .. ".proto"))
if protocol == "" or protocol == "all" then -- no or improper protocol if protocol == "" or protocol == "all" then -- no or improper protocol
error_protocol = 1 error_protocol = 1
end end