1a765abb74f20d0f6ece3f1b48c504a7ceeca711
[project/luci.git] / applications / luci-fw / luasrc / model / cbi / luci_fw / general.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 m = Map("firewall", translate("fw_fw"), translate("fw_fw1"))
15
16 s = m:section(TypedSection, "defaults")
17 s.anonymous = true
18
19 s:option(Flag, "syn_flood")
20
21 p = {}
22 p[1] = s:option(ListValue, "input")
23 p[2] = s:option(ListValue, "output")
24 p[3] = s:option(ListValue, "forward")
25
26 for i, v in ipairs(p) do
27         v:value("DROP", translate("fw_drop"))
28         v:value("ACCEPT", translate("fw_accept"))
29 end
30
31
32 s = m:section(TypedSection, "zone", translate("fw_zones"))
33 s.template = "cbi/tblsection"
34 s.anonymous = true
35 s.addremove = true
36
37 name = s:option(Value, "name", translate("name"))
38 name.size = 8
39
40 p = {}
41 p[1] = s:option(ListValue, "input")
42 p[2] = s:option(ListValue, "output")
43 p[3] = s:option(ListValue, "forward")
44
45 for i, v in ipairs(p) do
46         v:value("DROP", translate("fw_drop"))
47         v:value("ACCEPT", translate("fw_accept"))
48 end
49
50 s:option(Flag, "masq")
51
52 net = s:option(MultiValue, "network")
53 net.widget = "select"
54 net.rmempty = true
55 luci.model.uci.foreach("network", "interface",
56         function (section)
57                 if section[".name"] ~= "loopback" then
58                         net:value(section[".name"])
59                 end
60         end)
61         
62 function net.cfgvalue(self, section)
63         local value = MultiValue.cfgvalue(self, section)
64         return value or name:cfgvalue(section)
65 end
66
67 return m