Commit 217b5319 authored by Kaarle Ritvanen's avatar Kaarle Ritvanen

make class tables callable

parent 385bd779
...@@ -126,7 +126,7 @@ if not uerror.call( ...@@ -126,7 +126,7 @@ if not uerror.call(
require 'awall' require 'awall'
policyset = awall.PolicySet.new(pol_paths) policyset = awall.PolicySet(pol_paths)
if mode == 'list' then if mode == 'list' then
imported = policyset:load().policies imported = policyset:load().policies
...@@ -174,7 +174,7 @@ if not uerror.call( ...@@ -174,7 +174,7 @@ if not uerror.call(
if mode ~= 'dump' or level > 3 then if mode ~= 'dump' or level > 3 then
awall.loadmodules(basedir) awall.loadmodules(basedir)
config = awall.Config.new(input) config = awall.Config(input)
end end
......
...@@ -80,7 +80,7 @@ Config = object.class() ...@@ -80,7 +80,7 @@ Config = object.class()
function Config:init(policyconfig) function Config:init(policyconfig)
self.objects = policyconfig:expand() self.objects = policyconfig:expand()
self.iptables = iptables.IPTables.new() self.iptables = iptables.IPTables()
local acfrags = {} local acfrags = {}
...@@ -138,7 +138,7 @@ function Config:init(policyconfig) ...@@ -138,7 +138,7 @@ function Config:init(policyconfig)
for k, v in pairs(acfrags) do table.insert(ofrags, v) end for k, v in pairs(acfrags) do table.insert(ofrags, v) end
insertrules(optfrag.combinations(achains, ofrags)) insertrules(optfrag.combinations(achains, ofrags))
self.ipset = ipset.IPSet.new(self.objects.ipset) self.ipset = ipset.IPSet(self.objects.ipset)
end end
function Config:print() function Config:print()
......
--[[ --[[
Iptables file dumper for Alpine Wall Iptables file dumper for Alpine Wall
Copyright (C) 2012-2013 Kaarle Ritvanen Copyright (C) 2012-2014 Kaarle Ritvanen
See LICENSE file for license details See LICENSE file for license details
]]-- ]]--
...@@ -142,15 +142,15 @@ end ...@@ -142,15 +142,15 @@ end
function backup() function backup()
lfs.mkdir(backupdir) lfs.mkdir(backupdir)
Current.new():dump(backupdir) Current():dump(backupdir)
end end
function revert() function revert()
Backup.new():activate() Backup():activate()
end end
function flush() function flush()
local empty = IPTables.new() local empty = IPTables()
for family, params in pairs(families) do for family, params in pairs(families) do
local success, lines = pcall(io.lines, params.procfile) local success, lines = pcall(io.lines, params.procfile)
if success then if success then
......
...@@ -97,7 +97,7 @@ function Zone:optfrags(dir) ...@@ -97,7 +97,7 @@ function Zone:optfrags(dir)
end end
fwzone = Zone.new() fwzone = Zone()
IPSet = class(ConfigObject) IPSet = class(ConfigObject)
......
...@@ -9,20 +9,19 @@ module(..., package.seeall) ...@@ -9,20 +9,19 @@ module(..., package.seeall)
function class(base) function class(base)
local cls = {} local cls = {}
local mt = {__index = cls}
if not base and Object then base = Object end
if base then setmetatable(cls, {__index = base}) end
function cls.new(...) return cls.morph({}, ...) end
function cls:morph(...) function cls:morph(...)
setmetatable(self, mt) setmetatable(self, {__index = cls})
self:init(...) self:init(...)
return self return self
end end
return cls local mt = {__call=function(self, ...) return cls.morph({}, ...) end}
if not base and Object then base = Object end
if base then mt.__index = base end
return setmetatable(cls, mt)
end end
Object = class() Object = class()
......
...@@ -225,5 +225,5 @@ function PolicySet:load() ...@@ -225,5 +225,5 @@ function PolicySet:load()
end end
end end
return PolicyConfig.new(input, source, util.keys(imported)) return PolicyConfig(input, source, util.keys(imported))
end end
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