return zones
end
-function get_zones_by_network(self, net)
- local zones = { }
+function get_zone_by_network(self, net)
+ local z
ub.uci:foreach("firewall", "zone",
function(s)
- if s.name then
+ if s.name and net then
local n
for _, n in ipairs(ub:list(s.network or s.name)) do
if n == net then
- zones[#zones+1] = zone(s['.name'])
- return true
+ z = s['.name']
+ return false
end
end
end
end)
- return zones
+ return z and zone(z)
end
function del_zone(self, n)
local s = ub.uci:section("firewall", "forwarding", nil, {
src = self:name(),
dest = dest,
- mtu_fix = with_mtu_fix and true or false
+ mtu_fix = with_mtu_fix and "1" or "0"
})
return s and forwarding(s)
end
local s = ub.uci:section("firewall", "forwarding", nil, {
src = src,
dest = self:name(),
- mtu_fix = with_mtu_fix and true or false
+ mtu_fix = with_mtu_fix and "1" or "0"
})
return s and forwarding(s)
end
end
+function zone.del_forwardings_by(self, what)
+ local name = self:name()
+ ub.uci:foreach("firewall", "forwarding",
+ function(s)
+ if s.src and s.dest and s[what] == name then
+ ub.uci:delete("firewall", s['.name'])
+ end
+ end)
+end
+
function zone.add_redirect(self, options)
options = options or { }
options.src = self:name()