Commit 4a99b56a authored by Kaarle Ritvanen's avatar Kaarle Ritvanen
Browse files

table update & copy functions

clean-up of require statements in filter module
parent 97769b17
......@@ -7,19 +7,15 @@ Licensed under the terms of GPL2
module(..., package.seeall)
require 'awall'
require ''
require 'awall.model'
require 'awall.object'
require 'awall.optfrag'
require 'awall.util'
local resolve = require('').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]
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())
......@@ -99,7 +95,7 @@ function Filter:trules()
local dnataddr
for i, addr in ipairs(, 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')
......@@ -56,6 +56,13 @@ function extend(tbl1, tbl2)
for i, var in listpairs(tbl2) do table.insert(tbl1, var) end
function update(tbl1, tbl2)
if tbl2 then for k, v in pairs(tbl2) do tbl1[k] = v end end
return tbl1
function copy(tbl) return update({}, tbl) end
function compare(a, b)
local t = type(a)
if t ~= type(b) then return false 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