zones.lua 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. -- Copyright 2008 Steven Barth <steven@midlink.org>
  2. -- Licensed to the public under the Apache License 2.0.
  3. local ds = require "luci.dispatcher"
  4. local fw = require "luci.model.firewall"
  5. local m, s, o, p, i, v
  6. m = Map("firewall",
  7. translate("Firewall - Zone Settings"),
  8. translate("The firewall creates zones over your network interfaces to control network traffic flow."))
  9. fw.init(m.uci)
  10. s = m:section(TypedSection, "defaults", translate("General Settings"))
  11. s.anonymous = true
  12. s.addremove = false
  13. s:option(Flag, "syn_flood", translate("Enable SYN-flood protection"))
  14. o = s:option(Flag, "drop_invalid", translate("Drop invalid packets"))
  15. p = {
  16. s:option(ListValue, "input", translate("Input")),
  17. s:option(ListValue, "output", translate("Output")),
  18. s:option(ListValue, "forward", translate("Forward"))
  19. }
  20. for i, v in ipairs(p) do
  21. v:value("REJECT", translate("reject"))
  22. v:value("DROP", translate("drop"))
  23. v:value("ACCEPT", translate("accept"))
  24. end
  25. s = m:section(TypedSection, "zone", translate("Zones"))
  26. s.template = "cbi/tblsection"
  27. s.anonymous = true
  28. s.addremove = true
  29. s.extedit = ds.build_url("admin", "network", "firewall", "zones", "%s")
  30. function s.create(self)
  31. local z = fw:new_zone()
  32. if z then
  33. luci.http.redirect(
  34. ds.build_url("admin", "network", "firewall", "zones", z.sid)
  35. )
  36. end
  37. end
  38. function s.remove(self, section)
  39. return fw:del_zone(section)
  40. end
  41. o = s:option(DummyValue, "_info", translate("Zone ⇒ Forwardings"))
  42. o.template = "cbi/firewall_zoneforwards"
  43. o.cfgvalue = function(self, section)
  44. return self.map:get(section, "name")
  45. end
  46. p = {
  47. s:option(ListValue, "input", translate("Input")),
  48. s:option(ListValue, "output", translate("Output")),
  49. s:option(ListValue, "forward", translate("Forward"))
  50. }
  51. for i, v in ipairs(p) do
  52. v:value("REJECT", translate("reject"))
  53. v:value("DROP", translate("drop"))
  54. v:value("ACCEPT", translate("accept"))
  55. end
  56. s:option(Flag, "masq", translate("Masquerading"))
  57. s:option(Flag, "mtu_fix", translate("MSS clamping"))
  58. return m