aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xawall-cli26
-rw-r--r--awall/ipset.lua6
-rw-r--r--awall/iptables.lua2
3 files changed, 21 insertions, 13 deletions
diff --git a/awall-cli b/awall-cli
index aa9bbea..69ab3e9 100755
--- a/awall-cli
+++ b/awall-cli
@@ -136,6 +136,7 @@ if not call(
local awall = require('awall')
local printtabular = util.printtabular
+ local sortedkeys = util.sortedkeys
local policyset = awall.PolicySet(pol_paths)
@@ -143,7 +144,7 @@ if not call(
local imported = policyset:load().policies
local data = {}
- for i, name in util.sortedkeys(policyset.policies) do
+ for i, name in sortedkeys(policyset.policies) do
local policy = policyset.policies[name]
if all or policy.type == 'optional' then
@@ -200,38 +201,41 @@ if not call(
return cls:sub(1, 1):upper()..cls:sub(2, -1)
end
- for cls, objs in pairs(input.data) do
+ for _, cls in sortedkeys(input.data) do
if level > 2 or (level == 2 and cls ~= 'service') or contains(
{'variable', 'zone'},
cls
) then
if level == 0 then print(capitalize(cls)..'s:') end
-
+
+ local clsdata = input.data[cls]
local items = {}
- for k, v in pairs(objs) do
- local exp = expinput[cls][k]
+
+ for _, key in sortedkeys(clsdata) do
+ local exp = expinput[cls][key]
local expj = json.encode(exp)
- local src = input.source[cls][k]
+ local src = input.source[cls][key]
- if level == 0 then table.insert(items, {k, expj, src})
+ if level == 0 then table.insert(items, {key, expj, src})
else
+ local value = clsdata[key]
local data = {
- {capitalize(cls)..' '..k, json.encode(v)},
+ {capitalize(cls)..' '..key, json.encode(value)},
{
'('..src..')',
- util.compare(exp, v) and '' or '-> '..expj
+ util.compare(exp, value) and '' or '-> '..expj
}
}
if level > 3 then
- local obj = config.objects[cls][k]
+ local obj = config.objects[cls][key]
if type(obj) == 'table' and obj.info then
util.extend(data, obj:info())
end
end
- table.insert(items, {k, data})
+ table.insert(items, {key, data})
end
end
table.sort(items, function(a, b) return a[1] < b[1] end)
diff --git a/awall/ipset.lua b/awall/ipset.lua
index 6995a48..5f4423e 100644
--- a/awall/ipset.lua
+++ b/awall/ipset.lua
@@ -4,6 +4,10 @@ Copyright (C) 2012-2014 Kaarle Ritvanen
See LICENSE file for license details
]]--
+
+local sortedkeys = require('awall.util').sortedkeys
+
+
local IPSet = require('awall.class')()
function IPSet:init(config) self.config = config or {} end
@@ -25,7 +29,7 @@ function IPSet:create()
end
function IPSet:print()
- for name, ipset in pairs(self.config) do
+ for _, name in sortedkeys(self.config) do
self:dumpfile(name, io.stdout)
io.stdout:write('\n')
end
diff --git a/awall/iptables.lua b/awall/iptables.lua
index aed05f2..fccdd80 100644
--- a/awall/iptables.lua
+++ b/awall/iptables.lua
@@ -39,7 +39,7 @@ local backupdir = '/var/run/awall'
local BaseIPTables = class()
function BaseIPTables:print()
- for family, tbls in pairs(families) do
+ for _, family in sortedkeys(families) do
self:dumpfile(family, io.stdout)
print()
end