applications: rename luci-fw to luci-firewall
[project/luci.git] / applications / luci-firewall / luasrc / model / cbi / luci_fw / trule.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 arg[1] = arg[1] or ""
15 m = Map("firewall", translate("Advanced Rules"),
16 translate("Advanced rules let you customize the firewall to your " ..
17 "needs. Only new connections will be matched. Packets " ..
18 "belonging to already open connections are automatically " ..
19 "allowed to pass the firewall."))
20
21 s = m:section(NamedSection, arg[1], "rule", "")
22 s.anonymous = true
23 s.addremove = false
24
25 back = s:option(DummyValue, "_overview", translate("Overview"))
26 back.value = ""
27 back.titleref = luci.dispatcher.build_url("admin", "network", "firewall", "rule")
28
29
30 name = s:option(Value, "_name", translate("Name").." "..translate("(optional)"))
31 name.rmempty = true
32
33 iface = s:option(ListValue, "src", translate("Source zone"))
34 iface.rmempty = true
35
36 oface = s:option(ListValue, "dest", translate("Destination zone"))
37 oface:value("", translate("any"))
38 oface.rmempty = true
39
40 luci.model.uci.cursor():foreach("firewall", "zone",
41 function (section)
42 iface:value(section.name)
43 oface:value(section.name)
44 end)
45
46 proto = s:option(Value, "proto", translate("Protocol"))
47 proto.optional = true
48 proto:value("")
49 proto:value("all", translate("Any"))
50 proto:value("tcpudp", "TCP+UDP")
51 proto:value("tcp", "TCP")
52 proto:value("udp", "UDP")
53 proto:value("icmp", "ICMP")
54
55 s:option(Value, "src_ip", translate("Source address")).optional = true
56 s:option(Value, "dest_ip", translate("Destination address")).optional = true
57 s:option(Value, "src_mac", translate("Source MAC-address")).optional = true
58
59 sport = s:option(Value, "src_port", translate("Source port"))
60 sport:depends("proto", "tcp")
61 sport:depends("proto", "udp")
62 sport:depends("proto", "tcpudp")
63
64 dport = s:option(Value, "dest_port", translate("Destination port"))
65 dport:depends("proto", "tcp")
66 dport:depends("proto", "udp")
67 dport:depends("proto", "tcpudp")
68
69 jump = s:option(ListValue, "target", translate("Action"))
70 jump.rmempty = true
71 jump.default = "ACCEPT"
72 jump:value("DROP", translate("drop"))
73 jump:value("ACCEPT", translate("accept"))
74 jump:value("REJECT", translate("reject"))
75
76
77 return m