diff options
author | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2012-07-19 05:28:26 +0000 |
---|---|---|
committer | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2012-07-19 05:28:26 +0000 |
commit | fd780ffdb62d48a3ce085e0614ebd983afa78d20 (patch) | |
tree | 8faaa9e0e0afd5312910a1b04d6d658b5e41c453 | |
parent | e4df90e614b9ecb9d3dc312c95238dc38b2f775d (diff) | |
download | awall-fd780ffdb62d48a3ce085e0614ebd983afa78d20.tar.bz2 awall-fd780ffdb62d48a3ce085e0614ebd983afa78d20.tar.xz |
consistent chain names in level 5 dump
-rw-r--r-- | awall/model.lua | 18 | ||||
-rw-r--r-- | awall/modules/filter.lua | 3 | ||||
-rw-r--r-- | awall/modules/mark.lua | 7 |
3 files changed, 15 insertions, 13 deletions
diff --git a/awall/model.lua b/awall/model.lua index 2813d8b..4fff0b3 100644 --- a/awall/model.lua +++ b/awall/model.lua @@ -89,6 +89,8 @@ Rule = class(ConfigObject) function Rule:init(...) ConfigObject.init(self, unpack(arg)) + self.newchains = {} + for i, prop in ipairs({'in', 'out'}) do self[prop] = self[prop] and util.maplist(self[prop], function(z) @@ -368,14 +370,20 @@ end function Rule:extraoptfrags() return {} end -function Rule:newchain(base) +function Rule:newchain(key) + if self.newchains[key] then return self.newchains[key] end + if not self.context.lastid then self.context.lastid = {} end local lastid = self.context.lastid - if self.label then base = base..'-'..self.label end - if not lastid[base] then lastid[base] = -1 end - lastid[base] = lastid[base] + 1 - return base..'-'..lastid[base] + local res = key + if self.label then res = res..'-'..self.label end + if not lastid[res] then lastid[res] = -1 end + lastid[res] = lastid[res] + 1 + res = res..'-'..lastid[res] + + self.newchains[key] = res + return res end diff --git a/awall/modules/filter.lua b/awall/modules/filter.lua index b851234..5da8f91 100644 --- a/awall/modules/filter.lua +++ b/awall/modules/filter.lua @@ -95,8 +95,7 @@ end function Filter:target() if not self:limit() then return model.Rule.target(self) end - if not self['limit-target'] then self['limit-target'] = self:newchain('limit') end - return self['limit-target'] + return self:newchain('limit') end function Filter:extraoptfrags() diff --git a/awall/modules/mark.lua b/awall/modules/mark.lua index 1122ab4..bdc469c 100644 --- a/awall/modules/mark.lua +++ b/awall/modules/mark.lua @@ -26,12 +26,7 @@ end local RouteTrackRule = model.class(MarkRule) -function RouteTrackRule:target() - if not self['mark-target'] then - self['mark-target'] = self:newchain('mark') - end - return self['mark-target'] -end +function RouteTrackRule:target() return self:newchain('mark') end function RouteTrackRule:servoptfrags() return awall.optfrag.combinations(MarkRule.servoptfrags(self), |