You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.9 KiB

  1. -- ------ extra functions ------ --
  2. function policy_check() -- check to see if this policy's name exceed the maximum of 15 characters
  3. polchar = string.len(arg[1])
  4. if polchar > 15 then
  5. toolong = 1
  6. end
  7. end
  8. function policy_warn() -- display status and warning messages at the top of the page
  9. if toolong == 1 then
  10. return "<font color=\"ff0000\"><strong>WARNING: this policy's name is " .. polchar .. " characters exceeding the maximum of 15!</strong></font>"
  11. else
  12. return ""
  13. end
  14. end
  15. function cbi_add_member(field)
  16. uci.cursor():foreach("mwan3", "member",
  17. function (section)
  18. field:value(section[".name"])
  19. end
  20. )
  21. end
  22. -- ------ policy configuration ------ --
  23. dsp = require "luci.dispatcher"
  24. arg[1] = arg[1] or ""
  25. toolong = 0
  26. policy_check()
  27. m5 = Map("mwan3", translate("MWAN3 Multi-WAN Policy Configuration - " .. arg[1]),
  28. translate(policy_warn()))
  29. m5.redirect = dsp.build_url("admin", "network", "mwan3", "configuration", "policy")
  30. mwan_policy = m5:section(NamedSection, arg[1], "policy", "")
  31. mwan_policy.addremove = false
  32. mwan_policy.dynamic = false
  33. use_member = mwan_policy:option(DynamicList, "use_member", translate("Member used"))
  34. cbi_add_member(use_member)
  35. last_resort = mwan_policy:option(ListValue, "last_resort", translate("Last resort"),
  36. translate("When all policy members are offline use this behavior for matched traffic"))
  37. last_resort.default = "unreachable"
  38. last_resort:value("unreachable", translate("unreachable (reject)"))
  39. last_resort:value("blackhole", translate("blackhole (drop)"))
  40. last_resort:value("default", translate("default (use main routing table)"))
  41. -- ------ currently configured members ------ --
  42. mwan_member = m5:section(TypedSection, "member", translate("Currently Configured Members"))
  43. mwan_member.addremove = false
  44. mwan_member.dynamic = false
  45. mwan_member.sortable = false
  46. mwan_member.template = "cbi/tblsection"
  47. return m5