diff options
author | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2013-01-30 11:46:33 +0200 |
---|---|---|
committer | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2013-01-30 11:46:33 +0200 |
commit | cb0c7dce8ab8b9dea5567b82c3dbb242d1786ac3 (patch) | |
tree | 9ea5fa63ae18d5bce0bb9455c4b0aff0857a7986 /awall | |
parent | ff7c8fc086476ebfcf2b89859081fbd7f4c062be (diff) | |
download | awall-cb0c7dce8ab8b9dea5567b82c3dbb242d1786ac3.tar.bz2 awall-cb0c7dce8ab8b9dea5567b82c3dbb242d1786ac3.tar.xz |
support for all NFLOG and ULOG optionsv0.2.15
fixes #1586
Diffstat (limited to 'awall')
-rw-r--r-- | awall/model.lua | 2 | ||||
-rw-r--r-- | awall/modules/filter.lua | 29 |
2 files changed, 27 insertions, 4 deletions
diff --git a/awall/model.lua b/awall/model.lua index 1746c7a..2e2e61a 100644 --- a/awall/model.lua +++ b/awall/model.lua @@ -23,7 +23,7 @@ class = awall.object.class require 'stringy' -local ConfigObject = class() +ConfigObject = class() function ConfigObject:init(context, location) if context then diff --git a/awall/modules/filter.lua b/awall/modules/filter.lua index eafb5ad..15d3629 100644 --- a/awall/modules/filter.lua +++ b/awall/modules/filter.lua @@ -17,14 +17,37 @@ local extend = util.extend local RECENT_MAX_COUNT = 20 -local Log = model.class() +local Log = model.class(model.ConfigObject) function Log:optfrag() + local optmap = { + log={level='level', prefix='prefix'}, + nflog={ + group='group', + prefix='prefix', + range='range', + threshold='threshold' + }, + ulog={ + group='nlgroup', + prefix='prefix', + range='cprange', + threshold='qthreshold' + } + } + local mode = self.mode or 'log' - local prefix = self.prefix and ' --'..mode..'-prefix '..self.prefix or '' + if not optmap[mode] then self:error('Invalid logging mode: '..mode) end + + local target = string.upper(mode) + + for s, t in pairs(optmap[mode]) do + if self[s] then target = target..' --'..mode..'-'..t..' '..self[s] end + end + return { opts=self.limit and '-m limit --limit '..self.limit..'/second', - target=string.upper(mode)..prefix + target=target } end |