PKG_NAME:=luci-app-mwan3
PKG_VERSION:=1.4
-PKG_RELEASE:=2
+PKG_RELEASE:=3
PKG_MAINTAINER:=Aedan Renner <chipdankly@gmail.com>
PKG_LICENSE:=GPLv2
gather_event_info()
{
# 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
local CURRENT_STATUS="$(/usr/sbin/mwan3 status)"
end
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("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"
else
return "notMonitored"
wansid = {}
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
wanInterfaceName = "X"
end
results = "MWAN3 started"
end
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 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 pingCommand = "ping -c 3 -W 2 -I " .. interfaceDevice .. " " .. gateway
results = pingCommand .. "\n\n" .. sys.exec(pingCommand)
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
for z in tracked:gmatch("[^ ]+") do
local pingCommand = "ping -c 3 -W 2 -I " .. interfaceDevice .. " " .. z
end
function troubleshootingData()
+ local ver = require "luci.version"
+
local mArray = {}
-- software versions
- local wrtRelease = ut.trim(luci.version.distversion)
+ local wrtRelease = ut.trim(ver.distversion)
if wrtRelease ~= "" then
wrtRelease = "OpenWrt - " .. wrtRelease
else
wrtRelease = "OpenWrt - unknown"
end
- local luciRelease = ut.trim(luci.version.luciversion)
+ local luciRelease = ut.trim(ver.luciversion)
if luciRelease ~= "" then
luciRelease = "\nLuCI - " .. luciRelease
else
mArray.routelist = { routeString }
-- 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
firewallOut = "No data found"
end
local interfaceName = section[".name"]
interfaceNumber = interfaceNumber+1 -- count number of mwan interfaces configured
-- 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
errorFound = 1
errorNoMetricList = errorNoMetricList .. interfaceName .. " "
metricList = metricList .. interfaceName .. " " .. metricValue .. "\n"
end
-- 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
- 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
errorFound = 1
errorReliabilityList = errorReliabilityList .. interfaceName .. " "
end
end
-- 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
- local interfaceDevice = ut.trim(sys.exec("uci get -p /var/state network." .. interfaceName .. ".ifname"))
+ if ut.trim(sys.exec("uci -p /var/state get network." .. interfaceName)) == "interface" then
+ local interfaceDevice = ut.trim(sys.exec("uci -p /var/state get network." .. interfaceName .. ".ifname"))
if interfaceDevice == "uci: Entry not found" or interfaceDevice == "" then
errorFound = 1
errorNetConfigList = errorNetConfigList .. interfaceName .. " "
metric = mwan_interface:option(DummyValue, "metric", translate("Metric"))
metric.rawhtml = true
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
return metricValue
else
-- ------ extra functions ------ --
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
errorNoMetric = 1
else -- if metric exists create list of interface metrics to compare against for duplicates
uci.cursor():foreach("mwan3", "interface",
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"
end
)
end
end
-- 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
- 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
errorReliability = 1
end
end
-- 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
- local interfaceDevice = ut.trim(sys.exec("uci get -p /var/state network." .. arg[1] .. ".ifname"))
+ if ut.trim(sys.exec("uci -p /var/state get network." .. arg[1])) == "interface" then
+ local interfaceDevice = ut.trim(sys.exec("uci -p /var/state get network." .. arg[1] .. ".ifname"))
if interfaceDevice == "uci: Entry not found" or interfaceDevice == "" then
errorNetConfig = 1
errorRoute = 1
function ruleCheck() -- determine if rules needs a proper protocol configured
uci.cursor():foreach("mwan3", "rule",
function (section)
- local sourcePort = ut.trim(sys.exec("uci get -p /var/state mwan3." .. section[".name"] .. ".src_port"))
- local destPort = ut.trim(sys.exec("uci get -p /var/state mwan3." .. section[".name"] .. ".dest_port"))
+ local sourcePort = ut.trim(sys.exec("uci -p /var/state get mwan3." .. section[".name"] .. ".src_port"))
+ local destPort = ut.trim(sys.exec("uci -p /var/state get mwan3." .. section[".name"] .. ".dest_port"))
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
error_protocol_list = error_protocol_list .. section[".name"] .. " "
end
-- ------ extra functions ------ --
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 destPort = ut.trim(sys.exec("uci get -p /var/state mwan3." .. arg[1] .. ".dest_port"))
+ local sourcePort = ut.trim(sys.exec("uci -p /var/state get mwan3." .. arg[1] .. ".src_port"))
+ local destPort = ut.trim(sys.exec("uci -p /var/state get mwan3." .. arg[1] .. ".dest_port"))
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
error_protocol = 1
end