Commit 6d4ff188 authored by Kaarle Ritvanen's avatar Kaarle Ritvanen

support for empty zones

(set either addr or iface attribute to an empty list)
parent 498a67cf
......@@ -41,16 +41,18 @@ function Zone:optfrags(dir)
iopt, aopt, iprop, aprop = 'o', 'd', 'out', 'dest'
else assert(false) end
local aopts = {}
for i, hostdef in util.listpairs(self.addr) do
for i, addr in ipairs(awall.host.resolve(hostdef)) do
table.insert(aopts,
{family=addr[1],
[aprop]=addr[2],
opts='-'..aopt..' '..addr[2]})
local aopts = nil
if self.addr then
aopts = {}
for i, hostdef in util.listpairs(self.addr) do
for i, addr in ipairs(awall.host.resolve(hostdef)) do
table.insert(aopts,
{family=addr[1],
[aprop]=addr[2],
opts='-'..aopt..' '..addr[2]})
end
end
end
if not aopts[1] then aopts = nil end
return combinations(util.maplist(self.iface,
function(x)
......@@ -324,7 +326,7 @@ function Rule:trules()
target = self:newchain('address')
else
target = self:target()
if addrofrags then res = combinations(res, addrofrags) end
res = combinations(res, addrofrags)
end
tag(res, 'position', self:position())
......
......@@ -25,7 +25,7 @@ function Filter:destoptfrags()
local ofrags = model.Rule.destoptfrags(self)
if not self.dnat then return ofrags end
ofrags = awall.optfrag.combinations(ofrags, {{family='inet6'}}) or {}
ofrags = awall.optfrag.combinations(ofrags, {{family='inet6'}})
local natof = model.Zone.morph({addr=self.dnat}):optfrags('out')
assert(#natof == 1)
table.insert(ofrags, natof[1])
......
......@@ -44,5 +44,5 @@ function combinations(of1, of2)
end
end
return res[1] and res or nil
return res
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment