LuCI - Lua Configuration Interface
Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2010 Jo-Philipp Wich <xm@subsignal.org>
+Copyright 2010-2012 Jo-Philipp Wich <xm@subsignal.org>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
http://www.apache.org/licenses/LICENSE-2.0
-$Id$
]]--
local sys = require "luci.sys"
local dsp = require "luci.dispatcher"
local nxo = require "nixio"
+local ft = require "luci.tools.firewall"
local nw = require "luci.model.network"
local m, s, o, k, v
--
elseif rule_type == "redirect" then
- local name = m:get(arg[1], "_name")
+ local name = m:get(arg[1], "name") or m:get(arg[1], "_name")
if not name or #name == 0 then
name = translate("(Unnamed SNAT)")
else
s.addremove = false
- o = s:option(Value, "_name", translate("Name"))
- o.rmempty = true
- o.size = 10
+ ft.opt_enabled(s, Button)
+ ft.opt_name(s, Value, translate("Name"))
o = s:option(Value, "proto",
o.datatype = "neg(macaddr)"
o.placeholder = translate("any")
+ luci.sys.net.mac_hints(function(mac, name)
+ o:value(mac, "%s (%s)" %{ mac, name })
+ end)
+
o = s:option(Value, "src_ip", translate("Source IP address"))
o.rmempty = true
- o.datatype = "neg(ip4addr)"
+ o.datatype = "neg(ipaddr)"
o.placeholder = translate("any")
+ luci.sys.net.ipv4_hints(function(ip, name)
+ o:value(ip, "%s (%s)" %{ ip, name })
+ end)
+
o = s:option(Value, "src_port",
translate("Source port"),
o = s:option(Value, "dest_ip", translate("Destination IP address"))
o.datatype = "neg(ip4addr)"
- for i, dataset in ipairs(luci.sys.net.arptable()) do
- o:value(dataset["IP address"])
- end
+ luci.sys.net.ipv4_hints(function(ip, name)
+ o:value(ip, "%s (%s)" %{ ip, name })
+ end)
o = s:option(Value, "dest_port",
o.rmempty = true
o.placeholder = translate("any")
- o.datatype = "portrange"
+ o.datatype = "neg(portrange)"
o = s:option(Value, "src_dip",
o.placeholder = translate('Do not rewrite')
+ s:option(Value, "extra",
+ translate("Extra arguments"),
+ translate("Passes additional arguments to iptables. Use with care!"))
+
+
--
-- Rule
--
else
+ local name = m:get(arg[1], "name") or m:get(arg[1], "_name")
+ if not name or #name == 0 then
+ name = translate("(Unnamed Rule)")
+ end
+
+ m.title = "%s - %s" %{ translate("Firewall - Traffic Rules"), name }
+
+
s = m:section(NamedSection, arg[1], "rule", "")
s.anonymous = true
s.addremove = false
- s:option(Value, "_name", translate("Name").." "..translate("(optional)"))
+ ft.opt_enabled(s, Button)
+ ft.opt_name(s, Value, translate("Name"))
o = s:option(ListValue, "family", translate("Restrict to address family"))
o.datatype = "list(macaddr)"
o.placeholder = translate("any")
+ luci.sys.net.mac_hints(function(mac, name)
+ o:value(mac, "%s (%s)" %{ mac, name })
+ end)
+
o = s:option(Value, "src_ip", translate("Source address"))
o.datatype = "neg(ipaddr)"
o.placeholder = translate("any")
+ luci.sys.net.ipv4_hints(function(ip, name)
+ o:value(ip, "%s (%s)" %{ ip, name })
+ end)
+
o = s:option(Value, "src_port", translate("Source port"))
- o.datatype = "list(neg,portrange)"
+ o.datatype = "list(neg(portrange))"
o.placeholder = translate("any")
o.datatype = "neg(ipaddr)"
o.placeholder = translate("any")
+ luci.sys.net.ipv4_hints(function(ip, name)
+ o:value(ip, "%s (%s)" %{ ip, name })
+ end)
+
o = s:option(Value, "dest_port", translate("Destination port"))
- o.datatype = "list(neg,portrange)"
+ o.datatype = "list(neg(portrange))"
o.placeholder = translate("any")
o:value("ACCEPT", translate("accept"))
o:value("REJECT", translate("reject"))
o:value("NOTRACK", translate("don't track"))
+
+
+ s:option(Value, "extra",
+ translate("Extra arguments"),
+ translate("Passes additional arguments to iptables. Use with care!"))
end
return m