|
@ -3,6 +3,8 @@ module("luci.controller.mwan3", package.seeall) |
|
|
sys = require "luci.sys" |
|
|
sys = require "luci.sys" |
|
|
ut = require "luci.util" |
|
|
ut = require "luci.util" |
|
|
|
|
|
|
|
|
|
|
|
ip = "/usr/bin/ip -4 " |
|
|
|
|
|
|
|
|
function index() |
|
|
function index() |
|
|
if not nixio.fs.access("/etc/config/mwan3") then |
|
|
if not nixio.fs.access("/etc/config/mwan3") then |
|
|
return |
|
|
return |
|
@ -61,7 +63,7 @@ end |
|
|
|
|
|
|
|
|
function getInterfaceStatus(ruleNumber, interfaceName) |
|
|
function getInterfaceStatus(ruleNumber, interfaceName) |
|
|
if ut.trim(sys.exec("uci -p /var/state get 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 -p /var/state get 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 |
|
@ -183,8 +185,8 @@ function diagnosticsData(interface, tool, task) |
|
|
end |
|
|
end |
|
|
elseif tool == "rulechk" then |
|
|
elseif tool == "rulechk" then |
|
|
getInterfaceNumber() |
|
|
getInterfaceNumber() |
|
|
local rule1 = sys.exec("ip rule | grep $(echo $((" .. interfaceNumber .. " + 1000)))") |
|
|
|
|
|
local rule2 = sys.exec("ip rule | grep $(echo $((" .. interfaceNumber .. " + 2000)))") |
|
|
|
|
|
|
|
|
local rule1 = sys.exec(ip .. "rule | grep $(echo $((" .. interfaceNumber .. " + 1000)))") |
|
|
|
|
|
local rule2 = sys.exec(ip .. "rule | grep $(echo $((" .. interfaceNumber .. " + 2000)))") |
|
|
if rule1 ~= "" and rule2 ~= "" then |
|
|
if rule1 ~= "" and rule2 ~= "" then |
|
|
results = "All required interface IP rules found:\n\n" .. rule1 .. rule2 |
|
|
results = "All required interface IP rules found:\n\n" .. rule1 .. rule2 |
|
|
elseif rule1 ~= "" or rule2 ~= "" then |
|
|
elseif rule1 ~= "" or rule2 ~= "" then |
|
@ -194,7 +196,7 @@ function diagnosticsData(interface, tool, task) |
|
|
end |
|
|
end |
|
|
elseif tool == "routechk" then |
|
|
elseif tool == "routechk" then |
|
|
getInterfaceNumber() |
|
|
getInterfaceNumber() |
|
|
local routeTable = sys.exec("ip route list table " .. interfaceNumber) |
|
|
|
|
|
|
|
|
local routeTable = sys.exec(ip .. "route list table " .. interfaceNumber) |
|
|
if routeTable ~= "" then |
|
|
if routeTable ~= "" then |
|
|
results = "Interface routing table " .. interfaceNumber .. " was found:\n\n" .. routeTable |
|
|
results = "Interface routing table " .. interfaceNumber .. " was found:\n\n" .. routeTable |
|
|
else |
|
|
else |
|
@ -283,17 +285,17 @@ function troubleshootingData() |
|
|
mArray.routeshow = { routeShow } |
|
|
mArray.routeshow = { routeShow } |
|
|
|
|
|
|
|
|
-- ip rule show |
|
|
-- ip rule show |
|
|
local ipRuleShow = ut.trim(sys.exec("ip rule show")) |
|
|
|
|
|
|
|
|
local ipRuleShow = ut.trim(sys.exec(ip .. "rule show")) |
|
|
if ipRuleShow == "" then |
|
|
if ipRuleShow == "" then |
|
|
ipRuleShow = "No data found" |
|
|
ipRuleShow = "No data found" |
|
|
end |
|
|
end |
|
|
mArray.iprule = { ipRuleShow } |
|
|
mArray.iprule = { ipRuleShow } |
|
|
|
|
|
|
|
|
-- ip route list table 1-250 |
|
|
-- ip route list table 1-250 |
|
|
local routeList, routeString = ut.trim(sys.exec("ip rule | sed 's/://g' | awk '$1>=2001 && $1<=2250' | awk '{print $NF}'")), "" |
|
|
|
|
|
|
|
|
local routeList, routeString = ut.trim(sys.exec(ip .. "rule | sed 's/://g' | awk '$1>=2001 && $1<=2250' | awk '{print $NF}'")), "" |
|
|
if routeList ~= "" then |
|
|
if routeList ~= "" then |
|
|
for line in routeList:gmatch("[^\r\n]+") do |
|
|
for line in routeList:gmatch("[^\r\n]+") do |
|
|
routeString = routeString .. line .. "\n" .. sys.exec("ip route list table " .. line) |
|
|
|
|
|
|
|
|
routeString = routeString .. line .. "\n" .. sys.exec(ip .. "route list table " .. line) |
|
|
end |
|
|
end |
|
|
routeString = ut.trim(routeString) |
|
|
routeString = ut.trim(routeString) |
|
|
else |
|
|
else |
|
|