Commit 9cba7659 authored by Kaarle Ritvanen's avatar Kaarle Ritvanen

optfrag: expandfamilies function

parent 09617e43
......@@ -598,7 +598,7 @@ function M.Rule:trules()
end
ofrags = filter(
combinations(ofrags, optfrag.FAMILIES),
optfrag.expandfamilies(ofrags),
function(r) return self:trulefilter(r) end
)
......
--[[
Packet marking module for Alpine Wall
Copyright (C) 2012-2019 Kaarle Ritvanen
Copyright (C) 2012-2020 Kaarle Ritvanen
See LICENSE file for license details
]]--
......@@ -39,16 +39,17 @@ end
local function restoremark(config)
if list(config['route-track'])[1] then
return combinations(
optfrag.FAMILIES,
{{chain='OUTPUT'}, {chain='PREROUTING'}},
{
return optfrag.expandfamilies(
combinations(
{{chain='OUTPUT'}, {chain='PREROUTING'}},
{
table='mangle',
match='-m connmark ! --mark 0',
target='CONNMARK --restore-mark'
{
table='mangle',
match='-m connmark ! --mark 0',
target='CONNMARK --restore-mark'
}
}
}
)
)
end
end
......
......@@ -50,7 +50,7 @@ local function divert(config)
ofrags,
{chain='PREROUTING', match='-m socket', target='divert'}
)
return combinations(optfrag.FAMILIES, {{table='mangle'}}, ofrags)
return optfrag.expandfamilies(combinations({{table='mangle'}}, ofrags))
end
end
......
......@@ -16,8 +16,6 @@ local function ffrags(families)
return map(families, function(f) return {family=f} end)
end
M.FAMILIES = ffrags(FAMILIES)
function M.combinations(of1, ...)
local arg = {...}
......@@ -62,6 +60,10 @@ function M.combinations(of1, ...)
return M.combinations(res, table.unpack(arg))
end
function M.expandfamilies(ofrags)
return M.combinations(ffrags(FAMILIES), ofrags)
end
function M.prune(...)
local arg = {...}
local families = {}
......
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