Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
awall
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
8
Issues
8
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alpine
awall
Commits
20407dfd
Commit
20407dfd
authored
Jul 17, 2016
by
Kaarle Ritvanen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
helper function for printing to stderr
parent
2f835190
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
26 additions
and
24 deletions
+26
-24
awall-cli
awall-cli
+6
-5
ipset.lua
awall/ipset.lua
+4
-4
iptables.lua
awall/iptables.lua
+4
-9
model.lua
awall/model.lua
+2
-2
uerror.lua
awall/uerror.lua
+6
-3
util.lua
awall/util.lua
+4
-1
No files found.
awall-cli
View file @
20407dfd
...
...
@@ -116,6 +116,7 @@ end
util
=
require
(
'awall.util'
)
contains
=
util
.
contains
printmsg
=
util
.
printmsg
if
not
contains
(
{
...
...
@@ -283,7 +284,7 @@ if not call(
elseif
mode
==
'diff'
then
if
not
posix
.
stat
(
dumpfile
)
then
io.stderr
:
write
(
'Please translate or activate first\n
'
)
printmsg
(
'Please translate or activate first
'
)
os.exit
(
1
)
end
...
...
@@ -351,15 +352,15 @@ if not call(
if
call
(
config
.
activate
,
config
)
then
if
not
force
then
io.stderr
:
write
(
'New firewall configuration activated\n
'
)
printmsg
(
'New firewall configuration activated
'
)
io.stderr
:
write
(
'Press RETURN to commit changes permanently: '
)
interrupted
=
not
io.read
()
kill
()
if
interrupted
then
io.stderr
:
write
(
'
\n
Activation canceled, reverting to the old configuration
\n
'
printmsg
(
'
\n
Activation canceled, reverting to the old configuration'
)
revert
()
end
...
...
@@ -382,7 +383,7 @@ if not call(
posix
.
sleep
(
10
)
io.stderr
:
write
(
'
\n
Timeout, reverting to the old configuration\
n'
)
printmsg
(
'
\n
Timeout, reverting to the old configuratio
n'
)
iptables
.
revert
()
elseif
mode
==
'flush'
then
iptables
.
flush
()
...
...
awall/ipset.lua
View file @
20407dfd
--[[
Ipset file dumper for Alpine Wall
Copyright (C) 2012-201
4
Kaarle Ritvanen
Copyright (C) 2012-201
6
Kaarle Ritvanen
See LICENSE file for license details
]]
--
local
sortedkeys
=
require
(
'awall.util'
).
sortedkeys
local
util
=
require
(
'awall.util'
)
local
IPSet
=
require
(
'awall.class'
)()
...
...
@@ -24,13 +24,13 @@ function IPSet:create()
'ipset'
,
'-!'
,
'create'
,
name
,
table.unpack
(
ipset
.
options
)
)
if
lpc
.
wait
(
pid
)
~=
0
then
io.stderr
:
write
(
'ipset creation failed: '
..
name
)
util
.
printmsg
(
'ipset creation failed: '
..
name
)
end
end
end
function
IPSet
:
print
()
for
_
,
name
in
sortedkeys
(
self
.
config
)
do
for
_
,
name
in
util
.
sortedkeys
(
self
.
config
)
do
self
:
dumpfile
(
name
,
io.output
())
io.write
(
'
\n
'
)
end
...
...
awall/iptables.lua
View file @
20407dfd
--[[
Iptables file dumper for Alpine Wall
Copyright (C) 2012-201
4
Kaarle Ritvanen
Copyright (C) 2012-201
6
Kaarle Ritvanen
See LICENSE file for license details
]]
--
...
...
@@ -9,6 +9,7 @@ local class = require('awall.class')
local
raise
=
require
(
'awall.uerror'
).
raise
local
util
=
require
(
'awall.util'
)
local
printmsg
=
util
.
printmsg
local
sortedkeys
=
util
.
sortedkeys
...
...
@@ -71,9 +72,7 @@ function BaseIPTables:restore(test)
disabled
=
false
elseif
test
then
io.stderr
:
write
(
'Warning: '
..
family
..
' rules not tested\n'
)
end
elseif
test
then
printmsg
(
'Warning: '
..
family
..
' rules not tested'
)
end
end
if
disabled
then
raise
(
'Firewall not enabled in kernel'
)
end
...
...
@@ -159,11 +158,7 @@ function M.flush()
for
i
,
chain
in
ipairs
(
M
.
builtin
[
tbl
])
do
empty
.
config
[
family
][
tbl
][
chain
]
=
{}
end
else
io.stderr
:
write
(
'Warning: not flushing unknown table: '
..
tbl
..
'
\n
'
)
end
else
printmsg
(
'Warning: not flushing unknown table: '
..
tbl
)
end
end
end
end
...
...
awall/model.lua
View file @
20407dfd
--[[
Base data model for Alpine Wall
Copyright (C) 2012-201
5
Kaarle Ritvanen
Copyright (C) 2012-201
6
Kaarle Ritvanen
See LICENSE file for license details
]]
--
...
...
@@ -84,7 +84,7 @@ end
function
M
.
ConfigObject
:
error
(
msg
)
raise
(
self
.
location
..
': '
..
msg
)
end
function
M
.
ConfigObject
:
warning
(
msg
)
io.stderr
:
write
(
self
.
location
..
': '
..
msg
..
'
\n
'
)
util
.
printmsg
(
self
.
location
..
': '
..
msg
)
end
function
M
.
ConfigObject
:
trules
()
return
{}
end
...
...
awall/uerror.lua
View file @
20407dfd
--[[
User error handling for Alpine Wall
Copyright (C) 2012-201
4
Kaarle Ritvanen
Copyright (C) 2012-201
6
Kaarle Ritvanen
See LICENSE file for license details
]]
--
local
printmsg
=
require
(
'awall.util'
).
printmsg
local
M
=
{}
local
prefix
=
'awall user error: '
...
...
@@ -18,8 +21,8 @@ function M.call(f, ...)
function
(
msg
)
local
si
,
ei
=
msg
:
find
(
prefix
,
1
,
true
)
if
si
then
msg
=
'awall: '
..
msg
:
sub
(
ei
+
1
,
-
1
)
end
io.stderr
:
write
(
msg
..
'
\n
'
)
if
not
si
then
io.stderr
:
write
(
debug.traceback
()
..
'
\n
'
)
end
printmsg
(
msg
)
if
not
si
then
printmsg
(
debug.traceback
()
)
end
end
)
end
...
...
awall/util.lua
View file @
20407dfd
--[[
Utility module for Alpine Wall
Copyright (C) 2012-201
5
Kaarle Ritvanen
Copyright (C) 2012-201
6
Kaarle Ritvanen
See LICENSE file for license details
]]
--
...
...
@@ -142,4 +142,7 @@ end
function
M
.
printtabular
(
tbl
)
M
.
printtabulars
({
tbl
})
end
function
M
.
printmsg
(
msg
)
io.stderr
:
write
(
msg
..
'
\n
'
)
end
return
M
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