diff options
author | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2012-02-16 14:39:51 +0000 |
---|---|---|
committer | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2012-02-16 14:39:51 +0000 |
commit | 8cc299ff8a604f5a370e41d20ab1b504a9dc53d0 (patch) | |
tree | d8aaf59ea422e9a241dfe84e114faaf09012aa6d | |
parent | d45c00925e238594f6bb79519e6fa7f250ba87a8 (diff) | |
download | awall-8cc299ff8a604f5a370e41d20ab1b504a9dc53d0.tar.bz2 awall-8cc299ff8a604f5a370e41d20ab1b504a9dc53d0.tar.xz |
descriptive chain names
-rw-r--r-- | awall/model.lua | 20 | ||||
-rw-r--r-- | awall/modules/filter.lua | 2 |
2 files changed, 13 insertions, 9 deletions
diff --git a/awall/model.lua b/awall/model.lua index 3665d7f..6e5fb3b 100644 --- a/awall/model.lua +++ b/awall/model.lua @@ -16,13 +16,6 @@ local util = awall.util local combinations = awall.optfrag.combinations -local lastid = -1 -function newchain() - lastid = lastid + 1 - return 'awall-'..lastid -end - - function class(base) local cls = {} local mt = {__index = cls} @@ -88,6 +81,7 @@ Rule = class(Object) function Rule:init() local config = awall.config + for i, prop in ipairs({'in', 'out'}) do self[prop] = self[prop] and util.maplist(self[prop], function(z) @@ -96,7 +90,9 @@ function Rule:init() error('Invalid zone: '..z) end) or self:defaultzones() end + if self.service then + if type(self.service) == 'string' then self.label = self.service end self.service = util.maplist(self.service, function(s) return config.service[s] or error('Invalid service: '..s) @@ -307,7 +303,7 @@ function Rule:trules() local target if addrchain then - target = newchain() + target = self:newchain('address') else target = self:target() if addrofrags then res = combinations(res, addrofrags) end @@ -334,6 +330,14 @@ end function Rule:extraoptfrags() return {} end +local lastid = {} +function Rule:newchain(base) + 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] +end + classmap = {zone=Zone} diff --git a/awall/modules/filter.lua b/awall/modules/filter.lua index cc579f9..d4d7b73 100644 --- a/awall/modules/filter.lua +++ b/awall/modules/filter.lua @@ -31,7 +31,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'] = model.newchain() end + if not self['limit-target'] then self['limit-target'] = self:newchain('limit') end return self['limit-target'] end |