diff options
9 files changed, 73 insertions, 54 deletions
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 162b388d1..dad709ede 100644 --- a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/interface.lua +++ b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/interface.lua @@ -2,9 +2,11 @@ -- Copyright 2018 Florian Eckert <fe@dev.tdt.de> -- Licensed to the public under the GNU General Public License v2. -dsp = require "luci.dispatcher" -uci = require "uci" +local dsp = require "luci.dispatcher" +local uci = require "uci" +local m, mwan_interface, enabled, track_method, reliability, interval +local down, up, metric function interfaceWarnings(overview, count, iface_max) local warnings = "" @@ -134,10 +136,10 @@ function configCheck() return overview, count, iface_max end -m5 = Map("mwan3", translate("MWAN - Interfaces"), +m = Map("mwan3", translate("MWAN - Interfaces"), interfaceWarnings(configCheck())) -mwan_interface = m5:section(TypedSection, "interface", nil, +mwan_interface = m:section(TypedSection, "interface", nil, translate("MWAN supports up to 252 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<br />" .. @@ -151,7 +153,7 @@ mwan_interface.template = "cbi/tblsection" mwan_interface.extedit = dsp.build_url("admin", "network", "mwan", "interface", "%s") function mwan_interface.create(self, section) TypedSection.create(self, section) - m5.uci:save("mwan3") + m.uci:save("mwan3") luci.http.redirect(dsp.build_url("admin", "network", "mwan", "interface", section)) end @@ -237,4 +239,4 @@ function metric.cfgvalue(self, s) end end -return m5 +return m 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 4c970d4fa..c8f6104ea 100644 --- a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/interfaceconfig.lua +++ b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/interfaceconfig.lua @@ -2,14 +2,20 @@ -- Copyright 2018 Florian Eckert <fe@dev.tdt.de> -- Licensed to the public under the GNU General Public License v2. -dsp = require "luci.dispatcher" -arg[1] = arg[1] or "" +local dsp = require "luci.dispatcher" + +local m, mwan_interface, enabled, initial_state, family, track_ip +local track_method, reliability, count, size, max_ttl +local check_quality, failure_latency, failure_loss, recovery_latency +local recovery_loss, timeout, interval, failure +local keep_failure, recovery, down, up, flush, metric +arg[1] = arg[1] or "" -m5 = Map("mwan3", translatef("MWAN Interface Configuration - %s", arg[1])) - m5.redirect = dsp.build_url("admin", "network", "mwan", "interface") +m = Map("mwan3", translatef("MWAN Interface Configuration - %s", arg[1])) +m.redirect = dsp.build_url("admin", "network", "mwan", "interface") -mwan_interface = m5:section(NamedSection, arg[1], "interface", "") +mwan_interface = m:section(NamedSection, arg[1], "interface", "") mwan_interface.addremove = false mwan_interface.dynamic = false @@ -249,4 +255,4 @@ function metric.cfgvalue(self, s) end end -return m5 +return m diff --git a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/member.lua b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/member.lua index 9b4ab102d..4125aae0b 100644 --- a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/member.lua +++ b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/member.lua @@ -2,12 +2,13 @@ -- Copyright 2018 Florian Eckert <fe@dev.tdt.de> -- Licensed to the public under the GNU General Public License v2. -dsp = require "luci.dispatcher" +local dsp = require "luci.dispatcher" +local m, mwan_member, interface, metric, weight -m5 = Map("mwan3", translate("MWAN - Members")) +m = Map("mwan3", translate("MWAN - Members")) -mwan_member = m5:section(TypedSection, "member", nil, +mwan_member = m:section(TypedSection, "member", nil, translate("Members are profiles attaching a metric and weight to an MWAN interface<br />" .. "Names may contain characters A-Z, a-z, 0-9, _ and no spaces<br />" .. "Members may not share the same name as configured interfaces, policies or rules")) @@ -19,7 +20,7 @@ mwan_member.template = "cbi/tblsection" mwan_member.extedit = dsp.build_url("admin", "network", "mwan", "member", "%s") function mwan_member.create(self, section) TypedSection.create(self, section) - m5.uci:save("mwan3") + m.uci:save("mwan3") luci.http.redirect(dsp.build_url("admin", "network", "mwan", "member", section)) end @@ -41,4 +42,4 @@ function weight.cfgvalue(self, s) return self.map:get(s, "weight") or "1" end -return m5 +return m 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 27d9a3e85..3464ebfc9 100644 --- a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/memberconfig.lua +++ b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/memberconfig.lua @@ -2,19 +2,21 @@ -- Copyright 2018 Florian Eckert <fe@dev.tdt.de> -- Licensed to the public under the GNU General Public License v2. -dsp = require "luci.dispatcher" -arg[1] = arg[1] or "" +local dsp = require "luci.dispatcher" + +local m, mwan_member, interface, metric, weight +arg[1] = arg[1] or "" -m5 = Map("mwan3", translatef("MWAN Member Configuration - %s", arg[1])) -m5.redirect = dsp.build_url("admin", "network", "mwan", "member") +m = Map("mwan3", translatef("MWAN Member Configuration - %s", arg[1])) +m.redirect = dsp.build_url("admin", "network", "mwan", "member") -mwan_member = m5:section(NamedSection, arg[1], "member", "") +mwan_member = m:section(NamedSection, arg[1], "member", "") mwan_member.addremove = false mwan_member.dynamic = false interface = mwan_member:option(Value, "interface", translate("Interface")) -m5.uci:foreach("mwan3", "interface", +m.uci:foreach("mwan3", "interface", function(s) interface:value(s['.name'], s['.name']) end @@ -28,4 +30,4 @@ weight = mwan_member:option(Value, "weight", translate("Weight"), translate("Acceptable values: 1-1000. Defaults to 1 if not set")) weight.datatype = "range(1, 1000)" -return m5 +return m diff --git a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/notify.lua b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/notify.lua index 4c6e21003..ff1d338ee 100644 --- a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/notify.lua +++ b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/notify.lua @@ -4,12 +4,13 @@ local fs = require "nixio.fs" local ut = require "luci.util" -script = "/etc/mwan3.user" +local script = "/etc/mwan3.user" +local m, f, t -m5 = SimpleForm("luci", translate("MWAN - Notification")) +m = SimpleForm("luci", translate("MWAN - Notification")) -f = m5:section(SimpleSection, nil, +f = m:section(SimpleSection, nil, translate("This section allows you to modify the content of \"/etc/mwan3.user\".<br />" .. "The file is also preserved during sysupgrade.<br />" .. "<br />" .. @@ -42,4 +43,4 @@ function t.write(self, section, data) return fs.writefile(script, ut.trim(data:gsub("\r\n", "\n")) .. "\n") end -return m5 +return m 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 4543260f6..c2f47d6b2 100644 --- a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/policy.lua +++ b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/policy.lua @@ -2,9 +2,10 @@ -- Copyright 2018 Florian Eckert <fe@dev.tdt.de> -- Licensed to the public under the GNU General Public License v2. -dsp = require "luci.dispatcher" -uci = require "uci" +local dsp = require "luci.dispatcher" +local uci = require "uci" +local m, mwan_policy, use_member, last_resort function policyCheck() local policy_error = {} @@ -34,10 +35,10 @@ function policyError(policy_error) return warnings end -m5 = Map("mwan3", translate("MWAN - Policies"), +m = Map("mwan3", translate("MWAN - Policies"), policyError(policyCheck())) -mwan_policy = m5:section(TypedSection, "policy", nil, +mwan_policy = m:section(TypedSection, "policy", nil, translate("Policies are profiles grouping one or more members controlling how MWAN distributes traffic<br />" .. "Member interfaces with lower metrics are used first<br />" .. "Member interfaces with the same metric will be load-balanced<br />" .. @@ -53,7 +54,7 @@ mwan_policy.template = "cbi/tblsection" mwan_policy.extedit = dsp.build_url("admin", "network", "mwan", "policy", "%s") function mwan_policy.create(self, section) TypedSection.create(self, section) - m5.uci:save("mwan3") + m.uci:save("mwan3") luci.http.redirect(dsp.build_url("admin", "network", "mwan", "policy", section)) end @@ -84,4 +85,4 @@ function last_resort.cfgvalue(self, s) end end -return m5 +return m 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 d1a063d09..8e5a3fa95 100644 --- a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/policyconfig.lua +++ b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/policyconfig.lua @@ -2,19 +2,21 @@ -- Copyright 2018 Florian Eckert <fe@dev.tdt.de> -- Licensed to the public under the GNU General Public License v2. -dsp = require "luci.dispatcher" -arg[1] = arg[1] or "" +local dsp = require "luci.dispatcher" + +local m, mwan_policy, member, last_resort +arg[1] = arg[1] or "" -m5 = Map("mwan3", translatef("MWAN Policy Configuration - %s", arg[1])) -m5.redirect = dsp.build_url("admin", "network", "mwan", "policy") +m = Map("mwan3", translatef("MWAN Policy Configuration - %s", arg[1])) +m.redirect = dsp.build_url("admin", "network", "mwan", "policy") -mwan_policy = m5:section(NamedSection, arg[1], "policy", "") +mwan_policy = m:section(NamedSection, arg[1], "policy", "") mwan_policy.addremove = false mwan_policy.dynamic = false member = mwan_policy:option(DynamicList, "use_member", translate("Member used")) -m5.uci:foreach("mwan3", "member", +m.uci:foreach("mwan3", "member", function(s) member:value(s['.name'], s['.name']) end @@ -27,4 +29,4 @@ last_resort:value("unreachable", translate("unreachable (reject)")) last_resort:value("blackhole", translate("blackhole (drop)")) last_resort:value("default", translate("default (use main routing table)")) -return m5 +return m 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 f0b94bd0b..a197930a4 100644 --- a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/rule.lua +++ b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/rule.lua @@ -2,9 +2,10 @@ -- Copyright 2018 Florian Eckert <fe@dev.tdt.de> -- Licensed to the public under the GNU General Public License v2. -dsp = require "luci.dispatcher" -uci = require "uci" +local dsp = require "luci.dispatcher" +local uci = require "uci" +local m, mwan_rule, src_ip, src_port, dest_ip, dest_port, proto, use_policy function ruleCheck() local rule_error = {} @@ -38,11 +39,11 @@ function ruleWarn(rule_error) return warnings end -m5 = Map("mwan3", translate("MWAN - Rules"), +m = Map("mwan3", translate("MWAN - Rules"), ruleWarn(ruleCheck()) ) -mwan_rule = m5:section(TypedSection, "rule", nil, +mwan_rule = m:section(TypedSection, "rule", nil, translate("Rules specify which traffic will use a particular MWAN policy<br />" .. "Rules are based on IP address, port or protocol<br />" .. "Rules are matched from top to bottom<br />" .. @@ -61,7 +62,7 @@ mwan_rule.template = "cbi/tblsection" mwan_rule.extedit = dsp.build_url("admin", "network", "mwan", "rule", "%s") function mwan_rule.create(self, section) TypedSection.create(self, section) - m5.uci:save("mwan3") + m.uci:save("mwan3") luci.http.redirect(dsp.build_url("admin", "network", "mwan", "rule", section)) end @@ -101,4 +102,4 @@ function use_policy.cfgvalue(self, s) return self.map:get(s, "use_policy") or "—" end -return m5 +return m 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 84adfcf91..51592f813 100644 --- a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/ruleconfig.lua +++ b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/ruleconfig.lua @@ -2,14 +2,17 @@ -- Copyright 2018 Florian Eckert <fe@dev.tdt.de> -- Licensed to the public under the GNU General Public License v2. -dsp = require "luci.dispatcher" -arg[1] = arg[1] or "" +local dsp = require "luci.dispatcher" + +local m, mwan_rule, src_ip, src_port, dest_ip, dest_port, proto, sticky +local timeout, ipset, policy +arg[1] = arg[1] or "" -m5 = Map("mwan3", translatef("MWAN Rule Configuration - %s", arg[1])) -m5.redirect = dsp.build_url("admin", "network", "mwan", "rule") +m = Map("mwan3", translatef("MWAN Rule Configuration - %s", arg[1])) +m.redirect = dsp.build_url("admin", "network", "mwan", "rule") -mwan_rule = m5:section(NamedSection, arg[1], "rule", "") +mwan_rule = m:section(NamedSection, arg[1], "rule", "") mwan_rule.addremove = false mwan_rule.dynamic = false @@ -51,7 +54,7 @@ ipset = mwan_rule:option(Value, "ipset", translate("IPset"), translate("Name of IPset rule. Requires IPset rule in /etc/dnsmasq.conf (eg \"ipset=/youtube.com/youtube\")")) policy = mwan_rule:option(Value, "use_policy", translate("Policy assigned")) -m5.uci:foreach("mwan3", "policy", +m.uci:foreach("mwan3", "policy", function(s) policy:value(s['.name'], s['.name']) end @@ -60,4 +63,4 @@ policy:value("unreachable", translate("unreachable (reject)")) policy:value("blackhole", translate("blackhole (drop)")) policy:value("default", translate("default (use main routing table)")) -return m5 +return m |