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