libs/web: move XHR apply callback into subtemplate
[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("Traffic Redirection"),
16         translate("Traffic redirection allows you to change the " ..
17                 "destination address of forwarded packets."))
18
19
20 s = m:section(TypedSection, "redirect", "")
21 s.template  = "cbi/tblsection"
22 s.addremove = true
23 s.anonymous = true
24 s.extedit   = luci.dispatcher.build_url("admin", "network", "firewall", "redirect", "%s")
25
26 name = s:option(Value, "_name", translate("Name"), translate("(optional)"))
27 name.size = 10
28
29 iface = s:option(ListValue, "src", translate("Zone"))
30 iface.default = "wan"
31 luci.model.uci.cursor():foreach("firewall", "zone",
32         function (section)
33                 iface:value(section.name)
34         end)
35
36 proto = s:option(ListValue, "proto", translate("Protocol"))
37 proto:value("tcp", "TCP")
38 proto:value("udp", "UDP")
39 proto:value("tcpudp", "TCP+UDP")
40
41 dport = s:option(Value, "src_dport", translate("Source port"))
42 dport.size = 5
43
44 to = s:option(Value, "dest_ip", translate("Destination IP"))
45 for i, dataset in ipairs(luci.sys.net.arptable()) do
46         to:value(dataset["IP address"])
47 end
48
49 toport = s:option(Value, "dest_port", translate("Destination port"))
50 toport.size = 5
51
52 return m