diff options
author | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2014-09-18 14:44:37 +0300 |
---|---|---|
committer | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2014-09-18 14:45:02 +0300 |
commit | a211a70e695262f9cd1f7e4a720117eb67c4e65c (patch) | |
tree | bc2811ea9b38ac5be70e8ea25e9408efc40769f2 | |
parent | 058c6035e0f47fd599c4b7e6c37de022c03a6153 (diff) | |
download | awall-a211a70e695262f9cd1f7e4a720117eb67c4e65c.tar.bz2 awall-a211a70e695262f9cd1f7e4a720117eb67c4e65c.tar.xz |
Limit: return option fragements for recent mode
-rw-r--r-- | awall/model.lua | 7 | ||||
-rw-r--r-- | awall/modules/filter.lua | 10 |
2 files changed, 10 insertions, 7 deletions
diff --git a/awall/model.lua b/awall/model.lua index 50e1fe4..2c5c58d 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(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) diff --git a/awall/modules/filter.lua b/awall/modules/filter.lua index d28a658..a084d1a 100644 --- a/awall/modules/filter.lua +++ b/awall/modules/filter.lua @@ -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 |