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
c3126d2e
Commit
c3126d2e
authored
Mar 22, 2012
by
Kaarle Ritvanen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
class model generalized and moved to a self-contained module
parent
2a788938
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
33 deletions
+51
-33
awall/model.lua
awall/model.lua
+13
-27
awall/modules/nat.lua
awall/modules/nat.lua
+6
-6
awall/object.lua
awall/object.lua
+32
-0
No files found.
awall/model.lua
View file @
c3126d2e
...
...
@@ -10,44 +10,28 @@ module(..., package.seeall)
require
'awall'
require
'awall.host'
require
'awall.util'
require
'awall.object'
require
'awall.optfrag'
local
util
=
awall
.
util
local
combinations
=
awall
.
optfrag
.
combinations
class
=
awall
.
object
.
class
function
class
(
base
)
local
cls
=
{}
local
mt
=
{
__index
=
cls
}
if
base
then
setmetatable
(
cls
,
{
__index
=
base
})
end
ConfigObject
=
class
(
awall
.
object
.
Object
)
function
cls
.
new
(
...
)
local
inst
=
arg
[
1
]
and
arg
[
1
]
or
{}
cls
.
morph
(
inst
)
return
ins
t
function
ConfigObject
:
init
(
context
)
if
context
then
self
.
context
=
context
self
.
root
=
context
.
inpu
t
end
function
cls
:
morph
(
context
)
setmetatable
(
self
,
mt
)
if
context
then
self
.
context
=
context
self
.
root
=
context
.
input
end
self
:
init
()
end
return
cls
end
Object
=
class
()
function
Object
:
init
()
end
function
Object
:
trules
()
return
{}
end
function
ConfigObject
:
trules
()
return
{}
end
Zone
=
class
(
Object
)
Zone
=
class
(
Config
Object
)
function
Zone
:
optfrags
(
dir
)
local
iopt
,
aopt
,
iprop
,
aprop
...
...
@@ -80,10 +64,12 @@ end
fwzone
=
Zone
.
new
()
Rule
=
class
(
Object
)
Rule
=
class
(
ConfigObject
)
function
Rule
:
init
(
context
)
ConfigObject
.
init
(
self
,
context
)
function
Rule
:
init
()
for
i
,
prop
in
ipairs
({
'in'
,
'out'
})
do
self
[
prop
]
=
self
[
prop
]
and
util
.
maplist
(
self
[
prop
],
function
(
z
)
...
...
awall/modules/nat.lua
View file @
c3126d2e
...
...
@@ -16,8 +16,8 @@ local util = awall.util
local
NATRule
=
model
.
class
(
model
.
Rule
)
function
NATRule
:
init
()
model
.
Rule
.
init
(
self
)
function
NATRule
:
init
(
context
)
model
.
Rule
.
init
(
self
,
context
)
if
util
.
contains
({
self
[
'in'
],
self
.
out
},
fwzone
)
then
error
(
'NAT rules not allowed for firewall zone'
)
end
...
...
@@ -53,8 +53,8 @@ end
local
DNATRule
=
model
.
class
(
NATRule
)
function
DNATRule
:
init
()
NATRule
.
init
(
self
)
function
DNATRule
:
init
(
context
)
NATRule
.
init
(
self
,
context
)
self
.
params
=
{
forbidif
=
'out'
,
subject
=
'destination'
,
chain
=
'PREROUTING'
,
target
=
'DNAT'
}
end
...
...
@@ -62,8 +62,8 @@ end
local
SNATRule
=
model
.
class
(
NATRule
)
function
SNATRule
:
init
()
NATRule
.
init
(
self
)
function
SNATRule
:
init
(
context
)
NATRule
.
init
(
self
,
context
)
self
.
params
=
{
forbidif
=
'in'
,
subject
=
'source'
,
chain
=
'POSTROUTING'
,
target
=
'SNAT'
}
end
...
...
awall/object.lua
0 → 100644
View file @
c3126d2e
--[[
Class model with inheritance and morphing support for Alpine Wall
Copyright (C) 2012 Kaarle Ritvanen
Licensed under the terms of GPL2
]]
--
module
(
...
,
package
.
seeall
)
function
class
(
base
)
local
cls
=
{}
local
mt
=
{
__index
=
cls
}
if
base
then
setmetatable
(
cls
,
{
__index
=
base
})
end
function
cls
.
new
(
...
)
local
inst
=
arg
[
1
]
and
arg
[
1
]
or
{}
cls
.
morph
(
inst
)
return
inst
end
function
cls
:
morph
(
...
)
setmetatable
(
self
,
mt
)
self
:
init
(
unpack
(
arg
))
end
return
cls
end
Object
=
class
()
function
Object
:
init
(
...
)
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