luci-app-mwan3: fix unify luci code styling
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
This commit is contained in:
parent
831bd71eb3
commit
278b3f53db
8 changed files with 308 additions and 316 deletions
|
@ -105,61 +105,59 @@ end
|
||||||
m5 = Map("mwan3", translate("MWAN - Interfaces"),
|
m5 = Map("mwan3", translate("MWAN - Interfaces"),
|
||||||
interfaceWarnings(configCheck()))
|
interfaceWarnings(configCheck()))
|
||||||
|
|
||||||
|
|
||||||
mwan_interface = m5:section(TypedSection, "interface", nil,
|
mwan_interface = m5:section(TypedSection, "interface", nil,
|
||||||
translate("MWAN supports up to 250 physical and/or logical interfaces<br />" ..
|
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 />" ..
|
"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 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 />" ..
|
"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"))
|
"Interfaces may not share the same name as configured members, policies or rules"))
|
||||||
mwan_interface.addremove = true
|
mwan_interface.addremove = true
|
||||||
mwan_interface.dynamic = false
|
mwan_interface.dynamic = false
|
||||||
mwan_interface.sectionhead = translate("Interface")
|
mwan_interface.sectionhead = translate("Interface")
|
||||||
mwan_interface.sortable = false
|
mwan_interface.sortable = false
|
||||||
mwan_interface.template = "cbi/tblsection"
|
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")
|
m5.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
|
||||||
|
|
||||||
|
|
||||||
enabled = mwan_interface:option(DummyValue, "enabled", translate("Enabled"))
|
enabled = mwan_interface:option(DummyValue, "enabled", translate("Enabled"))
|
||||||
enabled.rawhtml = true
|
enabled.rawhtml = true
|
||||||
function enabled.cfgvalue(self, s)
|
function enabled.cfgvalue(self, s)
|
||||||
if self.map:get(s, "enabled") == "1" then
|
if self.map:get(s, "enabled") == "1" then
|
||||||
return translate("Yes")
|
return translate("Yes")
|
||||||
else
|
else
|
||||||
return translate("No")
|
return translate("No")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
track_method = mwan_interface:option(DummyValue, "track_method", translate("Tracking method"))
|
track_method = mwan_interface:option(DummyValue, "track_method", translate("Tracking method"))
|
||||||
track_method.rawhtml = true
|
track_method.rawhtml = true
|
||||||
function track_method.cfgvalue(self, s)
|
function track_method.cfgvalue(self, s)
|
||||||
local tracked = self.map:get(s, "track_ip")
|
local tracked = self.map:get(s, "track_ip")
|
||||||
if tracked then
|
if tracked then
|
||||||
return self.map:get(s, "track_method") or "—"
|
return self.map:get(s, "track_method") or "—"
|
||||||
else
|
else
|
||||||
return "—"
|
return "—"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
reliability = mwan_interface:option(DummyValue, "reliability", translate("Tracking reliability"))
|
reliability = mwan_interface:option(DummyValue, "reliability", translate("Tracking reliability"))
|
||||||
reliability.rawhtml = true
|
reliability.rawhtml = true
|
||||||
function reliability.cfgvalue(self, s)
|
function reliability.cfgvalue(self, s)
|
||||||
local tracked = self.map:get(s, "track_ip")
|
local tracked = self.map:get(s, "track_ip")
|
||||||
if tracked then
|
if tracked then
|
||||||
return self.map:get(s, "reliability") or "—"
|
return self.map:get(s, "reliability") or "—"
|
||||||
else
|
else
|
||||||
return "—"
|
return "—"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
interval = mwan_interface:option(DummyValue, "interval", translate("Ping interval"))
|
interval = mwan_interface:option(DummyValue, "interval", translate("Ping interval"))
|
||||||
interval.rawhtml = true
|
interval.rawhtml = true
|
||||||
function interval.cfgvalue(self, s)
|
function interval.cfgvalue(self, s)
|
||||||
local tracked = self.map:get(s, "track_ip")
|
local tracked = self.map:get(s, "track_ip")
|
||||||
if tracked then
|
if tracked then
|
||||||
local intervalValue = self.map:get(s, "interval")
|
local intervalValue = self.map:get(s, "interval")
|
||||||
|
@ -171,33 +169,33 @@ interval = mwan_interface:option(DummyValue, "interval", translate("Ping interva
|
||||||
else
|
else
|
||||||
return "—"
|
return "—"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
down = mwan_interface:option(DummyValue, "down", translate("Interface down"))
|
down = mwan_interface:option(DummyValue, "down", translate("Interface down"))
|
||||||
down.rawhtml = true
|
down.rawhtml = true
|
||||||
function down.cfgvalue(self, s)
|
function down.cfgvalue(self, s)
|
||||||
local tracked = self.map:get(s, "track_ip")
|
local tracked = self.map:get(s, "track_ip")
|
||||||
if tracked then
|
if tracked then
|
||||||
return self.map:get(s, "down") or "—"
|
return self.map:get(s, "down") or "—"
|
||||||
else
|
else
|
||||||
return "—"
|
return "—"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
up = mwan_interface:option(DummyValue, "up", translate("Interface up"))
|
up = mwan_interface:option(DummyValue, "up", translate("Interface up"))
|
||||||
up.rawhtml = true
|
up.rawhtml = true
|
||||||
function up.cfgvalue(self, s)
|
function up.cfgvalue(self, s)
|
||||||
local tracked = self.map:get(s, "track_ip")
|
local tracked = self.map:get(s, "track_ip")
|
||||||
if tracked then
|
if tracked then
|
||||||
return self.map:get(s, "up") or "—"
|
return self.map:get(s, "up") or "—"
|
||||||
else
|
else
|
||||||
return "—"
|
return "—"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
metric = mwan_interface:option(DummyValue, "metric", translate("Metric"))
|
metric = mwan_interface:option(DummyValue, "metric", translate("Metric"))
|
||||||
metric.rawhtml = true
|
metric.rawhtml = true
|
||||||
function metric.cfgvalue(self, s)
|
function metric.cfgvalue(self, s)
|
||||||
local uci = uci.cursor(nil, "/var/state")
|
local uci = uci.cursor(nil, "/var/state")
|
||||||
local metric = uci:get("network", s, "metric")
|
local metric = uci:get("network", s, "metric")
|
||||||
if metric then
|
if metric then
|
||||||
|
@ -205,6 +203,6 @@ metric = mwan_interface:option(DummyValue, "metric", translate("Metric"))
|
||||||
else
|
else
|
||||||
return "—"
|
return "—"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return m5
|
return m5
|
||||||
|
|
|
@ -5,170 +5,168 @@ arg[1] = arg[1] or ""
|
||||||
m5 = Map("mwan3", translatef("MWAN Interface Configuration - %s", arg[1]))
|
m5 = Map("mwan3", translatef("MWAN Interface Configuration - %s", arg[1]))
|
||||||
m5.redirect = dsp.build_url("admin", "network", "mwan", "interface")
|
m5.redirect = dsp.build_url("admin", "network", "mwan", "interface")
|
||||||
|
|
||||||
|
|
||||||
mwan_interface = m5:section(NamedSection, arg[1], "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
|
||||||
|
|
||||||
|
|
||||||
enabled = mwan_interface:option(ListValue, "enabled", translate("Enabled"))
|
enabled = mwan_interface:option(ListValue, "enabled", translate("Enabled"))
|
||||||
enabled.default = "1"
|
enabled.default = "1"
|
||||||
enabled:value("1", translate("Yes"))
|
enabled:value("1", translate("Yes"))
|
||||||
enabled:value("0", translate("No"))
|
enabled:value("0", translate("No"))
|
||||||
|
|
||||||
initial_state = mwan_interface:option(ListValue, "initial_state", translate("Initial state"),
|
initial_state = mwan_interface:option(ListValue, "initial_state", translate("Initial state"),
|
||||||
translate("Expect interface state on up event"))
|
translate("Expect interface state on up event"))
|
||||||
initial_state.default = "online"
|
initial_state.default = "online"
|
||||||
initial_state:value("online", translate("Online"))
|
initial_state:value("online", translate("Online"))
|
||||||
initial_state:value("offline", translate("Offline"))
|
initial_state:value("offline", translate("Offline"))
|
||||||
|
|
||||||
family = mwan_interface:option(ListValue, "family", translate("Internet Protocol"))
|
family = mwan_interface:option(ListValue, "family", translate("Internet Protocol"))
|
||||||
family.default = "ipv4"
|
family.default = "ipv4"
|
||||||
family:value("ipv4", translate("IPv4"))
|
family:value("ipv4", translate("IPv4"))
|
||||||
family:value("ipv6", translate("IPv6"))
|
family:value("ipv6", translate("IPv6"))
|
||||||
|
|
||||||
track_ip = mwan_interface:option(DynamicList, "track_ip", translate("Tracking hostname or IP address"),
|
track_ip = mwan_interface:option(DynamicList, "track_ip", translate("Tracking hostname or IP address"),
|
||||||
translate("This hostname or IP address will be pinged to determine if the link is up or down. Leave blank to assume interface is always online"))
|
translate("This hostname or IP address will be pinged to determine if the link is up or down. Leave blank to assume interface is always online"))
|
||||||
track_ip.datatype = "host"
|
track_ip.datatype = "host"
|
||||||
|
|
||||||
track_method = mwan_interface:option(ListValue, "track_method", translate("Tracking method"))
|
track_method = mwan_interface:option(ListValue, "track_method", translate("Tracking method"))
|
||||||
track_method.default = "ping"
|
track_method.default = "ping"
|
||||||
track_method:value("ping")
|
track_method:value("ping")
|
||||||
track_method:value("arping")
|
track_method:value("arping")
|
||||||
track_method:value("httping")
|
track_method:value("httping")
|
||||||
|
|
||||||
reliability = mwan_interface:option(Value, "reliability", translate("Tracking reliability"),
|
reliability = mwan_interface:option(Value, "reliability", translate("Tracking reliability"),
|
||||||
translate("Acceptable values: 1-100. This many Tracking IP addresses must respond for the link to be deemed up"))
|
translate("Acceptable values: 1-100. This many Tracking IP addresses must respond for the link to be deemed up"))
|
||||||
reliability.datatype = "range(1, 100)"
|
reliability.datatype = "range(1, 100)"
|
||||||
reliability.default = "1"
|
reliability.default = "1"
|
||||||
|
|
||||||
count = mwan_interface:option(ListValue, "count", translate("Ping count"))
|
count = mwan_interface:option(ListValue, "count", translate("Ping count"))
|
||||||
count.default = "1"
|
count.default = "1"
|
||||||
count:value("1")
|
count:value("1")
|
||||||
count:value("2")
|
count:value("2")
|
||||||
count:value("3")
|
count:value("3")
|
||||||
count:value("4")
|
count:value("4")
|
||||||
count:value("5")
|
count:value("5")
|
||||||
|
|
||||||
size = mwan_interface:option(Value, "size", translate("Ping size"))
|
size = mwan_interface:option(Value, "size", translate("Ping size"))
|
||||||
size.default = "56"
|
size.default = "56"
|
||||||
size:value("8")
|
size:value("8")
|
||||||
size:value("24")
|
size:value("24")
|
||||||
size:value("56")
|
size:value("56")
|
||||||
size:value("120")
|
size:value("120")
|
||||||
size:value("248")
|
size:value("248")
|
||||||
size:value("504")
|
size:value("504")
|
||||||
size:value("1016")
|
size:value("1016")
|
||||||
size:value("1472")
|
size:value("1472")
|
||||||
size:value("2040")
|
size:value("2040")
|
||||||
size.datatype = "range(1, 65507)"
|
size.datatype = "range(1, 65507)"
|
||||||
size.rmempty = false
|
size.rmempty = false
|
||||||
size.optional = false
|
size.optional = false
|
||||||
|
|
||||||
timeout = mwan_interface:option(ListValue, "timeout", translate("Ping timeout"))
|
timeout = mwan_interface:option(ListValue, "timeout", translate("Ping timeout"))
|
||||||
timeout.default = "2"
|
timeout.default = "2"
|
||||||
timeout:value("1", translatef("%d second", 1))
|
timeout:value("1", translatef("%d second", 1))
|
||||||
timeout:value("2", translatef("%d seconds", 2))
|
timeout:value("2", translatef("%d seconds", 2))
|
||||||
timeout:value("3", translatef("%d seconds", 3))
|
timeout:value("3", translatef("%d seconds", 3))
|
||||||
timeout:value("4", translatef("%d seconds", 4))
|
timeout:value("4", translatef("%d seconds", 4))
|
||||||
timeout:value("5", translatef("%d seconds", 5))
|
timeout:value("5", translatef("%d seconds", 5))
|
||||||
timeout:value("6", translatef("%d seconds", 6))
|
timeout:value("6", translatef("%d seconds", 6))
|
||||||
timeout:value("7", translatef("%d seconds", 7))
|
timeout:value("7", translatef("%d seconds", 7))
|
||||||
timeout:value("8", translatef("%d seconds", 8))
|
timeout:value("8", translatef("%d seconds", 8))
|
||||||
timeout:value("9", translatef("%d seconds", 9))
|
timeout:value("9", translatef("%d seconds", 9))
|
||||||
timeout:value("10", translatef("%d seconds", 10))
|
timeout:value("10", translatef("%d seconds", 10))
|
||||||
|
|
||||||
interval = mwan_interface:option(ListValue, "interval", translate("Ping interval"))
|
interval = mwan_interface:option(ListValue, "interval", translate("Ping interval"))
|
||||||
interval.default = "5"
|
interval.default = "5"
|
||||||
interval:value("1", translatef("%d second", 1))
|
interval:value("1", translatef("%d second", 1))
|
||||||
interval:value("3", translatef("%d seconds", 3))
|
interval:value("3", translatef("%d seconds", 3))
|
||||||
interval:value("5", translatef("%d seconds", 5))
|
interval:value("5", translatef("%d seconds", 5))
|
||||||
interval:value("10", translatef("%d seconds", 10))
|
interval:value("10", translatef("%d seconds", 10))
|
||||||
interval:value("20", translatef("%d seconds", 20))
|
interval:value("20", translatef("%d seconds", 20))
|
||||||
interval:value("30", translatef("%d seconds", 30))
|
interval:value("30", translatef("%d seconds", 30))
|
||||||
interval:value("60", translatef("%d minute", 1))
|
interval:value("60", translatef("%d minute", 1))
|
||||||
interval:value("300", translatef("%d minutes", 5))
|
interval:value("300", translatef("%d minutes", 5))
|
||||||
interval:value("600", translatef("%d minutes", 10))
|
interval:value("600", translatef("%d minutes", 10))
|
||||||
interval:value("900", translatef("%d minutes", 15))
|
interval:value("900", translatef("%d minutes", 15))
|
||||||
interval:value("1800", translatef("%d minutes", 30))
|
interval:value("1800", translatef("%d minutes", 30))
|
||||||
interval:value("3600", translatef("%d hour", 1))
|
interval:value("3600", translatef("%d hour", 1))
|
||||||
|
|
||||||
failure = mwan_interface:option(Value, "failure_interval", translate("Failure interval"),
|
failure = mwan_interface:option(Value, "failure_interval", translate("Failure interval"),
|
||||||
translate("Ping interval during failure detection"))
|
translate("Ping interval during failure detection"))
|
||||||
failure.default = "5"
|
failure.default = "5"
|
||||||
failure:value("1", translatef("%d second", 1))
|
failure:value("1", translatef("%d second", 1))
|
||||||
failure:value("3", translatef("%d seconds", 3))
|
failure:value("3", translatef("%d seconds", 3))
|
||||||
failure:value("5", translatef("%d seconds", 5))
|
failure:value("5", translatef("%d seconds", 5))
|
||||||
failure:value("10", translatef("%d seconds", 10))
|
failure:value("10", translatef("%d seconds", 10))
|
||||||
failure:value("20", translatef("%d seconds", 20))
|
failure:value("20", translatef("%d seconds", 20))
|
||||||
failure:value("30", translatef("%d seconds", 30))
|
failure:value("30", translatef("%d seconds", 30))
|
||||||
failure:value("60", translatef("%d minute", 1))
|
failure:value("60", translatef("%d minute", 1))
|
||||||
failure:value("300", translatef("%d minutes", 5))
|
failure:value("300", translatef("%d minutes", 5))
|
||||||
failure:value("600", translatef("%d minutes", 10))
|
failure:value("600", translatef("%d minutes", 10))
|
||||||
failure:value("900", translatef("%d minutes", 15))
|
failure:value("900", translatef("%d minutes", 15))
|
||||||
failure:value("1800", translatef("%d minutes", 30))
|
failure:value("1800", translatef("%d minutes", 30))
|
||||||
failure:value("3600", translatef("%d hour", 1))
|
failure:value("3600", translatef("%d hour", 1))
|
||||||
|
|
||||||
keep_failure = mwan_interface:option(Flag, "keep_failure_interval", translate("Keep failure interval"),
|
keep_failure = mwan_interface:option(Flag, "keep_failure_interval", translate("Keep failure interval"),
|
||||||
translate("Keep ping failure interval during failure state"))
|
translate("Keep ping failure interval during failure state"))
|
||||||
keep_failure.default = keep_failure.disabled
|
keep_failure.default = keep_failure.disabled
|
||||||
|
|
||||||
recovery = mwan_interface:option(Value, "recovery_interval", translate("Recovery interval"),
|
recovery = mwan_interface:option(Value, "recovery_interval", translate("Recovery interval"),
|
||||||
translate("Ping interval during failure recovering"))
|
translate("Ping interval during failure recovering"))
|
||||||
recovery.default = "5"
|
recovery.default = "5"
|
||||||
recovery:value("1", translatef("%d second", 1))
|
recovery:value("1", translatef("%d second", 1))
|
||||||
recovery:value("3", translatef("%d seconds", 3))
|
recovery:value("3", translatef("%d seconds", 3))
|
||||||
recovery:value("5", translatef("%d seconds", 5))
|
recovery:value("5", translatef("%d seconds", 5))
|
||||||
recovery:value("10", translatef("%d seconds", 10))
|
recovery:value("10", translatef("%d seconds", 10))
|
||||||
recovery:value("20", translatef("%d seconds", 20))
|
recovery:value("20", translatef("%d seconds", 20))
|
||||||
recovery:value("30", translatef("%d seconds", 30))
|
recovery:value("30", translatef("%d seconds", 30))
|
||||||
recovery:value("60", translatef("%d minute", 1))
|
recovery:value("60", translatef("%d minute", 1))
|
||||||
recovery:value("300", translatef("%d minutes", 5))
|
recovery:value("300", translatef("%d minutes", 5))
|
||||||
recovery:value("600", translatef("%d minutes", 10))
|
recovery:value("600", translatef("%d minutes", 10))
|
||||||
recovery:value("900", translatef("%d minutes", 15))
|
recovery:value("900", translatef("%d minutes", 15))
|
||||||
recovery:value("1800", translatef("%d minutes", 30))
|
recovery:value("1800", translatef("%d minutes", 30))
|
||||||
recovery:value("3600", translatef("%d hour", 1))
|
recovery:value("3600", translatef("%d hour", 1))
|
||||||
|
|
||||||
down = mwan_interface:option(ListValue, "down", translate("Interface down"),
|
down = mwan_interface:option(ListValue, "down", translate("Interface down"),
|
||||||
translate("Interface will be deemed down after this many failed ping tests"))
|
translate("Interface will be deemed down after this many failed ping tests"))
|
||||||
down.default = "3"
|
down.default = "3"
|
||||||
down:value("1")
|
down:value("1")
|
||||||
down:value("2")
|
down:value("2")
|
||||||
down:value("3")
|
down:value("3")
|
||||||
down:value("4")
|
down:value("4")
|
||||||
down:value("5")
|
down:value("5")
|
||||||
down:value("6")
|
down:value("6")
|
||||||
down:value("7")
|
down:value("7")
|
||||||
down:value("8")
|
down:value("8")
|
||||||
down:value("9")
|
down:value("9")
|
||||||
down:value("10")
|
down:value("10")
|
||||||
|
|
||||||
up = mwan_interface:option(ListValue, "up", translate("Interface up"),
|
up = mwan_interface:option(ListValue, "up", translate("Interface up"),
|
||||||
translate("Downed interface will be deemed up after this many successful ping tests"))
|
translate("Downed interface will be deemed up after this many successful ping tests"))
|
||||||
up.default = "3"
|
up.default = "3"
|
||||||
up:value("1")
|
up:value("1")
|
||||||
up:value("2")
|
up:value("2")
|
||||||
up:value("3")
|
up:value("3")
|
||||||
up:value("4")
|
up:value("4")
|
||||||
up:value("5")
|
up:value("5")
|
||||||
up:value("6")
|
up:value("6")
|
||||||
up:value("7")
|
up:value("7")
|
||||||
up:value("8")
|
up:value("8")
|
||||||
up:value("9")
|
up:value("9")
|
||||||
up:value("10")
|
up:value("10")
|
||||||
|
|
||||||
flush = mwan_interface:option(ListValue, "flush_conntrack", translate("Flush conntrack table"),
|
flush = mwan_interface:option(ListValue, "flush_conntrack", translate("Flush conntrack table"),
|
||||||
translate("Flush global firewall conntrack table on interface events"))
|
translate("Flush global firewall conntrack table on interface events"))
|
||||||
flush.default = "never"
|
flush.default = "never"
|
||||||
flush:value("ifup", translate("ifup"))
|
flush:value("ifup", translate("ifup"))
|
||||||
flush:value("ifdown", translate("ifdown"))
|
flush:value("ifdown", translate("ifdown"))
|
||||||
flush:value("never", translate("never"))
|
flush:value("never", translate("never"))
|
||||||
flush:value("always", translate("always"))
|
flush:value("always", translate("always"))
|
||||||
|
|
||||||
metric = mwan_interface:option(DummyValue, "metric", translate("Metric"),
|
metric = mwan_interface:option(DummyValue, "metric", translate("Metric"),
|
||||||
translate("This displays the metric assigned to this interface in /etc/config/network"))
|
translate("This displays the metric assigned to this interface in /etc/config/network"))
|
||||||
metric.rawhtml = true
|
metric.rawhtml = true
|
||||||
function metric.cfgvalue(self, s)
|
function metric.cfgvalue(self, s)
|
||||||
local uci = uci.cursor(nil, "/var/state")
|
local uci = uci.cursor(nil, "/var/state")
|
||||||
local metric = uci:get("network", arg[1], "metric")
|
local metric = uci:get("network", arg[1], "metric")
|
||||||
if metric then
|
if metric then
|
||||||
|
@ -176,6 +174,6 @@ metric = mwan_interface:option(DummyValue, "metric", translate("Metric"),
|
||||||
else
|
else
|
||||||
return "—"
|
return "—"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return m5
|
return m5
|
||||||
|
|
|
@ -7,34 +7,34 @@ mwan_member = m5: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"))
|
||||||
mwan_member.addremove = true
|
mwan_member.addremove = true
|
||||||
mwan_member.dynamic = false
|
mwan_member.dynamic = false
|
||||||
mwan_member.sectionhead = translate("Member")
|
mwan_member.sectionhead = translate("Member")
|
||||||
mwan_member.sortable = true
|
mwan_member.sortable = true
|
||||||
mwan_member.template = "cbi/tblsection"
|
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")
|
m5.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
|
||||||
|
|
||||||
interface = mwan_member:option(DummyValue, "interface", translate("Interface"))
|
interface = mwan_member:option(DummyValue, "interface", translate("Interface"))
|
||||||
interface.rawhtml = true
|
interface.rawhtml = true
|
||||||
function interface.cfgvalue(self, s)
|
function interface.cfgvalue(self, s)
|
||||||
return self.map:get(s, "interface") or "—"
|
return self.map:get(s, "interface") or "—"
|
||||||
end
|
end
|
||||||
|
|
||||||
metric = mwan_member:option(DummyValue, "metric", translate("Metric"))
|
metric = mwan_member:option(DummyValue, "metric", translate("Metric"))
|
||||||
metric.rawhtml = true
|
metric.rawhtml = true
|
||||||
function metric.cfgvalue(self, s)
|
function metric.cfgvalue(self, s)
|
||||||
return self.map:get(s, "metric") or "1"
|
return self.map:get(s, "metric") or "1"
|
||||||
end
|
end
|
||||||
|
|
||||||
weight = mwan_member:option(DummyValue, "weight", translate("Weight"))
|
weight = mwan_member:option(DummyValue, "weight", translate("Weight"))
|
||||||
weight.rawhtml = true
|
weight.rawhtml = true
|
||||||
function weight.cfgvalue(self, s)
|
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 m5
|
||||||
|
|
|
@ -6,8 +6,8 @@ m5 = Map("mwan3", translatef("MWAN Member Configuration - %s", arg[1]))
|
||||||
m5.redirect = dsp.build_url("admin", "network", "mwan", "member")
|
m5.redirect = dsp.build_url("admin", "network", "mwan", "member")
|
||||||
|
|
||||||
mwan_member = m5:section(NamedSection, arg[1], "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",
|
m5.uci:foreach("mwan3", "interface",
|
||||||
|
@ -18,10 +18,10 @@ m5.uci:foreach("mwan3", "interface",
|
||||||
|
|
||||||
metric = mwan_member:option(Value, "metric", translate("Metric"),
|
metric = mwan_member:option(Value, "metric", translate("Metric"),
|
||||||
translate("Acceptable values: 1-256. Defaults to 1 if not set"))
|
translate("Acceptable values: 1-256. Defaults to 1 if not set"))
|
||||||
metric.datatype = "range(1, 256)"
|
metric.datatype = "range(1, 256)"
|
||||||
|
|
||||||
weight = mwan_member:option(Value, "weight", translate("Weight"),
|
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 m5
|
||||||
|
|
|
@ -32,29 +32,27 @@ end
|
||||||
m5 = Map("mwan3", translate("MWAN - Policies"),
|
m5 = Map("mwan3", translate("MWAN - Policies"),
|
||||||
policyError(policyCheck()))
|
policyError(policyCheck()))
|
||||||
|
|
||||||
|
|
||||||
mwan_policy = m5:section(TypedSection, "policy", nil,
|
mwan_policy = m5: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. Interfaces with the same metric load-balance<br />" ..
|
"Member interfaces with lower metrics are used first. Interfaces with the same metric load-balance<br />" ..
|
||||||
"Load-balanced member interfaces distribute more traffic out those with higher weights<br />" ..
|
"Load-balanced member interfaces distribute more traffic out those with higher weights<br />" ..
|
||||||
"Names may contain characters A-Z, a-z, 0-9, _ and no spaces. Names must be 15 characters or less<br />" ..
|
"Names may contain characters A-Z, a-z, 0-9, _ and no spaces. Names must be 15 characters or less<br />" ..
|
||||||
"Policies may not share the same name as configured interfaces, members or rules"))
|
"Policies may not share the same name as configured interfaces, members or rules"))
|
||||||
mwan_policy.addremove = true
|
mwan_policy.addremove = true
|
||||||
mwan_policy.dynamic = false
|
mwan_policy.dynamic = false
|
||||||
mwan_policy.sectionhead = translate("Policy")
|
mwan_policy.sectionhead = translate("Policy")
|
||||||
mwan_policy.sortable = true
|
mwan_policy.sortable = true
|
||||||
mwan_policy.template = "cbi/tblsection"
|
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")
|
m5.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
|
||||||
|
|
||||||
|
|
||||||
use_member = mwan_policy:option(DummyValue, "use_member", translate("Members assigned"))
|
use_member = mwan_policy:option(DummyValue, "use_member", translate("Members assigned"))
|
||||||
use_member.rawhtml = true
|
use_member.rawhtml = true
|
||||||
function use_member.cfgvalue(self, s)
|
function use_member.cfgvalue(self, s)
|
||||||
local memberConfig, memberList = self.map:get(s, "use_member"), ""
|
local memberConfig, memberList = self.map:get(s, "use_member"), ""
|
||||||
if memberConfig then
|
if memberConfig then
|
||||||
for k,v in pairs(memberConfig) do
|
for k,v in pairs(memberConfig) do
|
||||||
|
@ -64,11 +62,11 @@ use_member = mwan_policy:option(DummyValue, "use_member", translate("Members ass
|
||||||
else
|
else
|
||||||
return "—"
|
return "—"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
last_resort = mwan_policy:option(DummyValue, "last_resort", translate("Last resort"))
|
last_resort = mwan_policy:option(DummyValue, "last_resort", translate("Last resort"))
|
||||||
last_resort.rawhtml = true
|
last_resort.rawhtml = true
|
||||||
function last_resort.cfgvalue(self, s)
|
function last_resort.cfgvalue(self, s)
|
||||||
local action = self.map:get(s, "last_resort")
|
local action = self.map:get(s, "last_resort")
|
||||||
if action == "blackhole" then
|
if action == "blackhole" then
|
||||||
return translate("blackhole (drop)")
|
return translate("blackhole (drop)")
|
||||||
|
@ -77,6 +75,6 @@ last_resort = mwan_policy:option(DummyValue, "last_resort", translate("Last reso
|
||||||
else
|
else
|
||||||
return translate("unreachable (reject)")
|
return translate("unreachable (reject)")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return m5
|
return m5
|
||||||
|
|
|
@ -6,8 +6,8 @@ m5 = Map("mwan3", translatef("MWAN Policy Configuration - %s", arg[1]))
|
||||||
m5.redirect = dsp.build_url("admin", "network", "mwan", "policy")
|
m5.redirect = dsp.build_url("admin", "network", "mwan", "policy")
|
||||||
|
|
||||||
mwan_policy = m5:section(NamedSection, arg[1], "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",
|
m5.uci:foreach("mwan3", "member",
|
||||||
|
@ -18,9 +18,9 @@ m5.uci:foreach("mwan3", "member",
|
||||||
|
|
||||||
last_resort = mwan_policy:option(ListValue, "last_resort", translate("Last resort"),
|
last_resort = mwan_policy:option(ListValue, "last_resort", translate("Last resort"),
|
||||||
translate("When all policy members are offline use this behavior for matched traffic"))
|
translate("When all policy members are offline use this behavior for matched traffic"))
|
||||||
last_resort.default = "unreachable"
|
last_resort.default = "unreachable"
|
||||||
last_resort:value("unreachable", translate("unreachable (reject)"))
|
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 m5
|
||||||
|
|
|
@ -47,54 +47,53 @@ mwan_rule = m5:section(TypedSection, "rule", nil,
|
||||||
"Traffic matching a rule, but all WAN interfaces for that policy are down will be blackholed<br />" ..
|
"Traffic matching a rule, but all WAN interfaces for that policy are down will be blackholed<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 />" ..
|
||||||
"Rules may not share the same name as configured interfaces, members or policies"))
|
"Rules may not share the same name as configured interfaces, members or policies"))
|
||||||
mwan_rule.addremove = true
|
mwan_rule.addremove = true
|
||||||
mwan_rule.anonymous = false
|
mwan_rule.anonymous = false
|
||||||
mwan_rule.dynamic = false
|
mwan_rule.dynamic = false
|
||||||
mwan_rule.sectionhead = translate("Rule")
|
mwan_rule.sectionhead = translate("Rule")
|
||||||
mwan_rule.sortable = true
|
mwan_rule.sortable = true
|
||||||
mwan_rule.template = "cbi/tblsection"
|
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")
|
m5.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
|
||||||
|
|
||||||
|
|
||||||
src_ip = mwan_rule:option(DummyValue, "src_ip", translate("Source address"))
|
src_ip = mwan_rule:option(DummyValue, "src_ip", translate("Source address"))
|
||||||
src_ip.rawhtml = true
|
src_ip.rawhtml = true
|
||||||
function src_ip.cfgvalue(self, s)
|
function src_ip.cfgvalue(self, s)
|
||||||
return self.map:get(s, "src_ip") or "—"
|
return self.map:get(s, "src_ip") or "—"
|
||||||
end
|
end
|
||||||
|
|
||||||
src_port = mwan_rule:option(DummyValue, "src_port", translate("Source port"))
|
src_port = mwan_rule:option(DummyValue, "src_port", translate("Source port"))
|
||||||
src_port.rawhtml = true
|
src_port.rawhtml = true
|
||||||
function src_port.cfgvalue(self, s)
|
function src_port.cfgvalue(self, s)
|
||||||
return self.map:get(s, "src_port") or "—"
|
return self.map:get(s, "src_port") or "—"
|
||||||
end
|
end
|
||||||
|
|
||||||
dest_ip = mwan_rule:option(DummyValue, "dest_ip", translate("Destination address"))
|
dest_ip = mwan_rule:option(DummyValue, "dest_ip", translate("Destination address"))
|
||||||
dest_ip.rawhtml = true
|
dest_ip.rawhtml = true
|
||||||
function dest_ip.cfgvalue(self, s)
|
function dest_ip.cfgvalue(self, s)
|
||||||
return self.map:get(s, "dest_ip") or "—"
|
return self.map:get(s, "dest_ip") or "—"
|
||||||
end
|
end
|
||||||
|
|
||||||
dest_port = mwan_rule:option(DummyValue, "dest_port", translate("Destination port"))
|
dest_port = mwan_rule:option(DummyValue, "dest_port", translate("Destination port"))
|
||||||
dest_port.rawhtml = true
|
dest_port.rawhtml = true
|
||||||
function dest_port.cfgvalue(self, s)
|
function dest_port.cfgvalue(self, s)
|
||||||
return self.map:get(s, "dest_port") or "—"
|
return self.map:get(s, "dest_port") or "—"
|
||||||
end
|
end
|
||||||
|
|
||||||
proto = mwan_rule:option(DummyValue, "proto", translate("Protocol"))
|
proto = mwan_rule:option(DummyValue, "proto", translate("Protocol"))
|
||||||
proto.rawhtml = true
|
proto.rawhtml = true
|
||||||
function proto.cfgvalue(self, s)
|
function proto.cfgvalue(self, s)
|
||||||
return self.map:get(s, "proto") or "all"
|
return self.map:get(s, "proto") or "all"
|
||||||
end
|
end
|
||||||
|
|
||||||
use_policy = mwan_rule:option(DummyValue, "use_policy", translate("Policy assigned"))
|
use_policy = mwan_rule:option(DummyValue, "use_policy", translate("Policy assigned"))
|
||||||
use_policy.rawhtml = true
|
use_policy.rawhtml = true
|
||||||
function use_policy.cfgvalue(self, s)
|
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 m5
|
||||||
|
|
|
@ -6,43 +6,42 @@ m5 = Map("mwan3", translatef("MWAN Rule Configuration - %s", arg[1]))
|
||||||
m5.redirect = dsp.build_url("admin", "network", "mwan", "rule")
|
m5.redirect = dsp.build_url("admin", "network", "mwan", "rule")
|
||||||
|
|
||||||
mwan_rule = m5:section(NamedSection, arg[1], "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
|
||||||
|
|
||||||
|
|
||||||
src_ip = mwan_rule:option(Value, "src_ip", translate("Source address"),
|
src_ip = mwan_rule:option(Value, "src_ip", translate("Source address"),
|
||||||
translate("Supports CIDR notation (eg \"192.168.100.0/24\") without quotes"))
|
translate("Supports CIDR notation (eg \"192.168.100.0/24\") without quotes"))
|
||||||
src_ip.datatype = ipaddr
|
src_ip.datatype = ipaddr
|
||||||
|
|
||||||
src_port = mwan_rule:option(Value, "src_port", translate("Source port"),
|
src_port = mwan_rule:option(Value, "src_port", translate("Source port"),
|
||||||
translate("May be entered as a single or multiple port(s) (eg \"22\" or \"80,443\") or as a portrange (eg \"1024:2048\") without quotes"))
|
translate("May be entered as a single or multiple port(s) (eg \"22\" or \"80,443\") or as a portrange (eg \"1024:2048\") without quotes"))
|
||||||
|
|
||||||
dest_ip = mwan_rule:option(Value, "dest_ip", translate("Destination address"),
|
dest_ip = mwan_rule:option(Value, "dest_ip", translate("Destination address"),
|
||||||
translate("Supports CIDR notation (eg \"192.168.100.0/24\") without quotes"))
|
translate("Supports CIDR notation (eg \"192.168.100.0/24\") without quotes"))
|
||||||
dest_ip.datatype = ipaddr
|
dest_ip.datatype = ipaddr
|
||||||
|
|
||||||
dest_port = mwan_rule:option(Value, "dest_port", translate("Destination port"),
|
dest_port = mwan_rule:option(Value, "dest_port", translate("Destination port"),
|
||||||
translate("May be entered as a single or multiple port(s) (eg \"22\" or \"80,443\") or as a portrange (eg \"1024:2048\") without quotes"))
|
translate("May be entered as a single or multiple port(s) (eg \"22\" or \"80,443\") or as a portrange (eg \"1024:2048\") without quotes"))
|
||||||
|
|
||||||
proto = mwan_rule:option(Value, "proto", translate("Protocol"),
|
proto = mwan_rule:option(Value, "proto", translate("Protocol"),
|
||||||
translate("View the content of /etc/protocols for protocol description"))
|
translate("View the content of /etc/protocols for protocol description"))
|
||||||
proto.default = "all"
|
proto.default = "all"
|
||||||
proto.rmempty = false
|
proto.rmempty = false
|
||||||
proto:value("all")
|
proto:value("all")
|
||||||
proto:value("tcp")
|
proto:value("tcp")
|
||||||
proto:value("udp")
|
proto:value("udp")
|
||||||
proto:value("icmp")
|
proto:value("icmp")
|
||||||
proto:value("esp")
|
proto:value("esp")
|
||||||
|
|
||||||
sticky = mwan_rule:option(ListValue, "sticky", translate("Sticky"),
|
sticky = mwan_rule:option(ListValue, "sticky", translate("Sticky"),
|
||||||
translate("Traffic from the same source IP address that previously matched this rule within the sticky timeout period will use the same WAN interface"))
|
translate("Traffic from the same source IP address that previously matched this rule within the sticky timeout period will use the same WAN interface"))
|
||||||
sticky.default = "0"
|
sticky.default = "0"
|
||||||
sticky:value("1", translate("Yes"))
|
sticky:value("1", translate("Yes"))
|
||||||
sticky:value("0", translate("No"))
|
sticky:value("0", translate("No"))
|
||||||
|
|
||||||
timeout = mwan_rule:option(Value, "timeout", translate("Sticky timeout"),
|
timeout = mwan_rule:option(Value, "timeout", translate("Sticky timeout"),
|
||||||
translate("Seconds. Acceptable values: 1-1000000. Defaults to 600 if not set"))
|
translate("Seconds. Acceptable values: 1-1000000. Defaults to 600 if not set"))
|
||||||
timeout.datatype = "range(1, 1000000)"
|
timeout.datatype = "range(1, 1000000)"
|
||||||
|
|
||||||
ipset = mwan_rule:option(Value, "ipset", translate("IPset"),
|
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\")"))
|
||||||
|
|
Loading…
Reference in a new issue