Commit 9578293b authored by Marek Vavruša's avatar Marek Vavruša

daemon/lua: use rawget/rawset to avoid metatable evaluation

parent e79ca30a
...@@ -25,12 +25,13 @@ setmetatable(net, { ...@@ -25,12 +25,13 @@ setmetatable(net, {
-- `modules.<name> = <config>` -- `modules.<name> = <config>`
setmetatable(modules, { setmetatable(modules, {
__newindex = function (t,k,v) __newindex = function (t,k,v)
modules.load(k) if not rawget(_G, k) then
if _G[k] then modules.load(k)
local config_call = _G[k]['config'] local mod = rawget(_G, k)
if config_call and config_call[''] then if mod and mod['config'] then
config_call(v) mod['config'](v)
end end
end end
end end
}) })
...@@ -42,12 +43,12 @@ function modules_register(module) ...@@ -42,12 +43,12 @@ function modules_register(module)
__index = function (t, k) __index = function (t, k)
local v = rawget(t, k) local v = rawget(t, k)
if v then return v if v then return v
elseif t.get then return t.get(k) elseif rawget(t, 'get') then return t.get(k)
end end
end, end,
__newindex = function (t, k, v) __newindex = function (t, k, v)
local old_v = rawget(t, k) local old_v = rawget(t, k)
if not old_v and t.set then if not old_v and rawget(t, 'set') then
t.set(k..' '..v) t.set(k..' '..v)
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment