summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2013-01-24 14:01:57 +0000
committerKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2013-01-24 14:01:57 +0000
commit4a99b56ae4a9007a7067c6b2c2ecf2012c1322b6 (patch)
tree0fc85fe7c998734c9e80172799cf62de85b093b6
parent97769b1755164e9af4670daa089b84110dadf54b (diff)
downloadawall-4a99b56ae4a9007a7067c6b2c2ecf2012c1322b6.tar.bz2
awall-4a99b56ae4a9007a7067c6b2c2ecf2012c1322b6.tar.xz
table update & copy functions
clean-up of require statements in filter module
-rw-r--r--awall/modules/filter.lua20
-rw-r--r--awall/util.lua7
2 files changed, 15 insertions, 12 deletions
diff --git a/awall/modules/filter.lua b/awall/modules/filter.lua
index d833ffc..fe99366 100644
--- a/awall/modules/filter.lua
+++ b/awall/modules/filter.lua
@@ -7,19 +7,15 @@ Licensed under the terms of GPL2
module(..., package.seeall)
-require 'awall'
-require 'awall.host'
-require 'awall.model'
-require 'awall.object'
-require 'awall.optfrag'
-require 'awall.util'
+local resolve = require('awall.host').resolve
+local model = require('awall.model')
+local combinations = require('awall.optfrag').combinations
-local model = awall.model
-local combinations = awall.optfrag.combinations
-local extend = awall.util.extend
+local util = require('awall.util')
+local extend = util.extend
-local Log = awall.object.class()
+local Log = model.class()
function Log:matchopts()
return self.limit and '-m limit --limit '..self.limit..'/second'
@@ -75,7 +71,7 @@ function Filter:trules()
'ipset', 'ipsec', 'service'}) do
params[attr] = self[attr]
end
- if extra then for k, v in pairs(extra) do params[k] = v end end
+ util.update(params, extra)
return extend(res, self:create(cls, params):trules())
end
@@ -99,7 +95,7 @@ function Filter:trules()
end
local dnataddr
- for i, addr in ipairs(awall.host.resolve(self.dnat, self)) do
+ for i, addr in ipairs(resolve(self.dnat, self)) do
if addr[1] == 'inet' then
if dnataddr then
self:error(self.dnat..' resolves to multiple IPv4 addresses')
diff --git a/awall/util.lua b/awall/util.lua
index 38dab88..d86cab9 100644
--- a/awall/util.lua
+++ b/awall/util.lua
@@ -56,6 +56,13 @@ function extend(tbl1, tbl2)
for i, var in listpairs(tbl2) do table.insert(tbl1, var) end
end
+function update(tbl1, tbl2)
+ if tbl2 then for k, v in pairs(tbl2) do tbl1[k] = v end end
+ return tbl1
+end
+
+function copy(tbl) return update({}, tbl) end
+
function compare(a, b)
local t = type(a)
if t ~= type(b) then return false end