Commit a211a70e authored by Kaarle Ritvanen's avatar Kaarle Ritvanen

Limit: return option fragements for recent mode

parent 058c6035
......@@ -591,7 +591,7 @@ end
function M.Limit:rate() return math.ceil(self.count / self.interval) end
function M.Limit:recentopts(name)
function M.Limit:recentofrags(name)
local count = self.count
local interval = self.interval
......@@ -603,8 +603,9 @@ function M.Limit:recentopts(name)
if count > RECENT_MAX_COUNT then return end
local rec = '-m recent --name '..name
return rec..' --update --hitcount '..count..' --seconds '..interval,
rec..' --set'
return {
{opts=rec..' --update --hitcount '..count..' --seconds '..interval}
}, {{opts=rec..' --set'}}
end
function M.Limit:limitofrags(name)
......
......@@ -244,16 +244,18 @@ function Filter:extraoptfrags()
local logch, limitofs
local accept = self:position() == 'append'
local uopts, sopts = limitobj:recentopts(limitchain)
local uofs, sofs = limitobj:recentofrags(limitchain)
if uopts then
if uofs then
ofrags, logch = self:logchain(limitlog, 'drop', 'DROP')
limitofs = {{opts=uopts, target=logch}}
limitofs = combinations(uofs, {{target=logch}})
if accept and self.log then
table.insert(limitofs, self.log:optfrag())
end
table.insert(limitofs, {opts=sopts, target=accept and 'ACCEPT' or nil})
extend(
limitofs, combinations(sofs, {{target=accept and 'ACCEPT' or nil}})
)
else
if accept then
......
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