-- 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 = ""
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 />" ..
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
end
end
-return m5
+return m
-- 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
end
end
-return m5
+return m
-- 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"))
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
return self.map:get(s, "weight") or "1"
end
-return m5
+return m
-- 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
translate("Acceptable values: 1-1000. Defaults to 1 if not set"))
weight.datatype = "range(1, 1000)"
-return m5
+return m
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 />" ..
return fs.writefile(script, ut.trim(data:gsub("\r\n", "\n")) .. "\n")
end
-return m5
+return m
-- 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 = {}
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 />" ..
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
end
end
-return m5
+return m
-- 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
last_resort:value("blackhole", translate("blackhole (drop)"))
last_resort:value("default", translate("default (use main routing table)"))
-return m5
+return m
-- 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 = {}
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 />" ..
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
return self.map:get(s, "use_policy") or "—"
end
-return m5
+return m
-- 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
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
policy:value("blackhole", translate("blackhole (drop)"))
policy:value("default", translate("default (use main routing table)"))
-return m5
+return m