Browse Source

mwan3-luci: update to 1.3-5

new naming/wording - more generically mwan than mwan3
renamed cryptic variables/functions/etc everywhere
removed unused and unnecessary variables everywhere
cleaned up ugly and inefficient Lua and Javascript

Signed-off-by: Aedan Renner chipdankly@gmail.com
lilik-openwrt-22.03
Aedan ARFETT Renner 10 years ago
parent
commit
0d93a49757
30 changed files with 917 additions and 991 deletions
  1. +2
    -2
      net/mwan3-luci/Makefile
  2. +5
    -5
      net/mwan3-luci/files/etc/hotplug.d/iface/16-mwancustombak
  3. +1
    -1
      net/mwan3-luci/files/etc/uci-defaults/mwan-luci
  4. +182
    -219
      net/mwan3-luci/files/usr/lib/lua/luci/controller/mwan3.lua
  5. +7
    -7
      net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan/advanced_hotplugscript.lua
  6. +5
    -5
      net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan/advanced_mwanconfig.lua
  7. +4
    -4
      net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan/advanced_networkconfig.lua
  8. +266
    -0
      net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan/interface.lua
  9. +54
    -55
      net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan/interfaceconfig.lua
  10. +5
    -5
      net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan/member.lua
  11. +2
    -2
      net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan/memberconfig.lua
  12. +20
    -20
      net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan/policy.lua
  13. +14
    -14
      net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan/policyconfig.lua
  14. +18
    -19
      net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan/rule.lua
  15. +20
    -20
      net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan/ruleconfig.lua
  16. +0
    -266
      net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan3/mwan3_interface.lua
  17. +1
    -0
      net/mwan3-luci/files/usr/lib/lua/luci/view/admin_status/index/mwan.htm
  18. +0
    -1
      net/mwan3-luci/files/usr/lib/lua/luci/view/admin_status/index/mwan3.htm
  19. +26
    -29
      net/mwan3-luci/files/usr/lib/lua/luci/view/mwan/advanced_diagnostics.htm
  20. +6
    -6
      net/mwan3-luci/files/usr/lib/lua/luci/view/mwan/advanced_hotplugscript.htm
  21. +6
    -6
      net/mwan3-luci/files/usr/lib/lua/luci/view/mwan/advanced_mwanconfig.htm
  22. +6
    -6
      net/mwan3-luci/files/usr/lib/lua/luci/view/mwan/advanced_networkconfig.htm
  23. +71
    -0
      net/mwan3-luci/files/usr/lib/lua/luci/view/mwan/advanced_troubleshooting.htm
  24. +6
    -6
      net/mwan3-luci/files/usr/lib/lua/luci/view/mwan/config_css.htm
  25. +17
    -26
      net/mwan3-luci/files/usr/lib/lua/luci/view/mwan/openwrt_overview_status.htm
  26. +51
    -0
      net/mwan3-luci/files/usr/lib/lua/luci/view/mwan/overview_detailed.htm
  27. +122
    -0
      net/mwan3-luci/files/usr/lib/lua/luci/view/mwan/overview_interface.htm
  28. +0
    -75
      net/mwan3-luci/files/usr/lib/lua/luci/view/mwan3/mwan3_adv_troubleshoot.htm
  29. +0
    -56
      net/mwan3-luci/files/usr/lib/lua/luci/view/mwan3/mwan3_over_detail.htm
  30. +0
    -136
      net/mwan3-luci/files/usr/lib/lua/luci/view/mwan3/mwan3_over_interface.htm

+ 2
- 2
net/mwan3-luci/Makefile View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-mwan3
PKG_VERSION:=1.3
PKG_RELEASE:=4
PKG_RELEASE:=5
PKG_MAINTAINER:=Aedan Renner <chipdankly@gmail.com>
PKG_LICENSE:=GPLv2
@ -20,7 +20,7 @@ define Package/luci-app-mwan3
CATEGORY:=LuCI
SUBMENU:=3. Applications
TITLE:=LuCI support for the MWAN3 multiwan hotplug script
DEPENDS:=+mwan3 +luci-mod-admin-full +luci-lib-nixio
DEPENDS:=+mwan3 +luci-mod-admin-full +luci-app-firewall +luci-lib-nixio
PKGARCH:=all
MAINTAINER:=Aedan Renner <chipdankly@gmail.com>
endef


net/mwan3-luci/files/etc/hotplug.d/iface/16-mwan3custombak → net/mwan3-luci/files/etc/hotplug.d/iface/16-mwancustombak View File


net/mwan3-luci/files/etc/uci-defaults/mwan3-luci → net/mwan3-luci/files/etc/uci-defaults/mwan-luci View File


+ 182
- 219
net/mwan3-luci/files/usr/lib/lua/luci/controller/mwan3.lua View File

@ -8,348 +8,311 @@ function index()
return
end
entry({"admin", "network", "mwan3"},
alias("admin", "network", "mwan3", "overview"),
entry({"admin", "network", "mwan"},
alias("admin", "network", "mwan", "overview"),
_("Load Balancing"), 600)
entry({"admin", "network", "mwan3", "overview"},
alias("admin", "network", "mwan3", "overview", "over_iface"),
entry({"admin", "network", "mwan", "overview"},
alias("admin", "network", "mwan", "overview", "overview_interface"),
_("Overview"), 10)
entry({"admin", "network", "mwan3", "overview", "over_iface"},
template("mwan3/mwan3_over_interface"))
entry({"admin", "network", "mwan3", "overview", "iface_status"},
call("mwan3_iface_status"))
entry({"admin", "network", "mwan3", "overview", "over_detail"},
template("mwan3/mwan3_over_detail"))
entry({"admin", "network", "mwan3", "overview", "detail_status"},
call("mwan3_detail_status"))
entry({"admin", "network", "mwan3", "configuration"},
alias("admin", "network", "mwan3", "configuration", "interface"),
entry({"admin", "network", "mwan", "overview", "overview_interface"},
template("mwan/overview_interface"))
entry({"admin", "network", "mwan", "overview", "interface_status"},
call("interfaceStatus"))
entry({"admin", "network", "mwan", "overview", "overview_detailed"},
template("mwan/overview_detailed"))
entry({"admin", "network", "mwan", "overview", "detailed_status"},
call("detailedStatus"))
entry({"admin", "network", "mwan", "configuration"},
alias("admin", "network", "mwan", "configuration", "interface"),
_("Configuration"), 20)
entry({"admin", "network", "mwan3", "configuration", "interface"},
arcombine(cbi("mwan3/mwan3_interface"), cbi("mwan3/mwan3_interfaceconfig")),
entry({"admin", "network", "mwan", "configuration", "interface"},
arcombine(cbi("mwan/interface"), cbi("mwan/interfaceconfig")),
_("Interfaces"), 10).leaf = true
entry({"admin", "network", "mwan3", "configuration", "member"},
arcombine(cbi("mwan3/mwan3_member"), cbi("mwan3/mwan3_memberconfig")),
entry({"admin", "network", "mwan", "configuration", "member"},
arcombine(cbi("mwan/member"), cbi("mwan/memberconfig")),
_("Members"), 20).leaf = true
entry({"admin", "network", "mwan3", "configuration", "policy"},
arcombine(cbi("mwan3/mwan3_policy"), cbi("mwan3/mwan3_policyconfig")),
entry({"admin", "network", "mwan", "configuration", "policy"},
arcombine(cbi("mwan/policy"), cbi("mwan/policyconfig")),
_("Policies"), 30).leaf = true
entry({"admin", "network", "mwan3", "configuration", "rule"},
arcombine(cbi("mwan3/mwan3_rule"), cbi("mwan3/mwan3_ruleconfig")),
entry({"admin", "network", "mwan", "configuration", "rule"},
arcombine(cbi("mwan/rule"), cbi("mwan/ruleconfig")),
_("Rules"), 40).leaf = true
entry({"admin", "network", "mwan3", "advanced"},
alias("admin", "network", "mwan3", "advanced", "hotplug"),
entry({"admin", "network", "mwan", "advanced"},
alias("admin", "network", "mwan", "advanced", "hotplugscript"),
_("Advanced"), 100)
entry({"admin", "network", "mwan3", "advanced", "hotplug"},
form("mwan3/mwan3_adv_hotplug"))
entry({"admin", "network", "mwan3", "advanced", "mwan3"},
form("mwan3/mwan3_adv_mwan3"))
entry({"admin", "network", "mwan3", "advanced", "network"},
form("mwan3/mwan3_adv_network"))
entry({"admin", "network", "mwan3", "advanced", "diag"},
template("mwan3/mwan3_adv_diagnostics"))
entry({"admin", "network", "mwan3", "advanced", "diag_display"},
call("mwan3_diag_data"), nil).leaf = true
entry({"admin", "network", "mwan3", "advanced", "tshoot"},
template("mwan3/mwan3_adv_troubleshoot"))
entry({"admin", "network", "mwan3", "advanced", "tshoot_display"},
call("mwan3_tshoot_data"))
entry({"admin", "network", "mwan", "advanced", "hotplugscript"},
form("mwan/advanced_hotplugscript"))
entry({"admin", "network", "mwan", "advanced", "mwanconfig"},
form("mwan/advanced_mwanconfig"))
entry({"admin", "network", "mwan", "advanced", "networkconfig"},
form("mwan/advanced_networkconfig"))
entry({"admin", "network", "mwan", "advanced", "diagnostics"},
template("mwan/advanced_diagnostics"))
entry({"admin", "network", "mwan", "advanced", "diagnostics_display"},
call("diagnosticsData"), nil).leaf = true
entry({"admin", "network", "mwan", "advanced", "troubleshooting"},
template("mwan/advanced_troubleshooting"))
entry({"admin", "network", "mwan", "advanced", "troubleshooting_display"},
call("troubleshootingData"))
end
function mwan3_get_iface_status(rulenum, ifname)
if ut.trim(sys.exec("uci get -p /var/state mwan3." .. ifname .. ".enabled")) == "1" then
if ut.trim(sys.exec("ip route list table " .. rulenum)) ~= "" then
if ut.trim(sys.exec("uci get -p /var/state mwan3." .. ifname .. ".track_ip")) ~= "" then
return "on"
function getInterfaceStatus(ruleNumber, interfaceName)
if ut.trim(sys.exec("uci get -p /var/state 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
return "online"
else
return "nm"
return "notMonitored"
end
else
return "off"
return "offline"
end
else
return "ne"
return "notEnabled"
end
end
function mwan3_get_iface()
local rulenum, str = 0, ""
function getInterfaceName()
local ruleNumber, status = 0, ""
uci.cursor():foreach("mwan3", "interface",
function (section)
rulenum = rulenum+1
str = str .. section[".name"] .. "[" .. mwan3_get_iface_status(rulenum, section[".name"]) .. "]"
ruleNumber = ruleNumber+1
status = status .. section[".name"] .. "[" .. getInterfaceStatus(ruleNumber, section[".name"]) .. "]"
end
)
return str
return status
end
function mwan3_iface_status()
function interfaceStatus()
local ntm = require "luci.model.network".init()
local rv = { }
local mArray = {}
-- overview status
local statstr = mwan3_get_iface()
if statstr ~= "" then
rv.wans = { }
local statusString = getInterfaceName()
if statusString ~= "" then
mArray.wans = {}
wansid = {}
for wanname, ifstat in string.gfind(statstr, "([^%[]+)%[([^%]]+)%]") do
local wanifname = ut.trim(sys.exec("uci get -p /var/state network." .. wanname .. ".ifname"))
if wanifname == "" then
wanifname = "X"
for wanName, interfaceState in string.gfind(statusString, "([^%[]+)%[([^%]]+)%]") do
local wanInterfaceName = ut.trim(sys.exec("uci get -p /var/state network." .. wanName .. ".ifname"))
if wanInterfaceName == "" then
wanInterfaceName = "X"
end
local wanlink = ntm:get_interface(wanifname)
wanlink = wanlink and wanlink:get_network()
wanlink = wanlink and wanlink:adminlink() or "#"
wansid[wanname] = #rv.wans + 1
rv.wans[wansid[wanname]] = { name = wanname, link = wanlink, ifname = wanifname, status = ifstat }
local wanDeviceLink = ntm:get_interface(wanInterfaceName)
wanDeviceLink = wanDeviceLink and wanDeviceLink:get_network()
wanDeviceLink = wanDeviceLink and wanDeviceLink:adminlink() or "#"
wansid[wanName] = #mArray.wans + 1
mArray.wans[wansid[wanName]] = { name = wanName, link = wanDeviceLink, ifname = wanInterfaceName, status = interfaceState }
end
end
-- overview status log
local mwlg = ut.trim(sys.exec("logread | grep mwan3 | tail -n 50 | sed 'x;1!H;$!d;x'"))
if mwlg ~= "" then
rv.mwan3log = { }
mwlog = {}
mwlog[mwlg] = #rv.mwan3log + 1
rv.mwan3log[mwlog[mwlg]] = { mwanlog = mwlg }
local mwanLog = ut.trim(sys.exec("logread | grep mwan3 | tail -n 50 | sed 'x;1!H;$!d;x'"))
if mwanLog ~= "" then
mArray.mwanlog = { mwanLog }
end
luci.http.prepare_content("application/json")
luci.http.write_json(rv)
luci.http.write_json(mArray)
end
function mwan3_detail_status()
local rv = { }
function detailedStatus()
local mArray = {}
-- detailed mwan3 status
local dst = ut.trim(sys.exec("mwan3 status"))
if dst ~= "" then
rv.mwan3dst = { }
dstat = {}
dstat[dst] = #rv.mwan3dst + 1
rv.mwan3dst[dstat[dst]] = { detailstat = dst }
-- detailed mwan status
local detailStatusInfo = ut.trim(sys.exec("/usr/sbin/mwan3 status"))
if detailStatusInfo ~= "" then
mArray.mwandetail = { detailStatusInfo }
end
luci.http.prepare_content("application/json")
luci.http.write_json(rv)
luci.http.write_json(mArray)
end
function mwan3_diag_data(iface, tool, alt)
function get_ifnum()
local num = 0
function diagnosticsData(interface, tool, task)
function getInterfaceNumber()
local number = 0
uci.cursor():foreach("mwan3", "interface",
function (section)
num = num+1
if section[".name"] == iface then
ifnum = num
number = number+1
if section[".name"] == interface then
interfaceNumber = number
end
end
)
end
local rv = { }
local mArray = {}
local res = ""
local results = ""
if tool == "service" then
os.execute("mwan3 " .. alt)
if alt == "restart" then
res = "MWAN3 restarted"
elseif alt == "stop" then
res = "MWAN3 stopped"
os.execute("/usr/sbin/mwan3 " .. task)
if task == "restart" then
results = "MWAN3 restarted"
elseif task == "stop" then
results = "MWAN3 stopped"
else
res = "MWAN3 started"
results = "MWAN3 started"
end
else
local ifdev = ut.trim(sys.exec("uci get -p /var/state network." .. iface .. ".ifname"))
if ifdev ~= "" then
local interfaceDevice = ut.trim(sys.exec("uci get -p /var/state network." .. interface .. ".ifname"))
if interfaceDevice ~= "" then
if tool == "ping" then
local gateway = ut.trim(sys.exec("route -n | awk '{ if ($8 == \"" .. ifdev .. "\" && $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}'"))
if gateway ~= "" then
if alt == "gateway" then
local cmd = "ping -c 3 -W 2 -I " .. ifdev .. " " .. gateway
res = cmd .. "\n\n" .. sys.exec(cmd)
if task == "gateway" then
local pingCommand = "ping -c 3 -W 2 -I " .. interfaceDevice .. " " .. gateway
results = pingCommand .. "\n\n" .. sys.exec(pingCommand)
else
local str = ut.trim(sys.exec("uci get -p /var/state mwan3." .. iface .. ".track_ip"))
if str ~= "" then
for z in str:gmatch("[^ ]+") do
local cmd = "ping -c 3 -W 2 -I " .. ifdev .. " " .. z
res = res .. cmd .. "\n\n" .. sys.exec(cmd) .. "\n\n"
local tracked = ut.trim(sys.exec("uci get -p /var/state mwan3." .. interface .. ".track_ip"))
if tracked ~= "" then
for z in tracked:gmatch("[^ ]+") do
local pingCommand = "ping -c 3 -W 2 -I " .. interfaceDevice .. " " .. z
results = results .. pingCommand .. "\n\n" .. sys.exec(pingCommand) .. "\n\n"
end
else
res = "No tracking IP addresses configured on " .. iface
results = "No tracking IP addresses configured on " .. interface
end
end
else
res = "No default gateway for " .. iface .. " found. Default route does not exist or is configured incorrectly"
results = "No default gateway for " .. interface .. " found. Default route does not exist or is configured incorrectly"
end
elseif tool == "rulechk" then
get_ifnum()
local rule1 = sys.exec("ip rule | grep $(echo $((" .. ifnum .. " + 1000)))")
local rule2 = sys.exec("ip rule | grep $(echo $((" .. ifnum .. " + 2000)))")
getInterfaceNumber()
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
res = "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
res = "Missing 1 of the 2 required interface IP rules\n\n\nRules found:\n\n" .. rule1 .. rule2
results = "Missing 1 of the 2 required interface IP rules\n\n\nRules found:\n\n" .. rule1 .. rule2
else
res = "Missing both of the required interface IP rules"
results = "Missing both of the required interface IP rules"
end
elseif tool == "routechk" then
get_ifnum()
local table = sys.exec("ip route list table " .. ifnum)
if table ~= "" then
res = "Interface routing table " .. ifnum .. " was found:\n\n" .. table
getInterfaceNumber()
local routeTable = sys.exec("ip route list table " .. interfaceNumber)
if routeTable ~= "" then
results = "Interface routing table " .. interfaceNumber .. " was found:\n\n" .. routeTable
else
res = "Missing required interface routing table " .. ifnum
results = "Missing required interface routing table " .. interfaceNumber
end
elseif tool == "hotplug" then
if alt == "ifup" then
os.execute("mwan3 ifup " .. iface)
res = "Hotplug ifup sent to interface " .. iface .. "..."
if task == "ifup" then
os.execute("/usr/sbin/mwan3 ifup " .. interface)
results = "Hotplug ifup sent to interface " .. interface .. "..."
else
os.execute("mwan3 ifdown " .. iface)
res = "Hotplug ifdown sent to interface " .. iface .. "..."
os.execute("/usr/sbin/mwan3 ifdown " .. interface)
results = "Hotplug ifdown sent to interface " .. interface .. "..."
end
end
else
res = "Unable to perform diagnostic tests on " .. iface .. ". There is no physical or virtual device associated with this interface"
results = "Unable to perform diagnostic tests on " .. interface .. ". There is no physical or virtual device associated with this interface"
end
end
if res ~= "" then
res = ut.trim(res)
rv.diagres = { }
dres = {}
dres[res] = #rv.diagres + 1
rv.diagres[dres[res]] = { diagresult = res }
if results ~= "" then
results = ut.trim(results)
mArray.diagnostics = { results }
end
luci.http.prepare_content("application/json")
luci.http.write_json(rv)
luci.http.write_json(mArray)
end
function mwan3_tshoot_data()
local rv = { }
function troubleshootingData()
local mArray = {}
-- software versions
local wrtrelease = ut.trim(luci.version.distversion)
if wrtrelease ~= "" then
wrtrelease = "OpenWrt - " .. wrtrelease
local wrtRelease = ut.trim(luci.version.distversion)
if wrtRelease ~= "" then
wrtRelease = "OpenWrt - " .. wrtRelease
else
wrtrelease = "OpenWrt - unknown"
wrtRelease = "OpenWrt - unknown"
end
local lucirelease = ut.trim(luci.version.luciversion)
if lucirelease ~= "" then
lucirelease = "\nLuCI - " .. lucirelease
local luciRelease = ut.trim(luci.version.luciversion)
if luciRelease ~= "" then
luciRelease = "\nLuCI - " .. luciRelease
else
lucirelease = "\nLuCI - unknown"
luciRelease = "\nLuCI - unknown"
end
local mwan3version = ut.trim(sys.exec("opkg info mwan3 | grep Version | awk '{ print $2 }'"))
if mwan3version ~= "" then
mwan3version = "\n\nmwan3 - " .. mwan3version
local mwanVersion = ut.trim(sys.exec("opkg info mwan3 | grep Version | awk '{print $2}'"))
if mwanVersion ~= "" then
mwanVersion = "\n\nmwan3 - " .. mwanVersion
else
mwan3version = "\nmwan3 - unknown"
mwanVersion = "\n\nmwan3 - unknown"
end
local mwan3lversion = ut.trim(sys.exec("opkg info luci-app-mwan3 | grep Version | awk '{ print $2 }'"))
if mwan3lversion ~= "" then
mwan3lversion = "\nmwan3-luci - " .. mwan3lversion
local mwanLuciVersion = ut.trim(sys.exec("opkg info luci-app-mwan3 | grep Version | awk '{print $2}'"))
if mwanLuciVersion ~= "" then
mwanLuciVersion = "\nmwan3-luci - " .. mwanLuciVersion
else
mwan3lversion = "\nmwan3-luci - unknown"
mwanLuciVersion = "\nmwan3-luci - unknown"
end
local softrev = wrtrelease .. lucirelease .. mwan3version .. mwan3lversion
rv.mw3ver = { }
mwv = {}
mwv[softrev] = #rv.mw3ver + 1
rv.mw3ver[mwv[softrev]] = { mwan3v = softrev }
-- mwan3 config
local mwcg = ut.trim(sys.exec("cat /etc/config/mwan3"))
if mwcg == "" then
mwcg = "No data found"
mArray.versions = { wrtRelease .. luciRelease .. mwanVersion .. mwanLuciVersion }
-- mwan config
local mwanConfig = ut.trim(sys.exec("cat /etc/config/mwan3"))
if mwanConfig == "" then
mwanConfig = "No data found"
end
rv.mwan3config = { }
mwan3cfg = {}
mwan3cfg[mwcg] = #rv.mwan3config + 1
rv.mwan3config[mwan3cfg[mwcg]] = { mwn3cfg = mwcg }
mArray.mwanconfig = { mwanConfig }
-- network config
local netcg = ut.trim(sys.exec("cat /etc/config/network | sed -e 's/.*username.*/ USERNAME HIDDEN/' -e 's/.*password.*/ PASSWORD HIDDEN/'"))
if netcg == "" then
netcg = "No data found"
local networkConfig = ut.trim(sys.exec("cat /etc/config/network | sed -e 's/.*username.*/ USERNAME HIDDEN/' -e 's/.*password.*/ PASSWORD HIDDEN/'"))
if networkConfig == "" then
networkConfig = "No data found"
end
rv.netconfig = { }
ncfg = {}
ncfg[netcg] = #rv.netconfig + 1
rv.netconfig[ncfg[netcg]] = { netcfg = netcg }
mArray.netconfig = { networkConfig }
-- ifconfig
local ifcg = ut.trim(sys.exec("ifconfig"))
if ifcg == "" then
ifcg = "No data found"
local ifconfig = ut.trim(sys.exec("ifconfig"))
if ifconfig == "" then
ifconfig = "No data found"
end
rv.ifconfig = { }
icfg = {}
icfg[ifcg] = #rv.ifconfig + 1
rv.ifconfig[icfg[ifcg]] = { ifcfg = ifcg }
mArray.ifconfig = { ifconfig }
-- route -n
local routeshow = ut.trim(sys.exec("route -n"))
if routeshow == "" then
routeshow = "No data found"
local routeShow = ut.trim(sys.exec("route -n"))
if routeShow == "" then
routeShow = "No data found"
end
rv.rtshow = { }
rshw = {}
rshw[routeshow] = #rv.rtshow + 1
rv.rtshow[rshw[routeshow]] = { iprtshow = routeshow }
mArray.routeshow = { routeShow }
-- ip rule show
local ipr = ut.trim(sys.exec("ip rule show"))
if ipr == "" then
ipr = "No data found"
local ipRuleShow = ut.trim(sys.exec("ip rule show"))
if ipRuleShow == "" then
ipRuleShow = "No data found"
end
rv.iprule = { }
ipruleid = {}
ipruleid[ipr] = #rv.iprule + 1
rv.iprule[ipruleid[ipr]] = { rule = ipr }
mArray.iprule = { ipRuleShow }
-- ip route list table 1-250
local routelisting, rlstr = ut.trim(sys.exec("ip rule | sed 's/://g' | awk '$1>=2001 && $1<=2250' | awk '{ print $NF }'")), ""
if routelisting ~= "" then
for line in routelisting:gmatch("[^\r\n]+") do
rlstr = rlstr .. line .. "\n" .. sys.exec("ip route list table " .. line)
local routeList, routeString = ut.trim(sys.exec("ip rule | sed 's/://g' | awk '$1>=2001 && $1<=2250' | awk '{print $NF}'")), ""
if routeList ~= "" then
for line in routeList:gmatch("[^\r\n]+") do
routeString = routeString .. line .. "\n" .. sys.exec("ip route list table " .. line)
end
rlstr = ut.trim(rlstr)
routeString = ut.trim(routeString)
else
rlstr = "No data found"
routeString = "No data found"
end
rv.routelist = { }
rtlist = {}
rtlist[rlstr] = #rv.routelist + 1
rv.routelist[rtlist[rlstr]] = { iprtlist = rlstr }
mArray.routelist = { routeString }
-- default firewall output policy
local defout = ut.trim(sys.exec("uci get -p /var/state firewall.@defaults[0].output"))
if defout == "" then
defout = "No data found"
local firewallOut = ut.trim(sys.exec("uci get -p /var/state firewall.@defaults[0].output"))
if firewallOut == "" then
firewallOut = "No data found"
end
rv.fidef = { }
fwdf = {}
fwdf[defout] = #rv.fidef + 1
rv.fidef[fwdf[defout]] = { firedef = defout }
mArray.firewallout = { firewallOut }
-- iptables
local iptbl = ut.trim(sys.exec("iptables -L -t mangle -v -n"))
if iptbl == "" then
iptbl = "No data found"
local iptables = ut.trim(sys.exec("iptables -L -t mangle -v -n"))
if iptables == "" then
iptables = "No data found"
end
rv.iptables = { }
tables = {}
tables[iptbl] = #rv.iptables + 1
rv.iptables[tables[iptbl]] = { iptbls = iptbl }
mArray.iptables = { iptables }
luci.http.prepare_content("application/json")
luci.http.write_json(rv)
luci.http.write_json(mArray)
end

net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan3/mwan3_adv_hotplug.lua → net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan/advanced_hotplugscript.lua View File


net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan3/mwan3_adv_mwan3.lua → net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan/advanced_mwanconfig.lua View File


net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan3/mwan3_adv_network.lua → net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan/advanced_networkconfig.lua View File


+ 266
- 0
net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan/interface.lua View File

@ -0,0 +1,266 @@
-- ------ extra functions ------ --
function interfaceCheck() -- find issues with too many interfaces, reliability and metric
uci.cursor():foreach("mwan3", "interface",
function (section)
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"))
if metricValue == "" then
errorFound = 1
errorNoMetricList = errorNoMetricList .. interfaceName .. " "
else
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")))
if trackingNumber > 0 then
local reliabilityNumber = tonumber(ut.trim(sys.exec("uci get -p /var/state 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 interfaceDevice == "uci: Entry not found" or interfaceDevice == "" then
errorFound = 1
errorNetConfigList = errorNetConfigList .. interfaceName .. " "
errorRouteList = errorRouteList .. interfaceName .. " "
else
local routeCheck = ut.trim(sys.exec("route -n | awk '{if ($8 == \"" .. interfaceDevice .. "\" && $1 == \"0.0.0.0\" && $3 == \"0.0.0.0\") print $1}'"))
if routeCheck == "" then
errorFound = 1
errorRouteList = errorRouteList .. interfaceName .. " "
end
end
else
errorFound = 1
errorNetConfigList = errorNetConfigList .. interfaceName .. " "
errorRouteList = errorRouteList .. interfaceName .. " "
end
end
)
-- check if any interfaces have duplicate metrics
local metricDuplicateNumbers = sys.exec("echo '" .. metricList .. "' | awk '{print $2}' | uniq -d")
if metricDuplicateNumbers ~= "" then
errorFound = 1
local metricDuplicates = ""
for line in metricDuplicateNumbers:gmatch("[^\r\n]+") do
metricDuplicates = sys.exec("echo '" .. metricList .. "' | grep '" .. line .. "' | awk '{print $1}'")
errorDuplicateMetricList = errorDuplicateMetricList .. metricDuplicates
end
errorDuplicateMetricList = sys.exec("echo '" .. errorDuplicateMetricList .. "' | tr '\n' ' '")
end
end
function interfaceWarnings() -- display status and warning messages at the top of the page
local warnings = ""
if interfaceNumber <= 250 then
warnings = "<strong>There are currently " .. interfaceNumber .. " of 250 supported interfaces configured</strong>"
else
warnings = "<font color=\"ff0000\"><strong>WARNING: " .. interfaceNumber .. " interfaces are configured exceeding the maximum of 250!</strong></font>"
end
if errorReliabilityList ~= " " then
warnings = warnings .. "<br /><br /><font color=\"ff0000\"><strong>WARNING: some interfaces have a higher reliability requirement than there are tracking IP addresses!</strong></font>"
end
if errorRouteList ~= " " then
warnings = warnings .. "<br /><br /><font color=\"ff0000\"><strong>WARNING: some interfaces have no default route in the main routing table!</strong></font>"
end
if errorNetConfigList ~= " " then
warnings = warnings .. "<br /><br /><font color=\"ff0000\"><strong>WARNING: some interfaces are configured incorrectly or not at all in /etc/config/network!</strong></font>"
end
if errorNoMetricList ~= " " then
warnings = warnings .. "<br /><br /><font color=\"ff0000\"><strong>WARNING: some interfaces have no metric configured in /etc/config/network!</strong></font>"
end
if errorDuplicateMetricList ~= " " then
warnings = warnings .. "<br /><br /><font color=\"ff0000\"><strong>WARNING: some interfaces have duplicate metrics configured in /etc/config/network!</strong></font>"
end
return warnings
end
-- ------ interface configuration ------ --
dsp = require "luci.dispatcher"
sys = require "luci.sys"
ut = require "luci.util"
interfaceNumber = 0
metricList = ""
errorFound = 0
errorDuplicateMetricList = " "
errorNetConfigList = " "
errorNoMetricList = " "
errorReliabilityList = " "
errorRouteList = " "
interfaceCheck()
m5 = Map("mwan3", translate("MWAN Interface Configuration"),
translate(interfaceWarnings()))
m5:append(Template("mwan/config_css"))
mwan_interface = m5:section(TypedSection, "interface", translate("Interfaces"),
translate("MWAN supports up to 250 physical and/or logical interfaces<br />" ..
"MWAN requires that all interfaces have a unique metric configured in /etc/config/network<br />" ..
"Names must match the interface name found in /etc/config/network (see advanced tab)<br />" ..
"Names may contain characters A-Z, a-z, 0-9, _ and no spaces<br />" ..
"Interfaces may not share the same name as configured members, policies or rules"))
mwan_interface.addremove = true
mwan_interface.dynamic = false
mwan_interface.sectionhead = "Interface"
mwan_interface.sortable = true
mwan_interface.template = "cbi/tblsection"
mwan_interface.extedit = dsp.build_url("admin", "network", "mwan", "configuration", "interface", "%s")
function mwan_interface.create(self, section)
TypedSection.create(self, section)
m5.uci:save("mwan3")
luci.http.redirect(dsp.build_url("admin", "network", "mwan", "configuration", "interface", section))
end
enabled = mwan_interface:option(DummyValue, "enabled", translate("Enabled"))
enabled.rawhtml = true
function enabled.cfgvalue(self, s)
if self.map:get(s, "enabled") == "1" then
return "Yes"
else
return "No"
end
end
track_ip = mwan_interface:option(DummyValue, "track_ip", translate("Tracking IP"))
track_ip.rawhtml = true
function track_ip.cfgvalue(self, s)
tracked = self.map:get(s, "track_ip")
if tracked then
local ipList = ""
for k,v in pairs(tracked) do
ipList = ipList .. v .. "<br />"
end
return ipList
else
return "&#8212;"
end
end
reliability = mwan_interface:option(DummyValue, "reliability", translate("Tracking reliability"))
reliability.rawhtml = true
function reliability.cfgvalue(self, s)
if tracked then
return self.map:get(s, "reliability") or "&#8212;"
else
return "&#8212;"
end
end
count = mwan_interface:option(DummyValue, "count", translate("Ping count"))
count.rawhtml = true
function count.cfgvalue(self, s)
if tracked then
return self.map:get(s, "count") or "&#8212;"
else
return "&#8212;"
end
end
timeout = mwan_interface:option(DummyValue, "timeout", translate("Ping timeout"))
timeout.rawhtml = true
function timeout.cfgvalue(self, s)
if tracked then
local timeoutValue = self.map:get(s, "timeout")
if timeoutValue then
return timeoutValue .. "s"
else
return "&#8212;"
end
else
return "&#8212;"
end
end
interval = mwan_interface:option(DummyValue, "interval", translate("Ping interval"))
interval.rawhtml = true
function interval.cfgvalue(self, s)
if tracked then
local intervalValue = self.map:get(s, "interval")
if intervalValue then
return intervalValue .. "s"
else
return "&#8212;"
end
else
return "&#8212;"
end
end
down = mwan_interface:option(DummyValue, "down", translate("Interface down"))
down.rawhtml = true
function down.cfgvalue(self, s)
if tracked then
return self.map:get(s, "down") or "&#8212;"
else
return "&#8212;"
end
end
up = mwan_interface:option(DummyValue, "up", translate("Interface up"))
up.rawhtml = true
function up.cfgvalue(self, s)
if tracked then
return self.map:get(s, "up") or "&#8212;"
else
return "&#8212;"
end
end
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")
if metricValue ~= "" then
return metricValue
else
return "&#8212;"
end
end
errors = mwan_interface:option(DummyValue, "errors", translate("Errors"))
errors.rawhtml = true
function errors.cfgvalue(self, s)
if errorFound == 1 then
local mouseOver, lineBreak = "", ""
if string.find(errorReliabilityList, " " .. s .. " ") then
mouseOver = "Higher reliability requirement than there are tracking IP addresses"
lineBreak = "&#10;&#10;"
end
if string.find(errorRouteList, " " .. s .. " ") then
mouseOver = mouseOver .. lineBreak .. "No default route in the main routing table"
lineBreak = "&#10;&#10;"
end
if string.find(errorNetConfigList, " " .. s .. " ") then
mouseOver = mouseOver .. lineBreak .. "Configured incorrectly or not at all in /etc/config/network"
lineBreak = "&#10;&#10;"
end
if string.find(errorNoMetricList, " " .. s .. " ") then
mouseOver = mouseOver .. lineBreak .. "No metric configured in /etc/config/network"
lineBreak = "&#10;&#10;"
end
if string.find(errorDuplicateMetricList, " " .. s .. " ") then
mouseOver = mouseOver .. lineBreak .. "Duplicate metric configured in /etc/config/network"
end
if mouseOver == "" then
return ""
else
return "<span title=\"" .. mouseOver .. "\"><img src=\"/luci-static/resources/cbi/reset.gif\" alt=\"error\"></img></span>"
end
else
return ""
end
end
return m5

net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan3/mwan3_interfaceconfig.lua → net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan/interfaceconfig.lua View File


net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan3/mwan3_member.lua → net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan/member.lua View File


net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan3/mwan3_memberconfig.lua → net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan/memberconfig.lua View File


net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan3/mwan3_policy.lua → net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan/policy.lua View File


net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan3/mwan3_policyconfig.lua → net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan/policyconfig.lua View File


net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan3/mwan3_rule.lua → net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan/rule.lua View File


net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan3/mwan3_ruleconfig.lua → net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan/ruleconfig.lua View File


+ 0
- 266
net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan3/mwan3_interface.lua View File

@ -1,266 +0,0 @@
-- ------ extra functions ------ --
function iface_check() -- find issues with too many interfaces, reliability and metric
uci.cursor():foreach("mwan3", "interface",
function (section)
local ifname = section[".name"]
ifnum = ifnum+1 -- count number of mwan3 interfaces configured
-- create list of metrics for none and duplicate checking
local metlkp = ut.trim(sys.exec("uci get -p /var/state network." .. ifname .. ".metric"))
if metlkp == "" then
err_found = 1
err_nomet_list = err_nomet_list .. ifname .. " "
else
metric_list = metric_list .. ifname .. " " .. metlkp .. "\n"
end
-- check if any interfaces have a higher reliability requirement than tracking IPs configured
local tipnum = tonumber(ut.trim(sys.exec("echo $(uci get -p /var/state mwan3." .. ifname .. ".track_ip) | wc -w")))
if tipnum > 0 then
local relnum = tonumber(ut.trim(sys.exec("uci get -p /var/state mwan3." .. ifname .. ".reliability")))
if relnum and relnum > tipnum then
err_found = 1
err_rel_list = err_rel_list .. ifname .. " "
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." .. ifname)) == "interface" then
local ifdev = ut.trim(sys.exec("uci get -p /var/state network." .. ifname .. ".ifname"))
if ifdev == "uci: Entry not found" or ifdev == "" then
err_found = 1
err_netcfg_list = err_netcfg_list .. ifname .. " "
err_route_list = err_route_list .. ifname .. " "
else
local rtcheck = ut.trim(sys.exec("route -n | awk '{ if ($8 == \"" .. ifdev .. "\" && $1 == \"0.0.0.0\" && $3 == \"0.0.0.0\") print $1 }'"))
if rtcheck == "" then
err_found = 1
err_route_list = err_route_list .. ifname .. " "
end
end
else
err_found = 1
err_netcfg_list = err_netcfg_list .. ifname .. " "
err_route_list = err_route_list .. ifname .. " "
end
end
)
-- check if any interfaces have duplicate metrics
local metric_dupnums = sys.exec("echo '" .. metric_list .. "' | awk '{ print $2 }' | uniq -d")
if metric_dupnums ~= "" then
err_found = 1
local metric_dupes = ""
for line in metric_dupnums:gmatch("[^\r\n]+") do
metric_dupes = sys.exec("echo '" .. metric_list .. "' | grep '" .. line .. "' | awk '{ print $1 }'")
err_dupmet_list = err_dupmet_list .. metric_dupes
end
err_dupmet_list = sys.exec("echo '" .. err_dupmet_list .. "' | tr '\n' ' '")
end
end
function iface_warn() -- display status and warning messages at the top of the page
local warns = ""
if ifnum <= 250 then
warns = "<strong>There are currently " .. ifnum .. " of 250 supported interfaces configured</strong>"
else
warns = "<font color=\"ff0000\"><strong>WARNING: " .. ifnum .. " interfaces are configured exceeding the maximum of 250!</strong></font>"
end
if err_rel_list ~= " " then
warns = warns .. "<br /><br /><font color=\"ff0000\"><strong>WARNING: some interfaces have a higher reliability requirement than there are tracking IP addresses!</strong></font>"
end
if err_route_list ~= " " then
warns = warns .. "<br /><br /><font color=\"ff0000\"><strong>WARNING: some interfaces have no default route in the main routing table!</strong></font>"
end
if err_netcfg_list ~= " " then
warns = warns .. "<br /><br /><font color=\"ff0000\"><strong>WARNING: some interfaces are configured incorrectly or not at all in /etc/config/network!</strong></font>"
end
if err_nomet_list ~= " " then
warns = warns .. "<br /><br /><font color=\"ff0000\"><strong>WARNING: some interfaces have no metric configured in /etc/config/network!</strong></font>"
end
if err_dupmet_list ~= " " then
warns = warns .. "<br /><br /><font color=\"ff0000\"><strong>WARNING: some interfaces have duplicate metrics configured in /etc/config/network!</strong></font>"
end
return warns
end
-- ------ interface configuration ------ --
dsp = require "luci.dispatcher"
sys = require "luci.sys"
ut = require "luci.util"
ifnum = 0
metric_list = ""
err_found = 0
err_dupmet_list = " "
err_netcfg_list = " "
err_nomet_list = " "
err_rel_list = " "
err_route_list = " "
iface_check()
m5 = Map("mwan3", translate("MWAN3 Multi-WAN Interface Configuration"),
translate(iface_warn()))
m5:append(Template("mwan3/mwan3_config_css"))
mwan_interface = m5:section(TypedSection, "interface", translate("Interfaces"),
translate("MWAN3 supports up to 250 physical and/or logical interfaces<br />" ..
"MWAN3 requires that all interfaces have a unique metric configured in /etc/config/network<br />" ..
"Names must match the interface name found in /etc/config/network (see advanced tab)<br />" ..
"Names may contain characters A-Z, a-z, 0-9, _ and no spaces<br />" ..
"Interfaces may not share the same name as configured members, policies or rules"))
mwan_interface.addremove = true
mwan_interface.dynamic = false
mwan_interface.sectionhead = "Interface"
mwan_interface.sortable = true
mwan_interface.template = "cbi/tblsection"
mwan_interface.extedit = dsp.build_url("admin", "network", "mwan3", "configuration", "interface", "%s")
function mwan_interface.create(self, section)
TypedSection.create(self, section)
m5.uci:save("mwan3")
luci.http.redirect(dsp.build_url("admin", "network", "mwan3", "configuration", "interface", section))
end
enabled = mwan_interface:option(DummyValue, "enabled", translate("Enabled"))
enabled.rawhtml = true
function enabled.cfgvalue(self, s)
if self.map:get(s, "enabled") == "1" then
return "Yes"
else
return "No"
end
end
track_ip = mwan_interface:option(DummyValue, "track_ip", translate("Tracking IP"))
track_ip.rawhtml = true
function track_ip.cfgvalue(self, s)
local str = ""
tracked = self.map:get(s, "track_ip")
if tracked then
for k,v in pairs(tracked) do
str = str .. v .. "<br />"
end
return str
else
return "&#8212;"
end
end
reliability = mwan_interface:option(DummyValue, "reliability", translate("Tracking reliability"))
reliability.rawhtml = true
function reliability.cfgvalue(self, s)
if tracked then
return self.map:get(s, "reliability") or "&#8212;"
else
return "&#8212;"
end
end
count = mwan_interface:option(DummyValue, "count", translate("Ping count"))
count.rawhtml = true
function count.cfgvalue(self, s)
if tracked then
return self.map:get(s, "count") or "&#8212;"
else
return "&#8212;"
end
end
timeout = mwan_interface:option(DummyValue, "timeout", translate("Ping timeout"))
timeout.rawhtml = true
function timeout.cfgvalue(self, s)
if tracked then
local tcheck = self.map:get(s, "timeout")
if tcheck then
return tcheck .. "s"
else
return "&#8212;"
end
else
return "&#8212;"
end
end
interval = mwan_interface:option(DummyValue, "interval", translate("Ping interval"))
interval.rawhtml = true
function interval.cfgvalue(self, s)
if tracked then
local icheck = self.map:get(s, "interval")
if icheck then
return icheck .. "s"
else
return "&#8212;"
end
else
return "&#8212;"
end
end
down = mwan_interface:option(DummyValue, "down", translate("Interface down"))
down.rawhtml = true
function down.cfgvalue(self, s)
if tracked then
return self.map:get(s, "down") or "&#8212;"
else
return "&#8212;"
end
end
up = mwan_interface:option(DummyValue, "up", translate("Interface up"))
up.rawhtml = true
function up.cfgvalue(self, s)
if tracked then
return self.map:get(s, "up") or "&#8212;"
else
return "&#8212;"
end
end
metric = mwan_interface:option(DummyValue, "metric", translate("Metric"))
metric.rawhtml = true
function metric.cfgvalue(self, s)
local metcheck = sys.exec("uci get -p /var/state network." .. s .. ".metric")
if metcheck ~= "" then
return metcheck
else
return "&#8212;"
end
end
errors = mwan_interface:option(DummyValue, "errors", translate("Errors"))
errors.rawhtml = true
function errors.cfgvalue(self, s)
if err_found == 1 then
local mouseover, linebrk = "", ""
if string.find(err_rel_list, " " .. s .. " ") then
mouseover = "Higher reliability requirement than there are tracking IP addresses"
linebrk = "&#10;&#10;"
end
if string.find(err_route_list, " " .. s .. " ") then
mouseover = mouseover .. linebrk .. "No default route in the main routing table"
linebrk = "&#10;&#10;"
end
if string.find(err_netcfg_list, " " .. s .. " ") then
mouseover = mouseover .. linebrk .. "Configured incorrectly or not at all in /etc/config/network"
linebrk = "&#10;&#10;"
end
if string.find(err_nomet_list, " " .. s .. " ") then
mouseover = mouseover .. linebrk .. "No metric configured in /etc/config/network"
linebrk = "&#10;&#10;"
end
if string.find(err_dupmet_list, " " .. s .. " ") then
mouseover = mouseover .. linebrk .. "Duplicate metric configured in /etc/config/network"
end
if mouseover == "" then
return ""
else
return "<span title=\"" .. mouseover .. "\"><img src=\"/luci-static/resources/cbi/reset.gif\" alt=\"error\"></img></span>"
end
else
return ""
end
end
return m5

+ 1
- 0
net/mwan3-luci/files/usr/lib/lua/luci/view/admin_status/index/mwan.htm View File

@ -0,0 +1 @@
<%+mwan/openwrt_overview_status%>

+ 0
- 1
net/mwan3-luci/files/usr/lib/lua/luci/view/admin_status/index/mwan3.htm View File

@ -1 +0,0 @@
<%+mwan3/mwan3_status%>

net/mwan3-luci/files/usr/lib/lua/luci/view/mwan3/mwan3_adv_diagnostics.htm → net/mwan3-luci/files/usr/lib/lua/luci/view/mwan/advanced_diagnostics.htm View File


net/mwan3-luci/files/usr/lib/lua/luci/view/mwan3/mwan3_adv_network.htm → net/mwan3-luci/files/usr/lib/lua/luci/view/mwan/advanced_hotplugscript.htm View File


net/mwan3-luci/files/usr/lib/lua/luci/view/mwan3/mwan3_adv_mwan3.htm → net/mwan3-luci/files/usr/lib/lua/luci/view/mwan/advanced_mwanconfig.htm View File


net/mwan3-luci/files/usr/lib/lua/luci/view/mwan3/mwan3_adv_hotplug.htm → net/mwan3-luci/files/usr/lib/lua/luci/view/mwan/advanced_networkconfig.htm View File


+ 71
- 0
net/mwan3-luci/files/usr/lib/lua/luci/view/mwan/advanced_troubleshooting.htm View File

@ -0,0 +1,71 @@
<%+header%>
<ul class="cbi-tabmenu">
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan/advanced/hotplugscript")%>"><%:Hotplug Script%></a></li>
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan/advanced/mwanconfig")%>"><%:MWAN Config%></a></li>
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan/advanced/networkconfig")%>"><%:Network Config%></a></li>
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan/advanced/diagnostics")%>"><%:Diagnostics%></a></li>
<li class="cbi-tab"><a href="<%=luci.dispatcher.build_url("admin/network/mwan/advanced/troubleshooting")%>"><%:Troubleshooting%></a></li>
</ul>
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<script type="text/javascript">//<![CDATA[
XHR.poll(15, '<%=luci.dispatcher.build_url("admin", "network", "mwan", "advanced", "troubleshooting_display")%>', null,
function(x, mArray)
{
var tshoot = document.getElementById('troubleshoot_text');
if (mArray.versions)
{
var versions = '<span class="description">Software versions : </span><br /><br />';
var mwanConfig = '<br /><br /><span class="description">Output of &#34;cat /etc/config/mwan3&#34; : </span><br /><br />';
var netConfig = '<br /><br /><span class="description">Output of &#34;cat /etc/config/network&#34; : </span><br /><br />';
var ifconfig = '<br /><br /><span class="description">Output of &#34;ifconfig&#34; : </span><br /><br />';
var ipRoute = '<br /><br /><span class="description">Output of &#34;route -n&#34; : </span><br /><br />';
var ipRuleShow = '<br /><br /><span class="description">Output of &#34;ip rule show&#34; : </span><br /><br />';
var routeListTable = '<br /><br /><span class="description">Output of &#34;ip route list table 1-250&#34; : </span><br /><br />';
var firewallOut = '<br /><br /><span class="description">Firewall default output policy (must be ACCEPT) : </span><br /><br />';
var iptables = '<br /><br /><span class="description">Output of &#34;iptables -L -t mangle -v -n&#34; : </span><br /><br />';
tshoot.innerHTML = String.format(
'<pre>%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s</pre>',
versions, mArray.versions[0], mwanConfig, mArray.mwanconfig[0], netConfig, mArray.netconfig[0],
ifconfig, mArray.ifconfig[0], ipRoute, mArray.routeshow[0], ipRuleShow, mArray.iprule[0],
routeListTable, mArray.routelist[0], firewallOut, mArray.firewallout[0], iptables, mArray.iptables[0]
);
}
else
{
tshoot.innerHTML = '<strong>Error collecting troubleshooting information</strong>';
}
}
);
//]]></script>
<div id="troubleshoot">
<fieldset class="cbi-section">
<legend><%:Troubleshooting Data%></legend>
<div id="troubleshoot_text"><img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> Collecting data...</div>
</fieldset>
</div>
<style type="text/css">
.container { /* container for entire page. fixes bootstrap theme's ridiculously small page width */
max-width: none;
margin-left: 30px;
padding-right: 30px;
width: auto;
}
#troubleshoot {
background-color: #FFFFFF;
border: 1px dotted #555555;
padding: 20px;
}
#troubleshoot_text {
padding: 20px;
text-align: left;
}
.description {
background-color: rgb(78, 186, 241);
}
</style>
<%+footer%>

net/mwan3-luci/files/usr/lib/lua/luci/view/mwan3/mwan3_config_css.htm → net/mwan3-luci/files/usr/lib/lua/luci/view/mwan/config_css.htm View File


net/mwan3-luci/files/usr/lib/lua/luci/view/mwan3/mwan3_status.htm → net/mwan3-luci/files/usr/lib/lua/luci/view/mwan/openwrt_overview_status.htm View File


+ 51
- 0
net/mwan3-luci/files/usr/lib/lua/luci/view/mwan/overview_detailed.htm View File

@ -0,0 +1,51 @@
<%+header%>
<ul class="cbi-tabmenu">
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan/overview")%>"><%:Interface Status%></a></li>
<li class="cbi-tab"><a href="<%=luci.dispatcher.build_url("admin/network/mwan/overview/overview_detailed")%>"><%:Detailed Status%></a></li>
</ul>
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<script type="text/javascript">//<![CDATA[
XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "mwan", "overview", "detailed_status")%>', null,
function(x, mArray)
{
var status = document.getElementById('mwan_detail_text');
if (mArray.mwandetail)
{
status.innerHTML = String.format('<pre>%s</pre>', mArray.mwandetail[0]);
}
else
{
status.innerHTML = '<strong>No detailed status information available</strong>';
}
}
);
//]]></script>
<div id="mwan_detail_status">
<fieldset class="cbi-section">
<legend><%:MWAN Detailed Status%></legend>
<div id="mwan_detail_text"><img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> Collecting data...</div>
</fieldset>
</div>
<style type="text/css">
.container { /* container for entire page. fixes bootstrap theme's ridiculously small page width */
max-width: none;
margin-left: 30px;
padding-right: 30px;
width: auto;
}
#mwan_detail_status {
border: 1px dotted #555555;
background-color: #FFFFFF;
padding: 20px;
}
#mwan_detail_text {
padding: 20px;
text-align: left;
}
</style>
<%+footer%>

+ 122
- 0
net/mwan3-luci/files/usr/lib/lua/luci/view/mwan/overview_interface.htm View File

@ -0,0 +1,122 @@
<%+header%>
<ul class="cbi-tabmenu">
<li class="cbi-tab"><a href="<%=luci.dispatcher.build_url("admin/network/mwan/overview")%>"><%:Interface Status%></a></li>
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan/overview/overview_detailed")%>"><%:Detailed Status%></a></li>
</ul>
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<script type="text/javascript">//<![CDATA[
XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "mwan", "overview", "interface_status")%>', null,
function(x, mArray)
{
var statusDiv = document.getElementById('mwan_status_text');
if (mArray.wans)
{
var interfaceStatus = '';
for( var i = 0; i < mArray.wans.length; i++ )
{
var status = '';
var css = '';
switch (mArray.wans[i].status)
{
case 'online':
status = 'Online (tracking active)';
css = 'wanon';
break;
case 'notMonitored':
status = 'Online (tracking off)';
css = 'wanon';
break;
case 'offline':
status = 'Offline';
css = 'wanoff';
break;
case 'notEnabled':
status = 'Disabled';
css = 'wanoff';
break;
}
interfaceStatus += String.format(
'<span class="%s"><strong>%s (<a href="%q">%s</a>)</strong><br />%s</span>',
css, mArray.wans[i].name, mArray.wans[i].link, mArray.wans[i].ifname, status
);
}
statusDiv.innerHTML = interfaceStatus;
}
else
{
statusDiv.innerHTML = '<strong>No MWAN interfaces found</strong>';
}
var logs = document.getElementById('mwan_statuslog_text');
if (mArray.mwanlog)
{
var mwanLog = 'Last 50 MWAN systemlog entries. Newest entries sorted at the top :';
logs.innerHTML = String.format('<pre>%s<br /><br />%s</pre>', mwanLog, mArray.mwanlog[0]);
}
else
{
logs.innerHTML = '<strong>No MWAN systemlog history found</strong>';
}
}
);
//]]></script>
<div id="mwan_interface_status">
<fieldset id="interface_field" class="cbi-section">
<legend><%:MWAN Interface Live Status%></legend>
<div id="mwan_status_text"><img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> Collecting data...</div>
</fieldset>
<fieldset class="cbi-section">
<legend><%:MWAN Interface Systemlog%></legend>
<div id="mwan_statuslog_text"><img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> Collecting data...</div>
</fieldset>
</div>
<style type="text/css">
.container { /* container for entire page. fixes bootstrap theme's ridiculously small page width */
max-width: none;
margin-left: 30px;
padding-right: 30px;
width: auto;
}
#mwan_interface_status {
background-color: #FFFFFF;
border: 1px dotted #555555;
padding: 20px;
}
#interface_field {
padding: 12px 20px 20px 20px;
}
#mwan_status_text {
display: table;
font-size: 14px;
margin: auto;
max-width: 1044px;
min-width: 246px;
width: 100%;
}
.wanon {
background-color: rgb(144, 240, 144);
}
.wanoff {
background-color: rgb(240, 144, 144);
}
.wanon, .wanoff {
border-radius: 60px;
box-shadow: 0px 2px 5px -3px;
float: left;
margin: 8px 3px 0px 3px;
min-height: 30px;
min-width: 235px;
padding: 5px 10px 8px 10px;
text-align: center;
}
#mwan_statuslog_text {
padding: 20px;
text-align: left;
}
</style>
<%+footer%>

+ 0
- 75
net/mwan3-luci/files/usr/lib/lua/luci/view/mwan3/mwan3_adv_troubleshoot.htm View File

@ -1,75 +0,0 @@
<%+header%>
<ul class="cbi-tabmenu">
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/advanced/hotplug")%>"><%:Hotplug Script%></a></li>
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/advanced/mwan3")%>"><%:MWAN3 Config%></a></li>
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/advanced/network")%>"><%:Network Config%></a></li>
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/advanced/diag")%>"><%:Diagnostics%></a></li>
<li class="cbi-tab"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/advanced/tshoot")%>"><%:Troubleshooting%></a></li>
</ul>
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<script type="text/javascript">//<![CDATA[
XHR.poll(15, '<%=luci.dispatcher.build_url("admin", "network", "mwan3", "advanced", "tshoot_display")%>', null,
function(x, st)
{
var tx = document.getElementById('mwan3_tshoot_text');
if (st.mw3ver)
{
var temp = '';
var mwanvers = 'Software versions : <br /><br />';
var mwan3cnfg = '<br /><br />Output of &#34;cat /etc/config/mwan3&#34; : <br /><br />';
var netcnfg = '<br /><br />Output of &#34;cat /etc/config/network&#34; : <br /><br />';
var ifcnfg = '<br /><br />Output of &#34;ifconfig&#34; : <br /><br />';
var iproute = '<br /><br />Output of &#34;route -n&#34; : <br /><br />';
var iprulesh = '<br /><br />Output of &#34;ip rule show&#34; : <br /><br />';
var routelisttbl = '<br /><br />Output of &#34;ip route list table 1-250&#34; : <br /><br />';
var firewalldef = '<br /><br />Firewall default output policy (must be ACCEPT) : <br /><br />';
var iptable = '<br /><br />Output of &#34;iptables -L -t mangle -v -n&#34; : <br /><br />';
temp = String.format(
'<pre><span class="tsht">%s</span>%s<span class="tsht">%s</span>%s<span class="tsht">%s</span>%s<span class="tsht">%s</span>%s<span class="tsht">%s</span>%s<span class="tsht">%s</span>%s<span class="tsht">%s</span>%s<span class="tsht">%s</span>%s<span class="tsht">%s</span>%s</pre>',
mwanvers, st.mw3ver[0].mwan3v, mwan3cnfg, st.mwan3config[0].mwn3cfg, netcnfg, st.netconfig[0].netcfg, ifcnfg, st.ifconfig[0].ifcfg, iproute, st.rtshow[0].iprtshow, iprulesh, st.iprule[0].rule, routelisttbl, st.routelist[0].iprtlist, firewalldef, st.fidef[0].firedef, iptable, st.iptables[0].iptbls
);
tx.innerHTML = temp;
}
else
{
var temp = '';
var terror = 'Error collecting troubleshooting information';
temp = String.format('<strong>%s</strong>', terror);
tx.innerHTML = temp;
}
}
);
//]]></script>
<div id="tshoot_div">
<fieldset class="cbi-section">
<legend><%:Troubleshooting Data%></legend>
<div id="mwan3_tshoot_text"><img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> Collecting data...</div>
</fieldset>
</div>
<style type="text/css">
.container { /*container for entire page. fixes bootstrap theme's ridiculously small page width*/
max-width: none;
margin-left: 30px;
padding-right: 30px;
width: auto;
}
#tshoot_div {
background-color: #FFFFFF;
border: 1px dotted #555555;
padding: 20px;
}
#mwan3_tshoot_text {
padding: 20px;
text-align: left;
}
.tsht {
background-color: rgb(78, 186, 241);
}
</style>
<%+footer%>

+ 0
- 56
net/mwan3-luci/files/usr/lib/lua/luci/view/mwan3/mwan3_over_detail.htm View File

@ -1,56 +0,0 @@
<%+header%>
<ul class="cbi-tabmenu">
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/overview")%>"><%:Interface Status%></a></li>
<li class="cbi-tab"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/overview/over_detail")%>"><%:Detailed Status%></a></li>
</ul>
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<script type="text/javascript">//<![CDATA[
XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "mwan3", "overview", "detail_status")%>', null,
function(x, st)
{
var tx = document.getElementById('mwan3_detail_text');
if (st.mwan3dst)
{
var temp = '';
temp = String.format('<pre>%s</pre>', st.mwan3dst[0].detailstat);
tx.innerHTML = temp;
}
else
{
var temp = '';
var nslg = 'No detailed status information available';
temp = String.format('<strong>%s</strong>', nslg);
tx.innerHTML = temp;
}
}
);
//]]></script>
<div id="mwan3_detail_status">
<fieldset class="cbi-section">
<legend><%:MWAN3 Multi-WAN Detailed Status%></legend>
<div id="mwan3_detail_text"><img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> Collecting data...</div>
</fieldset>
</div>
<style type="text/css">
.container { /*container for entire page. fixes bootstrap theme's ridiculously small page width*/
max-width: none;
margin-left: 30px;
padding-right: 30px;
width: auto;
}
#mwan3_detail_status {
border: 1px dotted #555555;
background-color: #FFFFFF;
padding: 20px;
}
#mwan3_detail_text {
padding: 20px;
text-align: left;
}
</style>
<%+footer%>

+ 0
- 136
net/mwan3-luci/files/usr/lib/lua/luci/view/mwan3/mwan3_over_interface.htm View File

@ -1,136 +0,0 @@
<%+header%>
<ul class="cbi-tabmenu">
<li class="cbi-tab"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/overview")%>"><%:Interface Status%></a></li>
<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan3/overview/over_detail")%>"><%:Detailed Status%></a></li>
</ul>
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<script type="text/javascript">//<![CDATA[
XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "mwan3", "overview", "iface_status")%>', null,
function(x, st)
{
var tx = document.getElementById('mwan3_status_text');
if (st.wans)
{
var temp = '';
for( var i = 0; i < st.wans.length; i++ )
{
var stat = '';
var cssc = '';
switch (st.wans[i].status)
{
case 'on':
stat = 'Online (tracking active)';
cssc = 'wanon';
break;
case 'nm':
stat = 'Online (tracking off)';
cssc = 'wanon';
break;
case 'off':
stat = 'Offline';
cssc = 'wanoff';
break;
case 'ne':
stat = 'Disabled';
cssc = 'wanoff';
break;
}
temp += String.format(
'<span class="%s"><strong>%s (<a href="%q">%s</a>)</strong><br />%s</span>',
cssc, st.wans[i].name, st.wans[i].link, st.wans[i].ifname, stat
);
}
tx.innerHTML = temp;
}
else
{
var temp = '';
var ncint = 'No MWAN3 interfaces found';
temp = String.format('<strong>%s</strong>', ncint);
tx.innerHTML = temp;
}
var tx = document.getElementById('mwan3_statuslog_text');
if (st.mwan3log)
{
var temp = '';
var mwan3lg = 'Last 50 MWAN3 systemlog entries. Newest entries sorted at the top :';
temp = String.format('<pre>%s<br /><br />%s</pre>', mwan3lg, st.mwan3log[0].mwanlog);
tx.innerHTML = temp;
}
else
{
var temp = '';
var nslg = 'No MWAN3 systemlog history found';
temp = String.format('<strong>%s</strong>', nslg);
tx.innerHTML = temp;
}
}
);
//]]></script>
<div id="mwan3_interface_status">
<fieldset id="interface_field" class="cbi-section">
<legend><%:MWAN3 Multi-WAN Interface Live Status%></legend>
<div id="mwan3_status_text"><img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> Collecting data...</div>
</fieldset>
<fieldset class="cbi-section">
<legend><%:MWAN3 Multi-WAN Interface Systemlog%></legend>
<div id="mwan3_statuslog_text"><img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> Collecting data...</div>
</fieldset>
</div>
<style type="text/css">
.container { /*container for entire page. fixes bootstrap theme's ridiculously small page width*/
max-width: none;
margin-left: 30px;
padding-right: 30px;
width: auto;
}
#mwan3_interface_status {
background-color: #FFFFFF;
border: 1px dotted #555555;
padding: 20px;
}
#interface_field {
padding: 12px 20px 20px 20px;
}
#mwan3_status_text {
display: table;
font-size: 14px;
margin: auto;
max-width: 1044px;
min-width: 246px;
width: 100%;
}
.wanon {
background-color: rgb(144, 240, 144);
}
.wanoff {
background-color: rgb(240, 144, 144);
}
.wanon, .wanoff {
border-radius: 60px;
box-shadow: 0px 2px 5px -3px;
float: left;
margin: 8px 3px 0px 3px;
min-height: 30px;
min-width: 235px;
padding: 5px 10px 8px 10px;
text-align: center;
}
#mwan3_statuslog_text {
padding: 20px;
text-align: left;
}
</style>
<%+footer%>

Loading…
Cancel
Save