Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
awall
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
7
Issues
7
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alpine
awall
Commits
a6d6b5bd
Commit
a6d6b5bd
authored
Nov 03, 2017
by
Kaarle Ritvanen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Log: simplify structure
parent
ce3ac0b5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
25 deletions
+14
-25
awall/modules/filter.lua
awall/modules/filter.lua
+4
-3
awall/modules/log.lua
awall/modules/log.lua
+10
-22
No files found.
awall/modules/filter.lua
View file @
a6d6b5bd
...
...
@@ -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
...
...
awall/modules/log.lua
View file @
a6d6b5bd
...
...
@@ -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
:
matcho
frags
())
return
combinations
(
ofrags
,
self
.
log
:
opt
frags
())
end
function
LogRule
:
target
()
return
self
.
log
:
target
()
end
return
{
export
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment