Commit b9fd92a8 authored by Kaarle Ritvanen's avatar Kaarle Ritvanen

Config object initialization from PolicySet

parent 4f40a36c
......@@ -46,30 +46,28 @@ for switch, value in pairs(alt_getopt.get_opts(arg, short_opts, long_opts)) do
end
require 'awall.policy'
require 'awall'
policyset = awall.PolicySet.new(params.i, params.I)
for i, action in ipairs({'disable', 'enable'}) do
for i, policy in ipairs(params[string.sub(action, 1, 1)]) do
policyset = policyset or awall.policy.PolicySet.new(params.i, params.I)
policyset[action](policyset, policy, confdir, import)
exit = true
end
end
if policyset then os.exit() end
if exit then os.exit() end
if mode == 'l' then
for name, status in awall.policy.PolicySet.new(params.i,
params.I):list() do
print(name, status)
end
for name, status in policyset:list() do print(name, status) end
os.exit()
end
require 'awall'
require 'awall.iptables'
awall.loadmodules(basedir)
config = awall.Config.new(params.i, params.I)
config = awall.Config.new(policyset)
if mode == 'a' then
......
......@@ -51,11 +51,14 @@ function loadmodules(path)
end
PolicySet = policy.PolicySet
Config = object.class(object.Object)
function Config:init(confdirs, importdirs)
function Config:init(policyset)
self.input = policy.PolicySet.new(confdirs, importdirs):load()
self.input = policyset:load()
self.iptables = iptables.IPTables.new()
local function expandvars(obj)
......
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