luci-app-mwan3: add new config options initial_state and keep_failure_interval
[project/luci.git] / applications / luci-app-mwan3 / luasrc / model / cbi / mwan / interfaceconfig.lua
index f4b207c..ab44ba6 100644 (file)
@@ -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,14 +102,20 @@ enabled = mwan_interface:option(ListValue, "enabled", translate("Enabled"))
        enabled:value("1", translate("Yes"))
        enabled:value("0", translate("No"))
 
+initial_state = mwan_interface:option(ListValue, "initial_state", translate("Initial state"),
+       translate("Expect interface state on up event"))
+       initial_state.default = "online"
+       initial_state:value("online", translate("Online"))
+       initial_state:value("offline", translate("Offline"))
+
 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"
+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"))
+       track_ip.datatype = "host"
 
 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"))
@@ -167,6 +173,42 @@ interval = mwan_interface:option(ListValue, "interval", translate("Ping interval
        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))
+
+keep_failure = mwan_interface:option(Flag, "keep_failure_interval", translate("Keep failure interval"),
+       translate("Keep ping failure interval during failure state"))
+       keep_failure.default = keep_failure.disabled
+
+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"))
        down.default = "3"