luci-app-mwan3: fix cbi local scope
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
This commit is contained in:
parent
8fc68bee2c
commit
c95fdfcc1a
9 changed files with 73 additions and 54 deletions
|
@ -2,9 +2,11 @@
|
||||||
-- Copyright 2018 Florian Eckert <fe@dev.tdt.de>
|
-- Copyright 2018 Florian Eckert <fe@dev.tdt.de>
|
||||||
-- Licensed to the public under the GNU General Public License v2.
|
-- Licensed to the public under the GNU General Public License v2.
|
||||||
|
|
||||||
dsp = require "luci.dispatcher"
|
local dsp = require "luci.dispatcher"
|
||||||
uci = require "uci"
|
local uci = require "uci"
|
||||||
|
|
||||||
|
local m, mwan_interface, enabled, track_method, reliability, interval
|
||||||
|
local down, up, metric
|
||||||
|
|
||||||
function interfaceWarnings(overview, count, iface_max)
|
function interfaceWarnings(overview, count, iface_max)
|
||||||
local warnings = ""
|
local warnings = ""
|
||||||
|
@ -134,10 +136,10 @@ function configCheck()
|
||||||
return overview, count, iface_max
|
return overview, count, iface_max
|
||||||
end
|
end
|
||||||
|
|
||||||
m5 = Map("mwan3", translate("MWAN - Interfaces"),
|
m = Map("mwan3", translate("MWAN - Interfaces"),
|
||||||
interfaceWarnings(configCheck()))
|
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 />" ..
|
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 />" ..
|
"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 />" ..
|
"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")
|
mwan_interface.extedit = dsp.build_url("admin", "network", "mwan", "interface", "%s")
|
||||||
function mwan_interface.create(self, section)
|
function mwan_interface.create(self, section)
|
||||||
TypedSection.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))
|
luci.http.redirect(dsp.build_url("admin", "network", "mwan", "interface", section))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -237,4 +239,4 @@ function metric.cfgvalue(self, s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return m5
|
return m
|
||||||
|
|
|
@ -2,14 +2,20 @@
|
||||||
-- Copyright 2018 Florian Eckert <fe@dev.tdt.de>
|
-- Copyright 2018 Florian Eckert <fe@dev.tdt.de>
|
||||||
-- Licensed to the public under the GNU General Public License v2.
|
-- Licensed to the public under the GNU General Public License v2.
|
||||||
|
|
||||||
dsp = require "luci.dispatcher"
|
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 ""
|
arg[1] = arg[1] or ""
|
||||||
|
|
||||||
|
m = Map("mwan3", translatef("MWAN Interface Configuration - %s", arg[1]))
|
||||||
|
m.redirect = dsp.build_url("admin", "network", "mwan", "interface")
|
||||||
|
|
||||||
m5 = Map("mwan3", translatef("MWAN Interface Configuration - %s", arg[1]))
|
mwan_interface = m:section(NamedSection, arg[1], "interface", "")
|
||||||
m5.redirect = dsp.build_url("admin", "network", "mwan", "interface")
|
|
||||||
|
|
||||||
mwan_interface = m5:section(NamedSection, arg[1], "interface", "")
|
|
||||||
mwan_interface.addremove = false
|
mwan_interface.addremove = false
|
||||||
mwan_interface.dynamic = false
|
mwan_interface.dynamic = false
|
||||||
|
|
||||||
|
@ -249,4 +255,4 @@ function metric.cfgvalue(self, s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return m5
|
return m
|
||||||
|
|
|
@ -2,12 +2,13 @@
|
||||||
-- Copyright 2018 Florian Eckert <fe@dev.tdt.de>
|
-- Copyright 2018 Florian Eckert <fe@dev.tdt.de>
|
||||||
-- Licensed to the public under the GNU General Public License v2.
|
-- 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 />" ..
|
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 />" ..
|
"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"))
|
"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")
|
mwan_member.extedit = dsp.build_url("admin", "network", "mwan", "member", "%s")
|
||||||
function mwan_member.create(self, section)
|
function mwan_member.create(self, section)
|
||||||
TypedSection.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))
|
luci.http.redirect(dsp.build_url("admin", "network", "mwan", "member", section))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -41,4 +42,4 @@ function weight.cfgvalue(self, s)
|
||||||
return self.map:get(s, "weight") or "1"
|
return self.map:get(s, "weight") or "1"
|
||||||
end
|
end
|
||||||
|
|
||||||
return m5
|
return m
|
||||||
|
|
|
@ -2,19 +2,21 @@
|
||||||
-- Copyright 2018 Florian Eckert <fe@dev.tdt.de>
|
-- Copyright 2018 Florian Eckert <fe@dev.tdt.de>
|
||||||
-- Licensed to the public under the GNU General Public License v2.
|
-- 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
|
||||||
|
|
||||||
arg[1] = arg[1] or ""
|
arg[1] = arg[1] or ""
|
||||||
|
|
||||||
|
m = Map("mwan3", translatef("MWAN Member Configuration - %s", arg[1]))
|
||||||
|
m.redirect = dsp.build_url("admin", "network", "mwan", "member")
|
||||||
|
|
||||||
m5 = Map("mwan3", translatef("MWAN Member Configuration - %s", arg[1]))
|
mwan_member = m:section(NamedSection, arg[1], "member", "")
|
||||||
m5.redirect = dsp.build_url("admin", "network", "mwan", "member")
|
|
||||||
|
|
||||||
mwan_member = m5:section(NamedSection, arg[1], "member", "")
|
|
||||||
mwan_member.addremove = false
|
mwan_member.addremove = false
|
||||||
mwan_member.dynamic = false
|
mwan_member.dynamic = false
|
||||||
|
|
||||||
interface = mwan_member:option(Value, "interface", translate("Interface"))
|
interface = mwan_member:option(Value, "interface", translate("Interface"))
|
||||||
m5.uci:foreach("mwan3", "interface",
|
m.uci:foreach("mwan3", "interface",
|
||||||
function(s)
|
function(s)
|
||||||
interface:value(s['.name'], s['.name'])
|
interface:value(s['.name'], s['.name'])
|
||||||
end
|
end
|
||||||
|
@ -28,4 +30,4 @@ weight = mwan_member:option(Value, "weight", translate("Weight"),
|
||||||
translate("Acceptable values: 1-1000. Defaults to 1 if not set"))
|
translate("Acceptable values: 1-1000. Defaults to 1 if not set"))
|
||||||
weight.datatype = "range(1, 1000)"
|
weight.datatype = "range(1, 1000)"
|
||||||
|
|
||||||
return m5
|
return m
|
||||||
|
|
|
@ -4,12 +4,13 @@
|
||||||
|
|
||||||
local fs = require "nixio.fs"
|
local fs = require "nixio.fs"
|
||||||
local ut = require "luci.util"
|
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 />" ..
|
translate("This section allows you to modify the content of \"/etc/mwan3.user\".<br />" ..
|
||||||
"The file is also preserved during sysupgrade.<br />" ..
|
"The file is also preserved during sysupgrade.<br />" ..
|
||||||
"<br />" ..
|
"<br />" ..
|
||||||
|
@ -42,4 +43,4 @@ function t.write(self, section, data)
|
||||||
return fs.writefile(script, ut.trim(data:gsub("\r\n", "\n")) .. "\n")
|
return fs.writefile(script, ut.trim(data:gsub("\r\n", "\n")) .. "\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
return m5
|
return m
|
||||||
|
|
|
@ -2,9 +2,10 @@
|
||||||
-- Copyright 2018 Florian Eckert <fe@dev.tdt.de>
|
-- Copyright 2018 Florian Eckert <fe@dev.tdt.de>
|
||||||
-- Licensed to the public under the GNU General Public License v2.
|
-- Licensed to the public under the GNU General Public License v2.
|
||||||
|
|
||||||
dsp = require "luci.dispatcher"
|
local dsp = require "luci.dispatcher"
|
||||||
uci = require "uci"
|
local uci = require "uci"
|
||||||
|
|
||||||
|
local m, mwan_policy, use_member, last_resort
|
||||||
|
|
||||||
function policyCheck()
|
function policyCheck()
|
||||||
local policy_error = {}
|
local policy_error = {}
|
||||||
|
@ -34,10 +35,10 @@ function policyError(policy_error)
|
||||||
return warnings
|
return warnings
|
||||||
end
|
end
|
||||||
|
|
||||||
m5 = Map("mwan3", translate("MWAN - Policies"),
|
m = Map("mwan3", translate("MWAN - Policies"),
|
||||||
policyError(policyCheck()))
|
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 />" ..
|
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 lower metrics are used first<br />" ..
|
||||||
"Member interfaces with the same metric will be load-balanced<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")
|
mwan_policy.extedit = dsp.build_url("admin", "network", "mwan", "policy", "%s")
|
||||||
function mwan_policy.create(self, section)
|
function mwan_policy.create(self, section)
|
||||||
TypedSection.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))
|
luci.http.redirect(dsp.build_url("admin", "network", "mwan", "policy", section))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -84,4 +85,4 @@ function last_resort.cfgvalue(self, s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return m5
|
return m
|
||||||
|
|
|
@ -2,19 +2,21 @@
|
||||||
-- Copyright 2018 Florian Eckert <fe@dev.tdt.de>
|
-- Copyright 2018 Florian Eckert <fe@dev.tdt.de>
|
||||||
-- Licensed to the public under the GNU General Public License v2.
|
-- Licensed to the public under the GNU General Public License v2.
|
||||||
|
|
||||||
dsp = require "luci.dispatcher"
|
local dsp = require "luci.dispatcher"
|
||||||
|
|
||||||
|
local m, mwan_policy, member, last_resort
|
||||||
|
|
||||||
arg[1] = arg[1] or ""
|
arg[1] = arg[1] or ""
|
||||||
|
|
||||||
|
m = Map("mwan3", translatef("MWAN Policy Configuration - %s", arg[1]))
|
||||||
|
m.redirect = dsp.build_url("admin", "network", "mwan", "policy")
|
||||||
|
|
||||||
m5 = Map("mwan3", translatef("MWAN Policy Configuration - %s", arg[1]))
|
mwan_policy = m:section(NamedSection, arg[1], "policy", "")
|
||||||
m5.redirect = dsp.build_url("admin", "network", "mwan", "policy")
|
|
||||||
|
|
||||||
mwan_policy = m5:section(NamedSection, arg[1], "policy", "")
|
|
||||||
mwan_policy.addremove = false
|
mwan_policy.addremove = false
|
||||||
mwan_policy.dynamic = false
|
mwan_policy.dynamic = false
|
||||||
|
|
||||||
member = mwan_policy:option(DynamicList, "use_member", translate("Member used"))
|
member = mwan_policy:option(DynamicList, "use_member", translate("Member used"))
|
||||||
m5.uci:foreach("mwan3", "member",
|
m.uci:foreach("mwan3", "member",
|
||||||
function(s)
|
function(s)
|
||||||
member:value(s['.name'], s['.name'])
|
member:value(s['.name'], s['.name'])
|
||||||
end
|
end
|
||||||
|
@ -27,4 +29,4 @@ last_resort:value("unreachable", translate("unreachable (reject)"))
|
||||||
last_resort:value("blackhole", translate("blackhole (drop)"))
|
last_resort:value("blackhole", translate("blackhole (drop)"))
|
||||||
last_resort:value("default", translate("default (use main routing table)"))
|
last_resort:value("default", translate("default (use main routing table)"))
|
||||||
|
|
||||||
return m5
|
return m
|
||||||
|
|
|
@ -2,9 +2,10 @@
|
||||||
-- Copyright 2018 Florian Eckert <fe@dev.tdt.de>
|
-- Copyright 2018 Florian Eckert <fe@dev.tdt.de>
|
||||||
-- Licensed to the public under the GNU General Public License v2.
|
-- Licensed to the public under the GNU General Public License v2.
|
||||||
|
|
||||||
dsp = require "luci.dispatcher"
|
local dsp = require "luci.dispatcher"
|
||||||
uci = require "uci"
|
local uci = require "uci"
|
||||||
|
|
||||||
|
local m, mwan_rule, src_ip, src_port, dest_ip, dest_port, proto, use_policy
|
||||||
|
|
||||||
function ruleCheck()
|
function ruleCheck()
|
||||||
local rule_error = {}
|
local rule_error = {}
|
||||||
|
@ -38,11 +39,11 @@ function ruleWarn(rule_error)
|
||||||
return warnings
|
return warnings
|
||||||
end
|
end
|
||||||
|
|
||||||
m5 = Map("mwan3", translate("MWAN - Rules"),
|
m = Map("mwan3", translate("MWAN - Rules"),
|
||||||
ruleWarn(ruleCheck())
|
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 />" ..
|
translate("Rules specify which traffic will use a particular MWAN policy<br />" ..
|
||||||
"Rules are based on IP address, port or protocol<br />" ..
|
"Rules are based on IP address, port or protocol<br />" ..
|
||||||
"Rules are matched from top to bottom<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")
|
mwan_rule.extedit = dsp.build_url("admin", "network", "mwan", "rule", "%s")
|
||||||
function mwan_rule.create(self, section)
|
function mwan_rule.create(self, section)
|
||||||
TypedSection.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))
|
luci.http.redirect(dsp.build_url("admin", "network", "mwan", "rule", section))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -101,4 +102,4 @@ function use_policy.cfgvalue(self, s)
|
||||||
return self.map:get(s, "use_policy") or "—"
|
return self.map:get(s, "use_policy") or "—"
|
||||||
end
|
end
|
||||||
|
|
||||||
return m5
|
return m
|
||||||
|
|
|
@ -2,14 +2,17 @@
|
||||||
-- Copyright 2018 Florian Eckert <fe@dev.tdt.de>
|
-- Copyright 2018 Florian Eckert <fe@dev.tdt.de>
|
||||||
-- Licensed to the public under the GNU General Public License v2.
|
-- Licensed to the public under the GNU General Public License v2.
|
||||||
|
|
||||||
dsp = require "luci.dispatcher"
|
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 ""
|
arg[1] = arg[1] or ""
|
||||||
|
|
||||||
|
m = Map("mwan3", translatef("MWAN Rule Configuration - %s", arg[1]))
|
||||||
|
m.redirect = dsp.build_url("admin", "network", "mwan", "rule")
|
||||||
|
|
||||||
m5 = Map("mwan3", translatef("MWAN Rule Configuration - %s", arg[1]))
|
mwan_rule = m:section(NamedSection, arg[1], "rule", "")
|
||||||
m5.redirect = dsp.build_url("admin", "network", "mwan", "rule")
|
|
||||||
|
|
||||||
mwan_rule = m5:section(NamedSection, arg[1], "rule", "")
|
|
||||||
mwan_rule.addremove = false
|
mwan_rule.addremove = false
|
||||||
mwan_rule.dynamic = 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\")"))
|
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"))
|
policy = mwan_rule:option(Value, "use_policy", translate("Policy assigned"))
|
||||||
m5.uci:foreach("mwan3", "policy",
|
m.uci:foreach("mwan3", "policy",
|
||||||
function(s)
|
function(s)
|
||||||
policy:value(s['.name'], s['.name'])
|
policy:value(s['.name'], s['.name'])
|
||||||
end
|
end
|
||||||
|
@ -60,4 +63,4 @@ policy:value("unreachable", translate("unreachable (reject)"))
|
||||||
policy:value("blackhole", translate("blackhole (drop)"))
|
policy:value("blackhole", translate("blackhole (drop)"))
|
||||||
policy:value("default", translate("default (use main routing table)"))
|
policy:value("default", translate("default (use main routing table)"))
|
||||||
|
|
||||||
return m5
|
return m
|
||||||
|
|
Loading…
Reference in a new issue