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
bdc0328a
Commit
bdc0328a
authored
Apr 09, 2012
by
Kaarle Ritvanen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optional, importable configuration files
parent
2b3db7b4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
20 deletions
+55
-20
awall-cli
awall-cli
+5
-2
awall/init.lua
awall/init.lua
+50
-18
No files found.
awall-cli
View file @
bdc0328a
...
...
@@ -19,15 +19,18 @@ long_opts = {activate='a',
if
stringy
.
endswith
(
arg
[
0
],
'/awall-cli'
)
then
basedir
=
string.sub
(
arg
[
0
],
1
,
-
11
)
input
=
{
basedir
..
'/json'
}
import
=
{}
short_opts
=
short_opts
..
'i:'
short_opts
=
short_opts
..
'i:
I:
'
long_opts
[
'input-dir'
]
=
'i'
long_opts
[
'import-path'
]
=
'I'
end
for
switch
,
value
in
pairs
(
alt_getopt
.
get_opts
(
arg
,
short_opts
,
long_opts
))
do
if
switch
==
'a'
then
activate
=
true
elseif
switch
==
'F'
then
fallback
=
true
elseif
switch
==
'i'
then
table.insert
(
input
,
value
)
elseif
switch
==
'I'
then
table.insert
(
import
,
value
)
elseif
switch
==
'o'
then
iptdir
=
value
ipsfile
=
value
..
'/ipset'
...
...
@@ -40,7 +43,7 @@ require 'awall'
require
'awall.iptables'
awall
.
loadmodules
(
basedir
)
config
=
awall
.
Config
.
new
(
input
)
config
=
awall
.
Config
.
new
(
input
,
import
)
if
activate
then
...
...
awall/init.lua
View file @
bdc0328a
...
...
@@ -37,31 +37,63 @@ end
Config
=
awall
.
object
.
class
(
awall
.
object
.
Object
)
function
Config
:
init
(
confdirs
)
function
Config
:
init
(
confdirs
,
importdirs
)
self
.
input
=
{}
self
.
iptables
=
awall
.
iptables
.
IPTables
.
new
()
for
i
,
dir
in
ipairs
(
confdirs
or
{
'/usr/share/awall'
,
'/etc/awall'
})
do
local
fnames
=
{}
for
fname
in
lfs
.
dir
(
dir
)
do
table.insert
(
fnames
,
fname
)
end
table.sort
(
fnames
)
for
i
,
fname
in
ipairs
(
fnames
)
do
if
string.sub
(
fname
,
1
,
1
)
~=
'.'
then
local
data
=
''
for
line
in
io.lines
(
dir
..
'/'
..
fname
)
do
data
=
data
..
line
end
data
=
json
.
decode
(
data
)
for
cls
,
objs
in
pairs
(
data
)
do
if
not
self
.
input
[
cls
]
then
self
.
input
[
cls
]
=
objs
elseif
objs
[
1
]
then
util
.
extend
(
self
.
input
[
cls
],
objs
)
else
for
k
,
v
in
pairs
(
objs
)
do
self
.
input
[
cls
][
k
]
=
v
end
end
local
required
=
{}
local
imported
=
{}
function
import
(
name
,
fname
)
local
file
if
fname
then
file
=
io.open
(
fname
)
else
for
i
,
dir
in
ipairs
(
importdirs
or
{
'/usr/share/awall/optional'
})
do
file
=
io.open
(
dir
..
'/'
..
name
..
'.json'
)
if
file
then
break
end
end
end
if
not
file
then
error
(
'Import failed: '
..
name
)
end
local
data
=
''
for
line
in
file
:
lines
()
do
data
=
data
..
line
end
file
:
close
()
data
=
json
.
decode
(
data
)
table.insert
(
required
,
name
)
for
i
,
iname
in
util
.
listpairs
(
data
.
import
)
do
if
not
util
.
contains
(
imported
,
iname
)
then
if
util
.
contains
(
required
,
iname
)
then
error
(
'Circular import: '
+
iname
)
end
import
(
iname
)
end
end
table.insert
(
imported
,
name
)
for
cls
,
objs
in
pairs
(
data
)
do
if
cls
~=
'import'
then
if
not
self
.
input
[
cls
]
then
self
.
input
[
cls
]
=
objs
elseif
objs
[
1
]
then
util
.
extend
(
self
.
input
[
cls
],
objs
)
else
for
k
,
v
in
pairs
(
objs
)
do
self
.
input
[
cls
][
k
]
=
v
end
end
end
end
end
for
i
,
dir
in
ipairs
(
confdirs
or
{
'/usr/share/awall/mandatory'
,
'/etc/awall'
})
do
local
names
=
{}
for
fname
in
lfs
.
dir
(
dir
)
do
local
si
,
ei
,
name
=
string.find
(
fname
,
'^([%w-]+)%.json$'
)
if
name
then
table.insert
(
names
,
name
)
end
end
table.sort
(
names
)
for
i
,
name
in
ipairs
(
names
)
do
import
(
name
,
dir
..
'/'
..
name
..
'.json'
)
end
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