Commit 058c6035 authored by Kaarle Ritvanen's avatar Kaarle Ritvanen

Limit.recentopts: generate options for both recent rules

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