aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--awall/model.lua12
-rw-r--r--awall/util.lua6
2 files changed, 11 insertions, 7 deletions
diff --git a/awall/model.lua b/awall/model.lua
index b902787..cfe29cd 100644
--- a/awall/model.lua
+++ b/awall/model.lua
@@ -265,13 +265,11 @@ function Rule:trules()
local function ffilter(ofrags)
if not ofrags or not ofrags[1] or not families then return ofrags end
- local res = {}
- for i, ofrag in util.listpairs(ofrags) do
- if not ofrag.family or util.contains(families, ofrag.family) then
- table.insert(res, ofrag)
- end
- end
- return res
+ return util.filter(ofrags,
+ function(of)
+ return not of.family or util.contains(families,
+ of.family)
+ end)
end
local function appendtarget(ofrag, target)
diff --git a/awall/util.lua b/awall/util.lua
index 55be6bd..8963a5c 100644
--- a/awall/util.lua
+++ b/awall/util.lua
@@ -18,6 +18,12 @@ function listpairs(var)
return ipairs(list(var))
end
+function filter(var, func)
+ local res = {}
+ for i, v in ipairs(var) do if func(v) then table.insert(res, v) end end
+ return res
+end
+
function map(var, func)
local res = {}
for k, v in pairs(var) do res[k] = func(v) end