Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
alpine
awall
Commits
0c4bdcd0
Commit
0c4bdcd0
authored
Aug 03, 2016
by
Kaarle Ritvanen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
custom targets
parent
08529e3f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
12 deletions
+35
-12
awall/model.lua
awall/model.lua
+24
-10
awall/modules/filter.lua
awall/modules/filter.lua
+11
-2
No files found.
awall/model.lua
View file @
0c4bdcd0
...
...
@@ -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
targe
t
=
self
:
uniqueid
(
'address'
)
end
else
nx
t
=
self
:
uniqueid
(
'address'
)
end
tag
(
ofrags
,
'position'
,
self
:
position
())
ofrags
=
combinations
(
ofrags
,
{{
target
=
targe
t
}})
ofrags
=
combinations
(
ofrags
,
{{
target
=
nx
t
}})
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
ext
end
(
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
...
...
awall/modules/filter.lua
View file @
0c4bdcd0
...
...
@@ -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
...
...
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