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