From 8802590ef976739e08ae6e32a0b69af030d2a7df Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 14 Jul 2017 08:46:30 +0100 Subject: [Feature] Allow to set custom mempool variables from settings --- src/lua/lua_task.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index de5e57e7e..26f3da5ad 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -3480,7 +3480,8 @@ lua_task_set_settings (lua_State *L) { struct rspamd_task *task = lua_check_task (L, 1); ucl_object_t *settings; - const ucl_object_t *act, *elt, *metric_elt; + const ucl_object_t *act, *elt, *metric_elt, *vars, *cur; + ucl_object_iter_t it = NULL; struct rspamd_metric_result *mres; guint i; @@ -3520,6 +3521,20 @@ lua_task_set_settings (lua_State *L) } } + vars = ucl_object_lookup (task->settings, "variables"); + if (vars && ucl_object_type (vars) == UCL_OBJECT) { + /* Set memory pool variables */ + while ((cur = ucl_object_iterate (vars, &it, true)) != NULL) { + if (ucl_object_type (cur) == UCL_STRING) { + rspamd_mempool_set_variable (task->task_pool, + ucl_object_key (cur), rspamd_mempool_strdup ( + task->task_pool, + ucl_object_tostring (cur) + ), NULL); + } + } + } + rspamd_symbols_cache_process_settings (task, task->cfg->cache); } else { -- cgit v1.2.3