zones.lua 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. o.default = o.disabled
  16. p = {
  17. s:option(ListValue, "input", translate("Input")),
  18. s:option(ListValue, "output", translate("Output")),
  19. s:option(ListValue, "forward", translate("Forward"))
  20. }
  21. for i, v in ipairs(p) do
  22. v:value("REJECT", translate("reject"))
  23. v:value("DROP", translate("drop"))
  24. v:value("ACCEPT", translate("accept"))
  25. end
  26. s = m:section(TypedSection, "zone", translate("Zones"))
  27. s.template = "cbi/tblsection"
  28. s.anonymous = true
  29. s.addremove = true
  30. s.extedit = ds.build_url("admin", "network", "firewall", "zones", "%s")
  31. function s.create(self)
  32. local z = fw:new_zone()
  33. if z then
  34. luci.http.redirect(
  35. ds.build_url("admin", "network", "firewall", "zones", z.sid)
  36. )
  37. end
  38. end
  39. function s.remove(self, section)
  40. return fw:del_zone(section)
  41. end
  42. o = s:option(DummyValue, "_info", translate("Zone ⇒ Forwardings"))
  43. o.template = "cbi/firewall_zoneforwards"
  44. o.cfgvalue = function(self, section)
  45. return self.map:get(section, "name")
  46. end
  47. p = {
  48. s:option(ListValue, "input", translate("Input")),
  49. s:option(ListValue, "output", translate("Output")),
  50. s:option(ListValue, "forward", translate("Forward"))
  51. }
  52. for i, v in ipairs(p) do
  53. v:value("REJECT", translate("reject"))
  54. v:value("DROP", translate("drop"))
  55. v:value("ACCEPT", translate("accept"))
  56. end
  57. s:option(Flag, "masq", translate("Masquerading"))
  58. s:option(Flag, "mtu_fix", translate("MSS clamping"))
  59. return m