diff options
author | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2012-03-22 11:30:15 +0000 |
---|---|---|
committer | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2012-03-22 11:30:15 +0000 |
commit | 1db655ba14f38b33a05ead906dc2626c25288029 (patch) | |
tree | 68cc7d6595c14c7d35b8bd8936407236f65d0617 | |
parent | 2f571bb0e760d9fafe9f2aa958e9751703c89084 (diff) | |
download | awall-1db655ba14f38b33a05ead906dc2626c25288029.tar.bz2 awall-1db655ba14f38b33a05ead906dc2626c25288029.tar.xz |
eliminate module-level configuration variables
-rwxr-xr-x | awall-cli | 10 | ||||
-rw-r--r-- | awall/init.lua | 15 |
2 files changed, 7 insertions, 18 deletions
@@ -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') diff --git a/awall/init.lua b/awall/init.lua index 1115244..ea85aaf 100644 --- a/awall/init.lua +++ b/awall/init.lua @@ -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() |