aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2017-01-31 12:33:10 +0200
committerKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2017-01-31 12:33:10 +0200
commit5a4cb73b78f08accce72b6cf94a1cf6af9e0291e (patch)
tree29dc6f29bbf1269c789ee76d3a01aa5be98accbf
parent0df4dab4c3a900519fd4bb999cfd40bd243efd57 (diff)
downloadawall-5a4cb73b78f08accce72b6cf94a1cf6af9e0291e.tar.bz2
awall-5a4cb73b78f08accce72b6cf94a1cf6af9e0291e.tar.xz
Rule: fix corner cases for chain combinerv1.4.1
-rw-r--r--awall/model.lua24
1 files changed, 16 insertions, 8 deletions
diff --git a/awall/model.lua b/awall/model.lua
index 8ec8f8e..7e6eb81 100644
--- a/awall/model.lua
+++ b/awall/model.lua
@@ -446,7 +446,7 @@ function M.Rule:combine(ofs1, ofs2, key, unique)
end
local chainless = filter(ofs2, function(of) return not of.chain end)
- local created = {}
+ local created
local res = {}
for _, of in ipairs(ofs1) do
@@ -455,16 +455,24 @@ function M.Rule:combine(ofs1, ofs2, key, unique)
local ofs = combinations(chainless, {{family=of.family}})
assert(#ofs > 0)
- if unique then
- assert(of.family)
- if created[of.family] then return connect() end
- created[of.family] = true
+ local comb = combinations({of}, ofs)
+ if #comb < #ofs then return connect() end
- if #ofs > 1 then return connect() end
+ if unique then
+ for _, c in ipairs(comb) do
+ if c.family then
+ if not created then created = {}
+ elseif created == true or created[c.family] then
+ return connect()
+ end
+ created[c.family] = true
+ else
+ if created then return connect() end
+ created = true
+ end
+ end
end
- local comb = combinations({of}, ofs)
- if #comb < #ofs then return connect() end
extend(res, comb)
else table.insert(res, of) end