Commit 5c1f829e authored by Kaarle Ritvanen's avatar Kaarle Ritvanen
Browse files

LoggingRule: allow overriding default log

parent c6b208dc
--[[ --[[
Filter module for Alpine Wall Filter module for Alpine Wall
Copyright (C) 2012-2016 Kaarle Ritvanen Copyright (C) 2012-2017 Kaarle Ritvanen
See LICENSE file for license details See LICENSE file for license details
]]-- ]]--
...@@ -146,7 +146,7 @@ function LoggingRule:init(...) ...@@ -146,7 +146,7 @@ function LoggingRule:init(...)
local custom = self:customtarget() local custom = self:customtarget()
if type(self.log) ~= 'table' then if type(self.log) ~= 'table' then
self.log = loadclass('log').get( self.log = loadclass('log').get(
self, self.log, not custom and self.action ~= 'accept' self, self.log, not custom and self:logdefault()
) )
end end
if custom and self.log then if custom and self.log then
...@@ -154,6 +154,8 @@ function LoggingRule:init(...) ...@@ -154,6 +154,8 @@ function LoggingRule:init(...)
end end
end end
function LoggingRule:logdefault() return false end
function LoggingRule:actiontarget() return 'ACCEPT' end function LoggingRule:actiontarget() return 'ACCEPT' end
function LoggingRule:target() function LoggingRule:target()
...@@ -328,12 +330,15 @@ function Filter:position() ...@@ -328,12 +330,15 @@ function Filter:position()
and 'prepend' or 'append' and 'prepend' or 'append'
end end
function Filter:logdefault()
return contains({'drop', 'reject', 'tarpit'}, self.action)
end
function Filter:actiontarget() function Filter:actiontarget()
if self.action == 'tarpit' then return 'tarpit' end if self.action ~= 'accept' and not self:logdefault() then
if contains({'accept', 'drop', 'reject'}, self.action) then self:error('Invalid filter action: '..self.action)
return self.action:upper()
end end
self:error('Invalid filter action: '..self.action) return self.action == 'tarpit' and 'tarpit' or self.action:upper()
end end
function Filter:target() function Filter:target()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment