aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2014-09-18 14:09:44 +0300
committerKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2014-09-18 14:39:32 +0300
commit058c6035e0f47fd599c4b7e6c37de022c03a6153 (patch)
treead9f04f74da1f8ddebe4fe7753ff490c8cd58c1a
parent0d6d0b76af382c00ada3add3e722482723158423 (diff)
downloadawall-058c6035e0f47fd599c4b7e6c37de022c03a6153.tar.bz2
awall-058c6035e0f47fd599c4b7e6c37de022c03a6153.tar.xz
Limit.recentopts: generate options for both recent rules
-rw-r--r--awall/model.lua10
-rw-r--r--awall/modules/filter.lua15
2 files changed, 11 insertions, 14 deletions
diff --git a/awall/model.lua b/awall/model.lua
index c261c51..50e1fe4 100644
--- a/awall/model.lua
+++ b/awall/model.lua
@@ -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
end
- if count <= RECENT_MAX_COUNT then
- return '--update --hitcount '..count..' --seconds '..interval
- end
+ if count > RECENT_MAX_COUNT then return end
+
+ local rec = '-m recent --name '..name
+ return rec..' --update --hitcount '..count..' --seconds '..interval,
+ rec..' --set'
end
function M.Limit:limitofrags(name)
diff --git a/awall/modules/filter.lua b/awall/modules/filter.lua
index 31ae700..d28a658 100644
--- a/awall/modules/filter.lua
+++ b/awall/modules/filter.lua
@@ -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())
end
+ table.insert(limitofs, {opts=sopts, target=accept and 'ACCEPT' or nil})
else
if accept then