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
Incidents
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
73aff0f6
Commit
73aff0f6
authored
Oct 11, 2017
by
Kaarle Ritvanen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rule: make convertchain a method
parent
be16233e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
40 deletions
+36
-40
awall/model.lua
awall/model.lua
+36
-40
No files found.
awall/model.lua
View file @
73aff0f6
...
...
@@ -590,46 +590,8 @@ function M.Rule:trules()
setdefault
(
ofrag
,
'target'
,
custom
or
self
:
target
())
end
local
tbl
=
self
:
table
()
local
function
convertchains
(
ofrags
)
local
res
=
{}
for
i
,
ofrag
in
ipairs
(
ofrags
)
do
if
contains
(
builtin
[
tbl
],
ofrag
.
chain
)
then
table.insert
(
res
,
ofrag
)
else
local
ofs
,
recursive
if
ofrag
.
chain
==
'PREROUTING'
then
ofs
=
{{
chain
=
'FORWARD'
},
{
chain
=
'INPUT'
}}
elseif
ofrag
.
chain
==
'POSTROUTING'
then
ofs
=
{{
chain
=
'FORWARD'
},
{
chain
=
'OUTPUT'
}}
recursive
=
true
elseif
ofrag
.
chain
==
'INPUT'
then
ofs
=
{
{
match
=
'-m addrtype --dst-type LOCAL'
,
chain
=
'PREROUTING'
}
}
elseif
ofrag
.
chain
==
'FORWARD'
then
ofs
=
{
{
match
=
'-m addrtype ! --dst-type LOCAL'
,
chain
=
'PREROUTING'
}
}
end
if
ofs
then
ofrag
.
chain
=
nil
ofs
=
combinations
(
ofs
,
{
ofrag
})
if
recursive
then
ofs
=
convertchains
(
ofs
)
end
extend
(
res
,
ofs
)
else
table.insert
(
res
,
ofrag
)
end
end
end
return
res
end
ofrags
=
convertchains
(
ffilter
(
ofrags
))
tag
(
ofrags
,
'table'
,
tbl
,
false
)
ofrags
=
self
:
convertchains
(
ffilter
(
ofrags
))
tag
(
ofrags
,
'table'
,
self
:
table
(),
false
)
local
function
checkzof
(
ofrag
,
dir
,
chains
)
if
ofrag
[
dir
]
and
contains
(
chains
,
ofrag
.
chain
)
then
...
...
@@ -667,6 +629,40 @@ function M.Rule:trulefilter(rule) return true end
function
M
.
Rule
:
extratrules
(
rules
)
return
{}
end
function
M
.
Rule
:
convertchains
(
ofrags
)
local
res
=
{}
for
_
,
ofrag
in
ipairs
(
ofrags
)
do
if
contains
(
builtin
[
self
:
table
()],
ofrag
.
chain
)
then
table.insert
(
res
,
ofrag
)
else
local
ofs
,
recursive
if
ofrag
.
chain
==
'PREROUTING'
then
ofs
=
{{
chain
=
'FORWARD'
},
{
chain
=
'INPUT'
}}
elseif
ofrag
.
chain
==
'POSTROUTING'
then
ofs
=
{{
chain
=
'FORWARD'
},
{
chain
=
'OUTPUT'
}}
recursive
=
true
elseif
ofrag
.
chain
==
'INPUT'
then
ofs
=
{{
match
=
'-m addrtype --dst-type LOCAL'
,
chain
=
'PREROUTING'
}}
elseif
ofrag
.
chain
==
'FORWARD'
then
ofs
=
{{
match
=
'-m addrtype ! --dst-type LOCAL'
,
chain
=
'PREROUTING'
}}
end
if
ofs
then
ofrag
.
chain
=
nil
ofs
=
combinations
(
ofs
,
{
ofrag
})
if
recursive
then
ofs
=
self
:
convertchains
(
ofs
)
end
extend
(
res
,
ofs
)
else
table.insert
(
res
,
ofrag
)
end
end
end
return
res
end
function
M
.
Rule
:
extrarules
(
label
,
cls
,
options
)
local
params
=
{}
...
...
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