aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2017-01-08 18:42:10 +0200
committerKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2017-01-24 01:52:49 +0200
commitadc33e7957e337b31ed151efc29186ca6d8ec4ac (patch)
treea35a6ce6050315b7094e952ec5b13d00829bebd8
parent1d8ee361e5c6a2cadad40636eb21d281d2431e69 (diff)
downloadawall-adc33e7957e337b31ed151efc29186ca6d8ec4ac.tar.bz2
awall-adc33e7957e337b31ed151efc29186ca6d8ec4ac.tar.xz
Filter: allow limits with pass action
-rw-r--r--awall/modules/filter.lua24
1 files changed, 19 insertions, 5 deletions
diff --git a/awall/modules/filter.lua b/awall/modules/filter.lua
index 13395e4..48eb43c 100644
--- a/awall/modules/filter.lua
+++ b/awall/modules/filter.lua
@@ -341,8 +341,12 @@ function Filter:mangleoptfrags(ofrags)
local limit = self:limit()
if not limit then return Filter.super(self):mangleoptfrags(ofrags) end
- if self.action ~= 'accept' then
- self:error('Cannot specify limit for '..self.action..' filter')
+ local function incompatible(item)
+ self:error('Limit incompatible with '..item)
+ end
+
+ if self:customtarget() or self:logdefault() then
+ incompatible('action: '..self.action)
end
local limitchain = self:uniqueid('limit')
@@ -351,17 +355,27 @@ function Filter:mangleoptfrags(ofrags)
local ofs
local conn = limit == 'conn-limit'
+ local target = self:target()
+ local ct = conn and target
+ local pl = not target and self.log
local uofs, sofs = limitobj:recentofrags(limitchain)
if uofs then
ofs = self:combinelog(uofs, limitlog, 'drop', 'DROP')
- if conn then extend(ofs, self:actofrags(self.log)) end
- extend(ofs, combinations(sofs, {{target=conn and 'ACCEPT'}}))
+
+ local nxt
+ if ct then
+ extend(ofs, self:actofrags(self.log))
+ nxt = target
+ elseif not pl then nxt = false end
+ extend(ofs, combinations(sofs, self:actofrags(pl, nxt)))
else
+ if pl then incompatible('action or log') end
+
local limofs = limitobj:limitofrags(limitchain)
- ofs = conn and Filter.super(self):mangleoptfrags(limofs) or
+ ofs = ct and Filter.super(self):mangleoptfrags(limofs) or
combinations(limofs, {{target='RETURN'}})
extend(ofs, self:actofrags(limitlog, 'DROP'))