summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-fw/luasrc/model/cbi/luci_fw/rrule.lua
blob: d3fc589f892f66762137680a8b528d47a49740e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
--[[
LuCI - Lua Configuration Interface

Copyright 2008 Steven Barth <steven@midlink.org>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

	http://www.apache.org/licenses/LICENSE-2.0

$Id$
]]--
require("luci.sys")
arg[1] = arg[1] or ""

m = Map("firewall", translate("fw_redirect"), translate("fw_redirect_desc"))


s = m:section(NamedSection, arg[1], "redirect", "")
s.anonymous = true
s.addremove = false

back = s:option(DummyValue, "_overview", translate("overview"))
back.value = ""
back.titleref = luci.dispatcher.build_url("admin", "network", "firewall", "redirect")

name = s:option(Value, "_name", translate("name"))
name.rmempty = true
name.size = 10

iface = s:option(ListValue, "src", translate("fw_zone"))
iface.default = "wan"
luci.model.uci.cursor():foreach("firewall", "zone",
	function (section)
		iface:value(section.name)
	end)
	
s:option(Value, "src_ip", translate("firewall_redirect_srcip")).optional = true
s:option(Value, "src_mac", translate("firewall_redirect_srcmac")).optional = true

sport = s:option(Value, "src_port", translate("firewall_redirect_srcport"))
sport:depends("proto", "tcp")
sport:depends("proto", "udp")
sport:depends("proto", "tcpudp")

proto = s:option(ListValue, "proto", translate("protocol"))
proto.optional = true
proto:value("")
proto:value("tcp", "TCP")
proto:value("udp", "UDP")
proto:value("tcpudp", "TCP+UDP")

dport = s:option(Value, "src_dport", translate("firewall_redirect_srcdport"))
dport.size = 5
dport:depends("proto", "tcp")
dport:depends("proto", "udp")
dport:depends("proto", "tcpudp")

to = s:option(Value, "dest_ip", translate("firewall_redirect_destip"))
for i, dataset in ipairs(luci.sys.net.arptable()) do
	to:value(dataset["IP address"])
end

toport = s:option(Value, "dest_port", translate("firewall_redirect_destport"))
toport.optional = true
toport.size = 5

return m