2 LuCI - Lua Configuration Interface
4 Copyright 2011 Jo-Philipp Wich <xm@subsignal.org>
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
10 http://www.apache.org/licenses/LICENSE-2.0
15 local sys = require "luci.sys"
16 local dsp = require "luci.dispatcher"
17 local ft = require "luci.tools.firewall"
24 translate("Firewall - Port Forwards"),
25 translate("This page allows you to change advanced properties of the port \
26 forwarding entry. In most cases there is no need to modify \
29 m.redirect = dsp.build_url("admin/network/firewall/forwards")
31 if m.uci:get("firewall", arg[1]) ~= "redirect" then
32 luci.http.redirect(m.redirect)
35 local name = m:get(arg[1], "name") or m:get(arg[1], "_name")
36 if not name or #name == 0 then
37 name = translate("(Unnamed Entry)")
39 m.title = "%s - %s" %{ translate("Firewall - Port Forwards"), name }
42 s = m:section(NamedSection, arg[1], "redirect", "")
46 ft.opt_enabled(s, Button)
47 ft.opt_name(s, Value, translate("Name"))
50 o = s:option(Value, "proto", translate("Protocol"))
51 o:value("tcp udp", "TCP+UDP")
54 o:value("icmp", "ICMP")
56 function o.cfgvalue(...)
57 local v = Value.cfgvalue(...)
58 if not v or v == "tcpudp" then
65 o = s:option(Value, "src", translate("Source zone"))
68 o.template = "cbi/firewall_zonelist"
71 o = s:option(DynamicList, "src_mac",
72 translate("Source MAC address"),
73 translate("Only match incoming traffic from these MACs."))
75 o.datatype = "neg(macaddr)"
76 o.placeholder = translate("any")
78 luci.sys.net.mac_hints(function(mac, name)
79 o:value(mac, "%s (%s)" %{ mac, name })
83 o = s:option(Value, "src_ip",
84 translate("Source IP address"),
85 translate("Only match incoming traffic from this IP or range."))
87 o.datatype = "neg(ip4addr)"
88 o.placeholder = translate("any")
90 luci.sys.net.ipv4_hints(function(ip, name)
91 o:value(ip, "%s (%s)" %{ ip, name })
95 o = s:option(Value, "src_port",
96 translate("Source port"),
97 translate("Only match incoming traffic originating from the given source port or port range on the client host"))
99 o.datatype = "neg(portrange)"
100 o.placeholder = translate("any")
103 o = s:option(Value, "src_dip",
104 translate("External IP address"),
105 translate("Only match incoming traffic directed at the given IP address."))
107 luci.sys.net.ipv4_hints(function(ip, name)
108 o:value(ip, "%s (%s)" %{ ip, name })
113 o.datatype = "neg(ip4addr)"
114 o.placeholder = translate("any")
117 o = s:option(Value, "src_dport", translate("External port"),
118 translate("Match incoming traffic directed at the given " ..
119 "destination port or port range on this host"))
120 o.datatype = "neg(portrange)"
124 o = s:option(Value, "dest", translate("Internal zone"))
127 o.template = "cbi/firewall_zonelist"
130 o = s:option(Value, "dest_ip", translate("Internal IP address"),
131 translate("Redirect matched incoming traffic to the specified \
133 o.datatype = "ip4addr"
135 luci.sys.net.ipv4_hints(function(ip, name)
136 o:value(ip, "%s (%s)" %{ ip, name })
140 o = s:option(Value, "dest_port",
141 translate("Internal port"),
142 translate("Redirect matched incoming traffic to the given port on \
144 o.placeholder = translate("any")
145 o.datatype = "portrange"
148 o = s:option(Flag, "reflection", translate("Enable NAT Loopback"))
150 o.default = o.enabled
151 o.cfgvalue = function(...)
152 return Flag.cfgvalue(...) or "1"
156 s:option(Value, "extra",
157 translate("Extra arguments"),
158 translate("Passes additional arguments to iptables. Use with care!"))