diff options
Diffstat (limited to 'applications/luci-app-mwan3/luasrc')
8 files changed, 116 insertions, 56 deletions
diff --git a/applications/luci-app-mwan3/luasrc/controller/mwan3.lua b/applications/luci-app-mwan3/luasrc/controller/mwan3.lua index 3d5a23dd03..d3fd150692 100644 --- a/applications/luci-app-mwan3/luasrc/controller/mwan3.lua +++ b/applications/luci-app-mwan3/luasrc/controller/mwan3.lua @@ -64,9 +64,9 @@ function index() end 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 -q -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 -p /var/state get mwan3." .. interfaceName .. ".track_ip")) ~= "" then + if ut.trim(sys.exec("uci -q -p /var/state get mwan3." .. interfaceName .. ".track_ip")) ~= "" then return "online" else return "notMonitored" @@ -102,7 +102,7 @@ function interfaceStatus() wansid = {} for wanName, interfaceState in string.gfind(statusString, "([^%[]+)%[([^%]]+)%]") do - local wanInterfaceName = ut.trim(sys.exec("uci -p /var/state get network." .. wanName .. ".ifname")) + local wanInterfaceName = ut.trim(sys.exec("uci -q -p /var/state get network." .. wanName .. ".ifname")) if wanInterfaceName == "" then wanInterfaceName = "X" end @@ -115,7 +115,7 @@ function interfaceStatus() end -- overview status log - local mwanLog = ut.trim(sys.exec("logread | grep mwan3 | tail -n 50 | sed 'x;1!H;$!d;x'")) + local mwanLog = ut.trim(sys.exec("logread | grep mwan3 | tail -n 50 | sed 'x;1!H;$!d;x' 2>/dev/null")) if mwanLog ~= "" then mArray.mwanlog = { mwanLog } end @@ -163,7 +163,7 @@ function diagnosticsData(interface, tool, task) results = "MWAN3 started" end else - local interfaceDevice = ut.trim(sys.exec("uci -p /var/state get network." .. interface .. ".ifname")) + local interfaceDevice = ut.trim(sys.exec("uci -q -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}'")) @@ -172,7 +172,7 @@ function diagnosticsData(interface, tool, task) 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 -p /var/state get mwan3." .. interface .. ".track_ip")) + local tracked = ut.trim(sys.exec("uci -q -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 @@ -301,7 +301,7 @@ function troubleshootingData() mArray.iprule = { ipRuleShow } -- 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' 2>/dev/null | 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) @@ -313,7 +313,7 @@ function troubleshootingData() mArray.routelist = { routeString } -- default firewall output policy - local firewallOut = ut.trim(sys.exec("uci -p /var/state get firewall.@defaults[0].output")) + local firewallOut = ut.trim(sys.exec("uci -q -p /var/state get firewall.@defaults[0].output")) if firewallOut == "" then firewallOut = "No data found" end diff --git a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/interface.lua b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/interface.lua index a8e68a01be..7e863a371f 100644 --- a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/interface.lua +++ b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/interface.lua @@ -59,24 +59,24 @@ 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>" + warnings = "<strong>" .. translatef("There are currently %d of 250 supported interfaces configured", interfaceNumber) .. "</strong>" else - warnings = "<font color=\"ff0000\"><strong>WARNING: " .. interfaceNumber .. " interfaces are configured exceeding the maximum of 250!</strong></font>" + warnings = "<font color=\"ff0000\"><strong>" .. translatef("WARNING: %d interfaces are configured exceeding the maximum of 250!", interfaceNumber) .. "</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>" + warnings = warnings .. "<br /><br /><font color=\"ff0000\"><strong>" .. translate("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>" + warnings = warnings .. "<br /><br /><font color=\"ff0000\"><strong>" .. translate("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>" + warnings = warnings .. "<br /><br /><font color=\"ff0000\"><strong>" .. translate("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>" + warnings = warnings .. "<br /><br /><font color=\"ff0000\"><strong>" .. translate("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>" + warnings = warnings .. "<br /><br /><font color=\"ff0000\"><strong>" .. translate("WARNING: some interfaces have duplicate metrics configured in /etc/config/network!") .. "</strong></font>" end return warnings end @@ -99,7 +99,7 @@ interfaceCheck() m5 = Map("mwan3", translate("MWAN Interface Configuration"), - translate(interfaceWarnings())) + interfaceWarnings()) m5:append(Template("mwan/config_css")) diff --git a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/interfaceconfig.lua b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/interfaceconfig.lua index 387ff01a8d..e7c16fdfdc 100644 --- a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/interfaceconfig.lua +++ b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/interfaceconfig.lua @@ -50,21 +50,21 @@ end function interfaceWarnings() -- display warning messages at the top of the page local warns, lineBreak = "", "" if errorReliability == 1 then - warns = "<font color=\"ff0000\"><strong>WARNING: this interface has a higher reliability requirement than there are tracking IP addresses!</strong></font>" + warns = "<font color=\"ff0000\"><strong>" .. translate("WARNING: this interface has a higher reliability requirement than there are tracking IP addresses!") .. "</strong></font>" lineBreak = "<br /><br />" end if errorRoute == 1 then - warns = warns .. lineBreak .. "<font color=\"ff0000\"><strong>WARNING: this interface has no default route in the main routing table!</strong></font>" + warns = warns .. lineBreak .. "<font color=\"ff0000\"><strong>" .. translate("WARNING: this interface has no default route in the main routing table!") .. "</strong></font>" lineBreak = "<br /><br />" end if errorNetConfig == 1 then - warns = warns .. lineBreak .. "<font color=\"ff0000\"><strong>WARNING: this interface is configured incorrectly or not at all in /etc/config/network!</strong></font>" + warns = warns .. lineBreak .. "<font color=\"ff0000\"><strong>" .. translate("WARNING: this interface is configured incorrectly or not at all in /etc/config/network!") .. "</strong></font>" lineBreak = "<br /><br />" end if errorNoMetric == 1 then - warns = warns .. lineBreak .. "<font color=\"ff0000\"><strong>WARNING: this interface has no metric configured in /etc/config/network!</strong></font>" + warns = warns .. lineBreak .. "<font color=\"ff0000\"><strong>" .. translate("WARNING: this interface has no metric configured in /etc/config/network!") .. "</strong></font>" elseif errorDuplicateMetric == 1 then - warns = warns .. lineBreak .. "<font color=\"ff0000\"><strong>WARNING: this and other interfaces have duplicate metrics configured in /etc/config/network!</strong></font>" + warns = warns .. lineBreak .. "<font color=\"ff0000\"><strong>" .. translate("WARNING: this and other interfaces have duplicate metrics configured in /etc/config/network!") .. "</strong></font>" end return warns end @@ -87,8 +87,8 @@ errorReliability = 0 interfaceCheck() -m5 = Map("mwan3", translate("MWAN Interface Configuration - " .. arg[1]), - translate(interfaceWarnings())) +m5 = Map("mwan3", translatef("MWAN Interface Configuration - %s", arg[1]), + interfaceWarnings()) m5.redirect = dsp.build_url("admin", "network", "mwan", "configuration", "interface") @@ -102,6 +102,11 @@ enabled = mwan_interface:option(ListValue, "enabled", translate("Enabled")) enabled:value("1", translate("Yes")) enabled:value("0", translate("No")) +family = mwan_interface:option(ListValue, "family", translate("Internet Protocol")) + family.default = "ipv4" + family:value("ipv4", translate("IPv4")) + family:value("ipv6", translate("IPv6")) + track_ip = mwan_interface:option(DynamicList, "track_ip", translate("Tracking IP"), translate("This IP address will be pinged to dermine if the link is up or down. Leave blank to assume interface is always online")) track_ip.datatype = "ipaddr" @@ -119,33 +124,80 @@ count = mwan_interface:option(ListValue, "count", translate("Ping count")) count:value("4") count:value("5") +size = mwan_interface:option(Value, "size", translate("Ping size")) + size.default = "56" + size:value("8") + size:value("24") + size:value("56") + size:value("120") + size:value("248") + size:value("504") + size:value("1016") + size:value("1472") + size:value("2040") + size.datatype = "range(1, 65507)" + size.rmempty = false + size.optional = false + timeout = mwan_interface:option(ListValue, "timeout", translate("Ping timeout")) timeout.default = "2" - timeout:value("1", translate("1 second")) - timeout:value("2", translate("2 seconds")) - timeout:value("3", translate("3 seconds")) - timeout:value("4", translate("4 seconds")) - timeout:value("5", translate("5 seconds")) - timeout:value("6", translate("6 seconds")) - timeout:value("7", translate("7 seconds")) - timeout:value("8", translate("8 seconds")) - timeout:value("9", translate("9 seconds")) - timeout:value("10", translate("10 seconds")) + timeout:value("1", translatef("%d second", 1)) + timeout:value("2", translatef("%d seconds", 2)) + timeout:value("3", translatef("%d seconds", 3)) + timeout:value("4", translatef("%d seconds", 4)) + timeout:value("5", translatef("%d seconds", 5)) + timeout:value("6", translatef("%d seconds", 6)) + timeout:value("7", translatef("%d seconds", 7)) + timeout:value("8", translatef("%d seconds", 8)) + timeout:value("9", translatef("%d seconds", 9)) + timeout:value("10", translatef("%d seconds", 10)) interval = mwan_interface:option(ListValue, "interval", translate("Ping interval")) interval.default = "5" - interval:value("1", translate("1 second")) - interval:value("3", translate("3 seconds")) - interval:value("5", translate("5 seconds")) - interval:value("10", translate("10 seconds")) - interval:value("20", translate("20 seconds")) - interval:value("30", translate("30 seconds")) - interval:value("60", translate("1 minute")) - interval:value("300", translate("5 minutes")) - interval:value("600", translate("10 minutes")) - interval:value("900", translate("15 minutes")) - interval:value("1800", translate("30 minutes")) - interval:value("3600", translate("1 hour")) + interval:value("1", translatef("%d second", 1)) + interval:value("3", translatef("%d seconds", 3)) + interval:value("5", translatef("%d seconds", 5)) + interval:value("10", translatef("%d seconds", 10)) + interval:value("20", translatef("%d seconds", 20)) + interval:value("30", translatef("%d seconds", 30)) + interval:value("60", translatef("%d minute", 1)) + interval:value("300", translatef("%d minutes", 5)) + interval:value("600", translatef("%d minutes", 10)) + interval:value("900", translatef("%d minutes", 15)) + interval:value("1800", translatef("%d minutes", 30)) + interval:value("3600", translatef("%d hour", 1)) + +failure = mwan_interface:option(Value, "failure_interval", translate("Failure interval"), + translate("Ping interval during failure detection")) + failure.default = "5" + failure:value("1", translatef("%d second", 1)) + failure:value("3", translatef("%d seconds", 3)) + failure:value("5", translatef("%d seconds", 5)) + failure:value("10", translatef("%d seconds", 10)) + failure:value("20", translatef("%d seconds", 20)) + failure:value("30", translatef("%d seconds", 30)) + failure:value("60", translatef("%d minute", 1)) + failure:value("300", translatef("%d minutes", 5)) + failure:value("600", translatef("%d minutes", 10)) + failure:value("900", translatef("%d minutes", 15)) + failure:value("1800", translatef("%d minutes", 30)) + failure:value("3600", translatef("%d hour", 1)) + +recovery = mwan_interface:option(Value, "recovery_interval", translate("Recovery interval"), + translate("Ping interval during failure recovering")) + recovery.default = "5" + recovery:value("1", translatef("%d second", 1)) + recovery:value("3", translatef("%d seconds", 3)) + recovery:value("5", translatef("%d seconds", 5)) + recovery:value("10", translatef("%d seconds", 10)) + recovery:value("20", translatef("%d seconds", 20)) + recovery:value("30", translatef("%d seconds", 30)) + recovery:value("60", translatef("%d minute", 1)) + recovery:value("300", translatef("%d minutes", 5)) + recovery:value("600", translatef("%d minutes", 10)) + recovery:value("900", translatef("%d minutes", 15)) + recovery:value("1800", translatef("%d minutes", 30)) + recovery:value("3600", translatef("%d hour", 1)) down = mwan_interface:option(ListValue, "down", translate("Interface down"), translate("Interface will be deemed down after this many failed ping tests")) @@ -175,6 +227,14 @@ up = mwan_interface:option(ListValue, "up", translate("Interface up"), up:value("9") up:value("10") +flush = mwan_interface:option(ListValue, "flush_conntrack", translate("Flush conntrack table"), + translate("Flush global firewall conntrack table on interface events")) + flush.default = "never" + flush:value("ifup", translate("ifup")) + flush:value("ifdown", translate("ifdown")) + flush:value("never", translate("never")) + flush:value("always", translate("always")) + metric = mwan_interface:option(DummyValue, "metric", translate("Metric"), translate("This displays the metric assigned to this interface in /etc/config/network")) metric.rawhtml = true diff --git a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/memberconfig.lua b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/memberconfig.lua index 181d22e06f..eb6f417afe 100644 --- a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/memberconfig.lua +++ b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/memberconfig.lua @@ -14,7 +14,7 @@ dsp = require "luci.dispatcher" arg[1] = arg[1] or "" -m5 = Map("mwan3", translate("MWAN Member Configuration - ") .. arg[1]) +m5 = Map("mwan3", translatef("MWAN Member Configuration - %s", arg[1])) m5.redirect = dsp.build_url("admin", "network", "mwan", "configuration", "member") diff --git a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/policy.lua b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/policy.lua index e141d696a9..08c3f69de6 100644 --- a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/policy.lua +++ b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/policy.lua @@ -13,7 +13,7 @@ end function policyWarn() -- display status and warning messages at the top of the page if nameTooLong == 1 then - return "<font color=\"ff0000\"><strong>WARNING: Some policies have names exceeding the maximum of 15 characters!</strong></font>" + return "<font color=\"ff0000\"><strong>" .. translate("WARNING: Some policies have names exceeding the maximum of 15 characters!") .. "</strong></font>" else return "" end @@ -30,7 +30,7 @@ policyCheck() m5 = Map("mwan3", translate("MWAN Policy Configuration"), - translate(policyWarn())) + policyWarn()) m5:append(Template("mwan/config_css")) diff --git a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/policyconfig.lua b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/policyconfig.lua index f48a104c67..06a0fec668 100644 --- a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/policyconfig.lua +++ b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/policyconfig.lua @@ -9,7 +9,7 @@ end function policyWarn() -- display status and warning messages at the top of the page if nameTooLong == 1 then - return "<font color=\"ff0000\"><strong>WARNING: this policy's name is " .. policyNameLength .. " characters exceeding the maximum of 15!</strong></font>" + return "<font color=\"ff0000\"><strong>" .. translatef("WARNING: this policy's name is %d characters exceeding the maximum of 15!", policyNameLength) .. "</strong></font>" else return "" end @@ -32,8 +32,8 @@ nameTooLong = 0 policyCheck() -m5 = Map("mwan3", translate("MWAN Policy Configuration - " .. arg[1]), - translate(policyWarn())) +m5 = Map("mwan3", translatef("MWAN Policy Configuration - %s", arg[1]), + policyWarn()) m5.redirect = dsp.build_url("admin", "network", "mwan", "configuration", "policy") diff --git a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/rule.lua b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/rule.lua index a22e01054c..412f369eb0 100644 --- a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/rule.lua +++ b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/rule.lua @@ -17,7 +17,7 @@ end function ruleWarn() -- display warning messages at the top of the page if error_protocol_list ~= " " then - return "<font color=\"ff0000\"><strong>WARNING: some rules have a port configured with no or improper protocol specified! Please configure a specific protocol!</strong></font>" + return "<font color=\"ff0000\"><strong>" .. translate("WARNING: some rules have a port configured with no or improper protocol specified! Please configure a specific protocol!") .. "</strong></font>" else return "" end @@ -34,7 +34,7 @@ ruleCheck() m5 = Map("mwan3", translate("MWAN Rule Configuration"), - translate(ruleWarn())) + ruleWarn()) m5:append(Template("mwan/config_css")) diff --git a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/ruleconfig.lua b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/ruleconfig.lua index f7fb341e1f..25a96f5c8f 100644 --- a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/ruleconfig.lua +++ b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/ruleconfig.lua @@ -13,7 +13,7 @@ end function ruleWarn() -- display warning message at the top of the page if error_protocol == 1 then - return "<font color=\"ff0000\"><strong>WARNING: this rule is incorrectly configured with no or improper protocol specified! Please configure a specific protocol!</strong></font>" + return "<font color=\"ff0000\"><strong>" .. translate("WARNING: this rule is incorrectly configured with no or improper protocol specified! Please configure a specific protocol!") .. "</strong></font>" else return "" end @@ -45,8 +45,8 @@ error_protocol = 0 ruleCheck() -m5 = Map("mwan3", translate("MWAN Rule Configuration - ") .. arg[1], - translate(ruleWarn())) +m5 = Map("mwan3", translatef("MWAN Rule Configuration - %s", arg[1]), + ruleWarn()) m5.redirect = dsp.build_url("admin", "network", "mwan", "configuration", "rule") |