2 LuCI - Lua Configuration Interface
4 Copyright 2008 Steven Barth <steven@midlink.org>
5 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
16 m = Map("firewall", translate("Traffic Control"))
17 s = m:section(TypedSection, "forwarding", translate("Zone-to-Zone traffic"), translate("Here you can specify which network traffic is allowed to flow between network zones. Only new connections will be matched. Packets belonging to already open connections are automatically allowed to pass the firewall. If you experience occasional connection problems try enabling MSS Clamping otherwise disable it for performance reasons."))
18 s.template = "cbi/tblsection"
22 iface = s:option(ListValue, "src", translate("Source"))
23 oface = s:option(ListValue, "dest", translate("Destination"))
25 luci.model.uci.cursor():foreach("firewall", "zone",
27 iface:value(section.name)
28 oface:value(section.name)
33 s = m:section(TypedSection, "rule")
36 s.template = "cbi/tblsection"
37 s.extedit = luci.dispatcher.build_url("admin", "network", "firewall", "rule", "%s")
38 s.defaults.target = "ACCEPT"
42 function s.create(self, section)
43 created = TypedSection.create(self, section)
46 function s.parse(self, ...)
47 TypedSection.parse(self, ...)
49 m.uci:save("firewall")
50 luci.http.redirect(luci.dispatcher.build_url(
51 "admin", "network", "firewall", "rule", created
56 s:option(DummyValue, "_name", translate("Name"))
57 s:option(DummyValue, "proto", translate("Protocol"))
59 src = s:option(DummyValue, "src", translate("Source"))
60 function src.cfgvalue(self, s)
62 self.map:get(s, "src") or "*",
63 self.map:get(s, "src_ip") or "0.0.0.0/0",
64 self.map:get(s, "src_port") or "*"
68 dest = s:option(DummyValue, "dest", translate("Destination"))
69 function dest.cfgvalue(self, s)
71 self.map:get(s, "dest") or translate("Device"),
72 self.map:get(s, "dest_ip") or "0.0.0.0/0",
73 self.map:get(s, "dest_port") or "*"
78 s:option(DummyValue, "target")