Commit 93df7260 authored by Marek Vavruša's avatar Marek Vavruša

daemon/lua: use default config after the config is processed

i.e. if the user doesn't set the cache, it will be applied later
if he sets it, it will stay
parent 41a76626
......@@ -416,6 +416,7 @@ static int cache_open(lua_State *L)
lua_pushstring(L, "current_storage");
lua_pushstring(L, uri);
lua_rawset(L, -3);
lua_pop(L, 1);
lua_pushboolean(L, 1);
return 1;
......@@ -425,6 +426,11 @@ static int cache_close(lua_State *L)
{
struct engine *engine = engine_luaget(L);
kr_cache_close(&engine->resolver.cache);
lua_getglobal(L, "cache");
lua_pushstring(L, "current_size");
lua_pushnumber(L, 0);
lua_rawset(L, -3);
lua_pop(L, 1);
lua_pushboolean(L, 1);
return 1;
}
......
......@@ -323,6 +323,8 @@ static int init_state(struct engine *engine)
lua_setglobal(engine->L, "verbose");
lua_pushcfunction(engine->L, l_option);
lua_setglobal(engine->L, "option");
lua_pushcfunction(engine->L, l_setuser);
lua_setglobal(engine->L, "user");
lua_pushcfunction(engine->L, l_libpath);
lua_setglobal(engine->L, "libpath");
lua_pushlightuserdata(engine->L, engine);
......@@ -448,7 +450,8 @@ static int engine_loadconf(struct engine *engine)
/* Load config file */
if(access("config", F_OK ) != -1 ) {
ret = l_dosandboxfile(engine->L, "config");
} else {
}
if (ret == 0) {
/* Load defaults */
static const char config_bytecode[] = {
#include "daemon/lua/config.inc"
......
......@@ -3,4 +3,8 @@ 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
-- Open cache if not set/disabled
if not cache.current_size then
cache.size = 10 * MB
end
\ No newline at end of file
......@@ -78,8 +78,6 @@ setmetatable(cache, {
else rawset(t, k, v) end
end
})
-- Defaults
cache.size = 10 * MB
-- Syntactic sugar for TA store
setmetatable(trust_anchors, {
......
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