diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-07-14 08:46:30 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-07-14 08:46:30 +0100 |
commit | 8802590ef976739e08ae6e32a0b69af030d2a7df (patch) | |
tree | d1924bb0f73b349d10ab4e6c36beb182023e02b8 /src | |
parent | 621525735fbf2bf075629818dbabe28431a40a66 (diff) | |
download | rspamd-8802590ef976739e08ae6e32a0b69af030d2a7df.tar.gz rspamd-8802590ef976739e08ae6e32a0b69af030d2a7df.zip |
[Feature] Allow to set custom mempool variables from settings
Diffstat (limited to 'src')
-rw-r--r-- | src/lua/lua_task.c | 17 |
1 files changed, 16 insertions, 1 deletions
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 { |