Merge pull request #1818 from dibdot/lxc_fix
[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
23 p = {
24         s:option(ListValue, "input", translate("Input")),
25         s:option(ListValue, "output", translate("Output")),
26         s:option(ListValue, "forward", translate("Forward"))
27 }
28
29 for i, v in ipairs(p) do
30         v:value("REJECT", translate("reject"))
31         v:value("DROP", translate("drop"))
32         v:value("ACCEPT", translate("accept"))
33 end
34
35
36 s = m:section(TypedSection, "zone", translate("Zones"))
37 s.template = "cbi/tblsection"
38 s.anonymous = true
39 s.addremove = true
40 s.extedit   = ds.build_url("admin", "network", "firewall", "zones", "%s")
41
42 function s.create(self)
43         local z = fw:new_zone()
44         if z then
45                 luci.http.redirect(
46                         ds.build_url("admin", "network", "firewall", "zones", z.sid)
47                 )
48         end
49 end
50
51 function s.remove(self, section)
52         return fw:del_zone(section)
53 end
54
55 o = s:option(DummyValue, "_info", translate("Zone ⇒ Forwardings"))
56 o.template = "cbi/firewall_zoneforwards"
57 o.cfgvalue = function(self, section)
58         return self.map:get(section, "name")
59 end
60
61 p = {
62         s:option(ListValue, "input", translate("Input")),
63         s:option(ListValue, "output", translate("Output")),
64         s:option(ListValue, "forward", translate("Forward"))
65 }
66
67 for i, v in ipairs(p) do
68         v:value("REJECT", translate("reject"))
69         v:value("DROP", translate("drop"))
70         v:value("ACCEPT", translate("accept"))
71 end
72
73 s:option(Flag, "masq", translate("Masquerading"))
74 s:option(Flag, "mtu_fix", translate("MSS clamping"))
75
76 return m