2008-06-08 15:36:57 +00:00
|
|
|
--[[
|
|
|
|
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$
|
|
|
|
]]--
|
2008-10-03 16:04:09 +00:00
|
|
|
arg[1] = arg[1] or ""
|
|
|
|
m = Map("firewall", translate("firewall_rule"), translate("firewall_rule_desc"))
|
2008-05-14 09:17:09 +00:00
|
|
|
|
2008-10-03 16:04:09 +00:00
|
|
|
s = m:section(NamedSection, arg[1], "rule", "")
|
2008-05-14 09:17:09 +00:00
|
|
|
s.anonymous = true
|
|
|
|
|
2008-10-03 16:04:09 +00:00
|
|
|
name = s:option(Value, "_name", translate("name")..translate("cbi_optional"))
|
|
|
|
name.rmempty = true
|
|
|
|
|
|
|
|
iface = s:option(ListValue, "src", translate("firewall_rule_src"))
|
2008-08-04 23:36:33 +00:00
|
|
|
iface.rmempty = true
|
2008-05-14 09:17:09 +00:00
|
|
|
|
2008-10-03 16:04:09 +00:00
|
|
|
oface = s:option(ListValue, "dest", translate("firewall_rule_dest"))
|
2008-09-30 20:53:46 +00:00
|
|
|
oface:value("")
|
2008-05-14 18:16:51 +00:00
|
|
|
oface.optional = true
|
|
|
|
|
2008-08-26 23:00:44 +00:00
|
|
|
luci.model.uci.cursor():foreach("firewall", "zone",
|
2008-06-05 19:16:38 +00:00
|
|
|
function (section)
|
2008-08-04 23:36:33 +00:00
|
|
|
iface:value(section.name)
|
|
|
|
oface:value(section.name)
|
2008-06-05 19:16:38 +00:00
|
|
|
end)
|
2008-05-14 09:17:09 +00:00
|
|
|
|
2008-06-09 10:10:29 +00:00
|
|
|
proto = s:option(ListValue, "proto", translate("protocol"))
|
2008-05-14 09:17:09 +00:00
|
|
|
proto.optional = true
|
|
|
|
proto:value("")
|
2008-08-27 19:20:43 +00:00
|
|
|
proto:value("tcpudp", "TCP+UDP")
|
2008-05-14 09:17:09 +00:00
|
|
|
proto:value("tcp", "TCP")
|
|
|
|
proto:value("udp", "UDP")
|
2008-08-04 23:36:33 +00:00
|
|
|
proto:value("icmp", "ICMP")
|
2008-05-14 09:17:09 +00:00
|
|
|
|
2008-10-03 16:04:09 +00:00
|
|
|
s:option(Value, "src_ip", translate("firewall_rule_srcip")).optional = true
|
|
|
|
s:option(Value, "dest_ip", translate("firewall_rule_destip")).optional = true
|
|
|
|
s:option(Value, "src_mac", translate("firewall_rule_srcmac")).optional = true
|
2008-05-14 09:17:09 +00:00
|
|
|
|
2008-10-03 16:04:09 +00:00
|
|
|
sport = s:option(Value, "src_port", translate("firewall_rule_srcport"))
|
2008-05-14 09:17:09 +00:00
|
|
|
sport.optional = true
|
|
|
|
sport:depends("proto", "tcp")
|
|
|
|
sport:depends("proto", "udp")
|
2008-09-02 11:27:00 +00:00
|
|
|
sport:depends("proto", "tcpudp")
|
2008-05-14 09:17:09 +00:00
|
|
|
|
2008-10-03 16:04:09 +00:00
|
|
|
dport = s:option(Value, "dest_port", translate("firewall_rule_destport"))
|
2008-05-14 09:17:09 +00:00
|
|
|
dport.optional = true
|
|
|
|
dport:depends("proto", "tcp")
|
|
|
|
dport:depends("proto", "udp")
|
2008-09-02 11:27:00 +00:00
|
|
|
dport:depends("proto", "tcpudp")
|
2008-05-14 09:17:09 +00:00
|
|
|
|
2008-10-03 16:04:09 +00:00
|
|
|
jump = s:option(ListValue, "target", translate("firewall_rule_target"))
|
2008-05-14 09:17:09 +00:00
|
|
|
jump.rmempty = true
|
2008-09-30 20:53:46 +00:00
|
|
|
jump.default = "ACCEPT"
|
2008-08-04 23:36:33 +00:00
|
|
|
jump:value("DROP", translate("fw_drop"))
|
2008-06-08 15:36:57 +00:00
|
|
|
jump:value("ACCEPT", translate("fw_accept"))
|
|
|
|
jump:value("REJECT", translate("fw_reject"))
|
2008-05-14 09:17:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
return m
|