diff options
author | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2014-03-31 11:34:09 +0300 |
---|---|---|
committer | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2014-03-31 19:07:51 +0300 |
commit | 217b5319f8adb7d979c17fa7eff34f0f7fa14a3f (patch) | |
tree | f8441c5037e9f51a975d684bd2bfc0dd0a8e6280 | |
parent | 385bd7791ee1a11a8ab017f260013b5d8080703f (diff) | |
download | awall-217b5319f8adb7d979c17fa7eff34f0f7fa14a3f.tar.bz2 awall-217b5319f8adb7d979c17fa7eff34f0f7fa14a3f.tar.xz |
make class tables callable
-rwxr-xr-x | awall-cli | 4 | ||||
-rw-r--r-- | awall/init.lua | 4 | ||||
-rw-r--r-- | awall/iptables.lua | 8 | ||||
-rw-r--r-- | awall/model.lua | 2 | ||||
-rw-r--r-- | awall/object.lua | 15 | ||||
-rw-r--r-- | awall/policy.lua | 2 |
6 files changed, 17 insertions, 18 deletions
@@ -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 diff --git a/awall/init.lua b/awall/init.lua index f3dcaab..1bdc299 100644 --- a/awall/init.lua +++ b/awall/init.lua @@ -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() diff --git a/awall/iptables.lua b/awall/iptables.lua index f4190f0..e8f9374 100644 --- a/awall/iptables.lua +++ b/awall/iptables.lua @@ -1,6 +1,6 @@ --[[ 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 diff --git a/awall/model.lua b/awall/model.lua index b0da33b..9de7aae 100644 --- a/awall/model.lua +++ b/awall/model.lua @@ -97,7 +97,7 @@ function Zone:optfrags(dir) end -fwzone = Zone.new() +fwzone = Zone() IPSet = class(ConfigObject) diff --git a/awall/object.lua b/awall/object.lua index 17062ec..64cccfe 100644 --- a/awall/object.lua +++ b/awall/object.lua @@ -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() diff --git a/awall/policy.lua b/awall/policy.lua index 36f319b..1d66656 100644 --- a/awall/policy.lua +++ b/awall/policy.lua @@ -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 |