Commit c699eca7 authored by Kaarle Ritvanen's avatar Kaarle Ritvanen

optfrag.expandfamilies: specify families

parent 9cba7659
......@@ -13,7 +13,9 @@ local model = require('awall.model')
local class = model.class
local Rule = model.Rule
local combinations = require('awall.optfrag').combinations
local optfrag = require('awall.optfrag')
local combinations = optfrag.combinations
local expandfamilies = optfrag.expandfamilies
local util = require('awall.util')
local contains = util.contains
......@@ -115,7 +117,7 @@ function TranslatingRule:destoptfrags()
local ofrags = TranslatingRule.super(self):destoptfrags()
if not self.dnat then return ofrags end
ofrags = combinations(ofrags, {{family='inet6'}})
ofrags = expandfamilies(ofrags, 'inet6')
local natof = self:create(
model.Zone, {addr=self.dnat.addr}
):optfrags(self:direction('out'))
......@@ -128,7 +130,7 @@ function TranslatingRule:servoptfrags()
local ofrags = TranslatingRule.super(self):servoptfrags()
if not (self.dnat and self.dnat.port) then return ofrags end
ofrags = combinations(ofrags, {{family='inet6'}})
ofrags = expandfamilies(ofrags, 'inet6')
local protos = {}
for _, serv in ipairs(self.service) do
......@@ -139,11 +141,11 @@ function TranslatingRule:servoptfrags()
for proto, _ in pairs(protos) do
extend(
ofrags,
combinations(
expandfamilies(
self:create(
model.Rule, {service={proto=proto, port=self.dnat.port}}
):servoptfrags(),
{{family='inet'}}
'inet'
)
)
end
......
......@@ -60,8 +60,10 @@ function M.combinations(of1, ...)
return M.combinations(res, table.unpack(arg))
end
function M.expandfamilies(ofrags)
return M.combinations(ffrags(FAMILIES), ofrags)
function M.expandfamilies(ofrags, families)
return M.combinations(
ffrags(families and util.list(families) or FAMILIES), ofrags
)
end
function M.prune(...)
......
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