Commit f48f9461 authored by Kaarle Ritvanen's avatar Kaarle Ritvanen

Limit: allow returning multiple limit option fragments

parent d4d5dd62
......@@ -607,11 +607,16 @@ function M.Limit:recentopts()
end
end
function M.Limit:limitopts(name)
function M.Limit:limitofrags(name)
local rate = self:rate()
return '-m hashlimit --hashlimit-upto '..rate..
'/second --hashlimit-burst '..rate..
' --hashlimit-mode srcip --hashlimit-name '..(name or self:uniqueid())
return {
{
opts='-m hashlimit --hashlimit-upto '..rate..
'/second --hashlimit-burst '..rate..
' --hashlimit-mode srcip --hashlimit-name '..
(name or self:uniqueid())
}
}
end
......
......@@ -265,11 +265,11 @@ function Filter:extraoptfrags()
ofrags, logch = self:logchain(self.log, 'accept', 'ACCEPT')
else logch = 'RETURN' end
limitofs = {
{opts=limitobj:limitopts(limitchain), target=logch},
{target='DROP'}
}
if limitlog then table.insert(limitofs, 2, limitlog:optfrag()) end
limitofs = combinations(
limitobj:limitofrags(limitchain), {{target=logch}}
)
if limitlog then table.insert(limitofs, limitlog:optfrag()) end
table.insert(limitofs, {target='DROP'})
end
extend(ofrags, combinations({{chain=limitchain}}, limitofs))
......
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