applications/luci-fw: Reworked to use the new native UCI-based firewall configuration
[project/luci.git] / applications / luci-fw / luasrc / model / cbi / luci_fw / firewall.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_rules"), translate("fw_rules1"))
15
16 s = m:section(TypedSection, "rule", "")
17 s.addremove = true
18 s.anonymous = true
19
20 iface = s:option(ListValue, "src")
21 iface:value("")
22 iface.rmempty = true
23
24 oface = s:option(ListValue, "dest")
25 oface.optional = true
26
27 luci.model.uci.foreach("firewall", "zone",
28         function (section)
29                 iface:value(section.name)
30                 oface:value(section.name)
31         end)
32
33 proto = s:option(ListValue, "proto", translate("protocol"))
34 proto.optional = true
35 proto:value("")
36 proto:value("tcp", "TCP")
37 proto:value("udp", "UDP")
38 proto:value("icmp", "ICMP")
39
40 s:option(Value, "src_ip").optional = true
41 s:option(Value, "dest_ip").optional = true
42 s:option(Value, "src_mac").optional = true
43
44 sport = s:option(Value, "src_port")
45 sport.optional = true
46 sport:depends("proto", "tcp")
47 sport:depends("proto", "udp")
48
49 dport = s:option(Value, "dest_port")
50 dport.optional = true
51 dport:depends("proto", "tcp")
52 dport:depends("proto", "udp")
53
54 jump = s:option(ListValue, "target")
55 jump.rmempty = true
56 jump:value("DROP", translate("fw_drop"))
57 jump:value("ACCEPT", translate("fw_accept"))
58 jump:value("REJECT", translate("fw_reject"))
59
60
61 return m