Commit b4fb57b3 authored by Kaarle Ritvanen's avatar Kaarle Ritvanen

dynamically discover classes in ConfigObject.create

parent 7481a54f
...@@ -30,6 +30,13 @@ function ConfigObject:init(context, location) ...@@ -30,6 +30,13 @@ function ConfigObject:init(context, location)
end end
function ConfigObject:create(cls, params) function ConfigObject:create(cls, params)
if type(cls) == 'string' then
local name = cls
cls = awall.classmap[cls]
if not cls then
self:error('Support for '' objects not installed')
return cls.morph(params, self.context, self.location) return cls.morph(params, self.context, self.location)
end end
...@@ -69,9 +69,7 @@ function Filter:trules() ...@@ -69,9 +69,7 @@ function Filter:trules()
dnat[attr] = self[attr] dnat[attr] = self[attr]
end end
if not awall.classmap.dnat then self:error('NAT module not installed') end awall.util.extend(res, self:create('dnat', dnat):trules())
awall.util.extend(res, self:create(awall.classmap.dnat, dnat):trules())
end end
awall.util.extend(res, model.Rule.trules(self)) awall.util.extend(res, model.Rule.trules(self))
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment