aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--awall/modules/filter.lua7
-rw-r--r--awall/modules/log.lua32
2 files changed, 14 insertions, 25 deletions
diff --git a/awall/modules/filter.lua b/awall/modules/filter.lua
index c4ea0eb..8633a3d 100644
--- a/awall/modules/filter.lua
+++ b/awall/modules/filter.lua
@@ -179,8 +179,9 @@ end
function LoggingRule:combinelog(ofrags, log, action, target)
local actions = self:actofrags(log, target)
return actions[1] and
- self:combine(ofrags, actions, 'log'..action, log and log:target()) or
- ofrags
+ self:combine(
+ ofrags, actions, 'log'..action, log and #log:optfrags() > 0
+ ) or ofrags
end
function LoggingRule:mangleoptfrags(ofrags)
@@ -416,7 +417,7 @@ function Filter:mangleoptfrags(ofrags)
if ft then
extend(ofs, self:actofrags(self.log))
nxt = target
- elseif sofs and not (pl and pl:target()) then nxt = false end
+ elseif sofs and not (pl and #pl:optfrags() > 0) then nxt = false end
extend(ofs, combinations(sofs, self:actofrags(pl, nxt)))
else
diff --git a/awall/modules/log.lua b/awall/modules/log.lua
index cac900d..e3cd84e 100644
--- a/awall/modules/log.lua
+++ b/awall/modules/log.lua
@@ -22,7 +22,10 @@ end
local Log = class(model.ConfigObject)
-function Log:matchofrags()
+function Log:optfrags()
+ local mode = self.mode or 'log'
+ if mode == 'none' then return {} end
+
local selector, ofrags
for i, sel in ipairs{'every', 'limit', 'probability'} do
@@ -45,14 +48,6 @@ function Log:matchofrags()
end
end
- if self.mode == 'ulog' then
- ofrags = combinations({{family='inet'}}, ofrags)
- end
-
- return ofrags
-end
-
-function Log:target()
local optmap = {
log={level='level', prefix='prefix'},
nflog={
@@ -68,25 +63,20 @@ function Log:target()
threshold='qthreshold'
}
}
-
- local mode = self.mode or 'log'
- if mode == 'none' then return end
if not optmap[mode] then self:error('Invalid logging mode: '..mode) end
- local res = mode:upper()
+ local target = mode:upper()
for s, t in pairs(optmap[mode]) do
local value = self[s]
if value then
if s == 'prefix' then value = util.quote(value) end
- res = res..' --'..mode..'-'..t..' '..value
+ target = target..' --'..mode..'-'..t..' '..value
end
end
- return res
-end
-function Log:optfrags()
- local target = self:target()
- return combinations(self:matchofrags(), {target and {target=target}})
+ return combinations(
+ ofrags, {{family=mode == 'ulog' and 'inet' or nil, target=target}}
+ )
end
function Log.get(rule, spec, default)
@@ -107,11 +97,9 @@ end
function LogRule:position() return 'prepend' end
function LogRule:mangleoptfrags(ofrags)
- return combinations(ofrags, self.log:matchofrags())
+ return combinations(ofrags, self.log:optfrags())
end
-function LogRule:target() return self.log:target() end
-
return {
export={