Commit 1db655ba authored by Kaarle Ritvanen's avatar Kaarle Ritvanen

eliminate module-level configuration variables

parent 2f571bb0
......@@ -19,12 +19,6 @@ end
require 'awall'
awall.loadmodules(testmode and '.')
if testmode then
awall.confdirs = {'json', 'input'}
awall.iptdir = 'output'
awall.ipsfile = 'output/ipset'
end
config = awall.Config.new()
config = awall.Config.new(testmode and {'json', 'input'})
config:test()
config:dump()
config:dump(testmode and 'output', testmode and 'output/ipset')
......@@ -17,11 +17,6 @@ require 'awall.object'
require 'awall.util'
confdirs = {'/usr/share/awall', '/etc/awall'}
iptdir = '/etc/iptables'
ipsfile = '/etc/ipset.d/awall'
local modules = {package.loaded['awall.model']}
function loadmodules(path)
......@@ -37,12 +32,12 @@ end
Config = awall.object.class(awall.object.Object)
function Config:init()
function Config:init(confdirs)
self.input = {}
self.iptables = awall.iptables.new()
for i, dir in ipairs(confdirs) do
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)
......@@ -127,9 +122,9 @@ function Config:init()
self.ipset = awall.ipset.new(self.input.ipset)
end
function Config:dump()
self.ipset:dump(ipsfile)
self.iptables:dump(iptdir)
function Config:dump(iptdir, ipsfile)
self.ipset:dump(ipsfile or '/etc/ipset.d/awall')
self.iptables:dump(iptdir or '/etc/iptables')
end
function Config:test()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment