d9f5ce6d89ede25ad69ddd0eb473bed46776a2a7
[project/luci.git] / applications / luci-fw / luasrc / model / cbi / luci_fw / 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 require("luci.tools.webadmin")
15 m = Map("firewall", translate("Firewall"), translate("The firewall creates zones over your network interfaces to control network traffic flow."))
16
17 s = m:section(TypedSection, "defaults")
18 s.anonymous = true
19
20 s:option(Flag, "syn_flood")
21
22 local di = s:option(Flag, "drop_invalid", translate("Drop invalid packets"))
23 di.rmempty = false
24 function di.cfgvalue(...)
25         return AbstractValue.cfgvalue(...) or "1"
26 end
27
28 p = {}
29 p[1] = s:option(ListValue, "input")
30 p[2] = s:option(ListValue, "output")
31 p[3] = s:option(ListValue, "forward")
32
33 for i, v in ipairs(p) do
34         v:value("REJECT", translate("reject"))
35         v:value("DROP", translate("drop"))
36         v:value("ACCEPT", translate("accept"))
37 end
38
39
40 s = m:section(TypedSection, "zone", translate("Zones"))
41 s.template = "cbi/tblsection"
42 s.anonymous = true
43 s.addremove = true
44
45 name = s:option(Value, "name", translate("Name"))
46 name.size = 8
47
48 p = {}
49 p[1] = s:option(ListValue, "input")
50 p[2] = s:option(ListValue, "output")
51 p[3] = s:option(ListValue, "forward")
52
53 for i, v in ipairs(p) do
54         v:value("REJECT", translate("reject"))
55         v:value("DROP", translate("drop"))
56         v:value("ACCEPT", translate("accept"))
57 end
58
59 s:option(Flag, "masq")
60
61 net = s:option(MultiValue, "network")
62 net.widget = "select"
63 net.rmempty = true
64 luci.tools.webadmin.cbi_add_networks(net)
65
66 function net.cfgvalue(self, section)
67         local value = MultiValue.cfgvalue(self, section)
68         return value or name:cfgvalue(section)
69 end
70
71 return m