aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2015-12-23 10:43:01 +0200
committerKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2015-12-23 10:43:12 +0200
commit7252006ece7548fec71140525a501c4c3211eaab (patch)
treecce5fac7332f1c433066f7840b757280e39f5afe
parentf9ea97f87470bbd3425b7448a136065d1d31ce6f (diff)
downloadawall-7252006ece7548fec71140525a501c4c3211eaab.tar.bz2
awall-7252006ece7548fec71140525a501c4c3211eaab.tar.xz
generalize extrarules function
-rw-r--r--awall/model.lua18
-rw-r--r--awall/modules/filter.lua13
-rw-r--r--awall/util.lua3
3 files changed, 22 insertions, 12 deletions
diff --git a/awall/model.lua b/awall/model.lua
index c4ac0ac..648de6c 100644
--- a/awall/model.lua
+++ b/awall/model.lua
@@ -567,6 +567,24 @@ end
function M.Rule:extraoptfrags() return {} end
+function M.Rule:extrarules(label, cls, options)
+ local params = {}
+
+ for _, attr in ipairs(
+ extend(
+ {'in', 'out', 'src', 'dest', 'ipset', 'ipsec', 'service'},
+ options.attrs
+ )
+ ) do
+ params[attr] = (options.src or self)[attr]
+ end
+
+ util.update(params, options.update)
+ if options.discard then params[options.discard] = nil end
+
+ return self:create(cls, params, label, options.index):trules()
+end
+
M.Limit = M.class(M.ConfigObject)
diff --git a/awall/modules/filter.lua b/awall/modules/filter.lua
index 6bf7438..175ffc1 100644
--- a/awall/modules/filter.lua
+++ b/awall/modules/filter.lua
@@ -213,17 +213,8 @@ function Filter:trules()
local function extrarules(label, cls, options)
options = options or {}
-
- local params = {}
- for i, attr in ipairs(
- {'in', 'out', 'src', 'dest', 'dnat', 'ipset', 'ipsec', 'service'}
- ) do
- params[attr] = (options.src or self)[attr]
- end
- util.update(params, options.update)
- if options.discard then params[options.discard] = nil end
-
- extend(res, self:create(cls, params, label, options.index):trules())
+ options.attrs = 'dnat'
+ extend(res, self:extrarules(label, cls, options))
end
if self.dnat then
diff --git a/awall/util.lua b/awall/util.lua
index f6720bd..0057cd2 100644
--- a/awall/util.lua
+++ b/awall/util.lua
@@ -1,6 +1,6 @@
--[[
Utility module for Alpine Wall
-Copyright (C) 2012-2014 Kaarle Ritvanen
+Copyright (C) 2012-2015 Kaarle Ritvanen
See LICENSE file for license details
]]--
@@ -72,6 +72,7 @@ end
function M.extend(tbl1, tbl2)
for i, var in M.listpairs(tbl2) do table.insert(tbl1, var) end
+ return tbl1
end
function M.update(tbl1, tbl2)