Redesigned firewall configuration
[project/luci.git] / applications / luci-fw / luasrc / model / cbi / luci_fw / redirect.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.sys")
15 m = Map("firewall", translate("fw_redirect"), translate("fw_redirect_desc"))
16
17
18 s = m:section(TypedSection, "redirect", "")
19 s.template  = "cbi/tblsection"
20 s.addremove = true
21 s.anonymous = true
22 s.extedit   = luci.dispatcher.build_url("admin", "network", "firewall", "redirect", "%s")
23
24 name = s:option(Value, "_name", translate("name"), translate("cbi_optional"))
25 name.size = 10
26
27 iface = s:option(ListValue, "src", translate("fw_zone"))
28 iface.default = "wan"
29 luci.model.uci.cursor():foreach("firewall", "zone",
30         function (section)
31                 iface:value(section.name)
32         end)
33
34 proto = s:option(ListValue, "proto", translate("protocol"))
35 proto:value("tcp", "TCP")
36 proto:value("udp", "UDP")
37 proto:value("tcpudp", "TCP+UDP")
38
39 dport = s:option(Value, "src_dport")
40 dport.size = 5
41
42 to = s:option(Value, "dest_ip")
43 for i, dataset in ipairs(luci.sys.net.arptable()) do
44         to:value(dataset["IP address"])
45 end
46
47 toport = s:option(Value, "dest_port")
48 toport.size = 5
49
50 return m