Commit 249fa602 authored by Marek Vavruša's avatar Marek Vavruša

daemon/lua: kB/MB/GB in env, net.iface sugar, env

parent 929b06de
-- Default configuration
cache.open('.', 10485760)
cache.open(10*MB)
-- Listen on localhost
if not next(net.list()) then
if not pcall(net.listen, '127.0.0.1') then
error('failed to bind to localhost#53')
end
end
\ No newline at end of file
-- Units
kB = 1024
MB = 1024*1024
GB = 1024*1024
-- Function aliases
-- `env.VAR returns os.getenv(VAR)`
env = {}
setmetatable(env, {
__index = function (t, k) return os.getenv(k) end
})
-- Quick access to interfaces
-- `net.<iface>` => `net.interfaces()[iface]`
setmetatable(net, {
__index = function (t, k)
local v = rawget(t, k)
if v then return v
else return net.interfaces()[k]
end
end
})
-- Syntactic sugar for module loading
-- `modules.<name> = <config>`
setmetatable(modules, {
......
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