LUA_FUNCTION_DEF (config, load_ucl);
/***
- * @method rspamd_config:parce_rcl([skip_sections])
+ * @method rspamd_config:parse_rcl([skip_sections])
* Parses RCL using loaded ucl file
* @param {table|string} sections to skip
* @return true or false + error message
*/
LUA_FUNCTION_DEF (config, parse_rcl);
+/***
+ * @method rspamd_config:init_modules()
+ * Initialize lua and internal modules
+ * @return true or false
+ */
+LUA_FUNCTION_DEF (config, init_modules);
+
static const struct luaL_reg configlib_m[] = {
LUA_INTERFACE_DEF (config, get_module_opt),
LUA_INTERFACE_DEF (config, get_mempool),
LUA_INTERFACE_DEF (config, experimental_enabled),
LUA_INTERFACE_DEF (config, load_ucl),
LUA_INTERFACE_DEF (config, parse_rcl),
+ LUA_INTERFACE_DEF (config, init_modules),
{"__tostring", rspamd_lua_class_tostring},
{"__newindex", lua_config_newindex},
{NULL, NULL}
return 1;
}
+static gint
+lua_config_init_modules (lua_State *L)
+{
+ struct rspamd_config *cfg = lua_check_config (L, 1);
+
+ if (cfg != NULL) {
+ rspamd_lua_post_load_config (cfg);
+ lua_pushboolean (L, rspamd_init_filters (cfg, FALSE));
+ }
+ else {
+ return luaL_error (L, "invalid arguments");
+ }
+
+ return 1;
+}
+
static gint
lua_monitored_alive (lua_State *L)
{
struct rspamd_main *rspamd_main = NULL;
lua_State *L = NULL;
+/* Defined in modules.c */
+extern module_t *modules[];
+extern worker_t *workers[];
+
static void rspamadm_help (gint argc, gchar **argv, const struct rspamadm_command *);
static const char* rspamadm_help_help (gboolean full_help, const struct rspamadm_command *);
const struct rspamadm_command *cmd;
GPtrArray *all_commands = g_ptr_array_new (); /* Discovered during check */
gint i, nargc, targc;
+ worker_t **pworker;
ucl_vars = g_hash_table_new_full (rspamd_strcase_hash,
rspamd_strcase_equal, g_free, g_free);
rspamd_config_post_load (cfg,
RSPAMD_CONFIG_INIT_LIBS|RSPAMD_CONFIG_INIT_URL|RSPAMD_CONFIG_INIT_NO_TLD);
+ pworker = &workers[0];
+ while (*pworker) {
+ /* Init string quarks */
+ (void) g_quark_from_static_string ((*pworker)->name);
+ pworker++;
+ }
+
+ cfg->compiled_modules = modules;
+ cfg->compiled_workers = workers;
+
gperf_profiler_init (cfg, "rspamadm");
setproctitle ("rspamdadm");