aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2016-08-03 12:50:07 +0300
committerKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2016-09-30 12:50:44 +0300
commit0c4bdcd0ee76a5b376dc09de7cb199ac90f5afd7 (patch)
tree1e71f8d9952c88ee2a564233fec416dc267a6716
parent08529e3f63430b90d146c902f8eda516bdd2b880 (diff)
downloadawall-0c4bdcd0ee76a5b376dc09de7cb199ac90f5afd7.tar.bz2
awall-0c4bdcd0ee76a5b376dc09de7cb199ac90f5afd7.tar.xz
custom targets
-rw-r--r--awall/model.lua34
-rw-r--r--awall/modules/filter.lua13
2 files changed, 35 insertions, 12 deletions
diff --git a/awall/model.lua b/awall/model.lua
index 2a2d4c9..126841b 100644
--- a/awall/model.lua
+++ b/awall/model.lua
@@ -521,24 +521,29 @@ function M.Rule:trules()
end
end
- local target
+ local custom = self:customtarget()
+ local final = custom or self:target()
+
+ local nxt
if combined then
- target = self:target()
+ nxt = final
ofrags = combined
- else target = self:uniqueid('address') end
+ else nxt = self:uniqueid('address') end
tag(ofrags, 'position', self:position())
- ofrags = combinations(ofrags, {{target=target}})
+ ofrags = combinations(ofrags, {{target=nxt}})
if not combined then
- extend(
- ofrags,
- combinations(addrofrags, {{chain=target, target=self:target()}})
- )
+ extend(ofrags, combinations(addrofrags, {{chain=nxt, target=final}}))
+ end
+
+ local function extofrags(new)
+ if not custom then extend(ofrags, new)
+ elseif new[1] then self:error('Custom action not allowed here') end
end
- extend(ofrags, self:extraoptfrags())
+ extofrags(self:extraoptfrags())
local tbl = self:table()
@@ -594,7 +599,16 @@ function M.Rule:trules()
combinations(ofrags, ffilter({{family='inet'}, {family='inet6'}})),
function(r) return self:trulefilter(r) end
)
- return extend(ofrags, self:extratrules(ofrags))
+ extofrags(self:extratrules(ofrags))
+
+ return ofrags
+end
+
+function M.Rule:customtarget()
+ if self.action then
+ local as = self.action:sub(1, 1)
+ if as == as:upper() then return self.action end
+ end
end
function M.Rule:extraoptfrags() return {} end
diff --git a/awall/modules/filter.lua b/awall/modules/filter.lua
index f12359e..48165b4 100644
--- a/awall/modules/filter.lua
+++ b/awall/modules/filter.lua
@@ -142,8 +142,15 @@ local LoggingRule = class(TranslatingRule)
function LoggingRule:init(...)
LoggingRule.super(self):init(...)
util.setdefault(self, 'action', 'accept')
+
+ local custom = self:customtarget()
if type(self.log) ~= 'table' then
- self.log = loadclass('log').get(self, self.log, self.action ~= 'accept')
+ self.log = loadclass('log').get(
+ self, self.log, not custom and self.action ~= 'accept'
+ )
+ end
+ if custom and self.log then
+ self:error('Logging not allowed with custom action: '..self.action)
end
end
@@ -165,7 +172,9 @@ function LoggingRule:logchain(log, action, target)
end
function LoggingRule:extraoptfrags()
- return self:logchain(self.log, self.action, self:actiontarget())
+ return self.log and
+ self:logchain(self.log, self.action, self:actiontarget()) or
+ LoggingRule.super(self):extraoptfrags()
end