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

make class tables callable

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