@@ -145,7 +145,7 @@ struct rspamd_controller_worker_ctx { | |||
/* SSL private key */ | |||
gchar *ssl_key; | |||
/* A map of secure IP */ | |||
GList *secure_ip; | |||
const ucl_object_t *secure_ip; | |||
radix_compressed_t *secure_map; | |||
/* Static files dir */ | |||
@@ -2490,7 +2490,7 @@ init_controller_worker (struct rspamd_config *cfg) | |||
rspamd_rcl_register_worker_option (cfg, | |||
type, | |||
"secure_ip", | |||
rspamd_rcl_parse_struct_string_list, | |||
rspamd_rcl_parse_struct_ucl, | |||
ctx, | |||
G_STRUCT_OFFSET (struct rspamd_controller_worker_ctx, secure_ip), | |||
0, | |||
@@ -2499,7 +2499,7 @@ init_controller_worker (struct rspamd_config *cfg) | |||
rspamd_rcl_register_worker_option (cfg, | |||
type, | |||
"trusted_ips", | |||
rspamd_rcl_parse_struct_string_list, | |||
rspamd_rcl_parse_struct_ucl, | |||
ctx, | |||
G_STRUCT_OFFSET (struct rspamd_controller_worker_ctx, secure_ip), | |||
0, | |||
@@ -2545,12 +2545,12 @@ void | |||
start_controller_worker (struct rspamd_worker *worker) | |||
{ | |||
struct rspamd_controller_worker_ctx *ctx = worker->ctx; | |||
GList *cur; | |||
struct module_ctx *mctx; | |||
GHashTableIter iter; | |||
gpointer key, value; | |||
struct rspamd_keypair_cache *cache; | |||
gchar *secure_ip; | |||
const ucl_object_t *cur; | |||
ucl_object_iter_t it = NULL; | |||
gpointer m; | |||
ctx->ev_base = rspamd_prepare_worker (worker, | |||
@@ -2565,26 +2565,31 @@ start_controller_worker (struct rspamd_worker *worker) | |||
ctx->custom_commands = g_hash_table_new (rspamd_strcase_hash, | |||
rspamd_strcase_equal); | |||
if (ctx->secure_ip != NULL) { | |||
cur = ctx->secure_ip; | |||
while (cur) { | |||
secure_ip = cur->data; | |||
/* Try map syntax */ | |||
if (!rspamd_map_is_map (secure_ip)) { | |||
if (!radix_add_generic_iplist (secure_ip, | |||
&ctx->secure_map)) { | |||
msg_warn_ctx ("cannot load or parse ip list from '%s'", | |||
secure_ip); | |||
if (ucl_object_type (ctx->secure_ip) == UCL_ARRAY) { | |||
while ((cur = ucl_object_iterate (ctx->secure_ip, &it, true)) != NULL) { | |||
/* Try map syntax */ | |||
if (ucl_object_type (cur) == UCL_STRING && | |||
!rspamd_map_is_map (ucl_object_tostring (cur))) { | |||
if (!radix_add_generic_iplist (ucl_object_tostring (cur), | |||
&ctx->secure_map)) { | |||
msg_warn_ctx ("cannot load or parse ip list from '%s'", | |||
ucl_object_tostring (cur)); | |||
} | |||
} | |||
else { | |||
rspamd_map_add_from_ucl (worker->srv->cfg, cur, | |||
"Allow webui access from the specified IP", | |||
rspamd_radix_read, rspamd_radix_fin, | |||
(void **)&ctx->secure_map); | |||
} | |||
} | |||
else { | |||
rspamd_map_add (worker->srv->cfg, secure_ip, | |||
} | |||
else { | |||
rspamd_map_add_from_ucl (worker->srv->cfg, ctx->secure_ip, | |||
"Allow webui access from the specified IP", | |||
rspamd_radix_read, rspamd_radix_fin, | |||
(void **)&ctx->secure_map); | |||
} | |||
cur = g_list_next (cur); | |||
} | |||
} | |||
@@ -271,13 +271,14 @@ dkim_module_config (struct rspamd_config *cfg) | |||
} | |||
if ((value = | |||
rspamd_config_get_module_opt (cfg, "dkim", "whitelist")) != NULL) { | |||
str = ucl_obj_tostring (value); | |||
if (!rspamd_map_is_map (str)) { | |||
if (str && !rspamd_map_is_map (str)) { | |||
radix_add_generic_iplist (str, | |||
&dkim_module_ctx->whitelist_ip); | |||
} | |||
else { | |||
rspamd_map_add (cfg, str, | |||
rspamd_map_add_from_ucl (cfg, value, | |||
"DKIM whitelist", rspamd_radix_read, rspamd_radix_fin, | |||
(void **)&dkim_module_ctx->whitelist_ip); | |||
@@ -285,7 +286,7 @@ dkim_module_config (struct rspamd_config *cfg) | |||
} | |||
if ((value = | |||
rspamd_config_get_module_opt (cfg, "dkim", "domains")) != NULL) { | |||
if (!rspamd_map_add (cfg, ucl_obj_tostring (value), | |||
if (!rspamd_map_add_from_ucl (cfg, value, | |||
"DKIM domains", rspamd_kv_list_read, rspamd_kv_list_fin, | |||
(void **)&dkim_module_ctx->dkim_domains)) { | |||
msg_warn_config ("cannot load dkim domains list from %s", | |||
@@ -297,7 +298,7 @@ dkim_module_config (struct rspamd_config *cfg) | |||
} | |||
if (!got_trusted && (value = | |||
rspamd_config_get_module_opt (cfg, "dkim", "trusted_domains")) != NULL) { | |||
if (!rspamd_map_add (cfg, ucl_obj_tostring (value), | |||
if (!rspamd_map_add_from_ucl (cfg, value, | |||
"DKIM domains", rspamd_kv_list_read, rspamd_kv_list_fin, | |||
(void **)&dkim_module_ctx->dkim_domains)) { | |||
msg_warn_config ("cannot load dkim domains list from %s", |
@@ -832,12 +832,12 @@ fuzzy_check_module_config (struct rspamd_config *cfg) | |||
str = ucl_obj_tostring (value); | |||
if (!rspamd_map_is_map (str)) { | |||
if (str && !rspamd_map_is_map (str)) { | |||
radix_add_generic_iplist (str, | |||
&fuzzy_module_ctx->whitelist); | |||
} | |||
else { | |||
rspamd_map_add (cfg, str, | |||
rspamd_map_add_from_ucl (cfg, value, | |||
"Fuzzy whitelist", rspamd_radix_read, rspamd_radix_fin, | |||
(void **)&fuzzy_module_ctx->whitelist); | |||
@@ -213,12 +213,12 @@ spf_module_config (struct rspamd_config *cfg) | |||
str = ucl_obj_tostring (value); | |||
if (!rspamd_map_is_map (str)) { | |||
if (str && !rspamd_map_is_map (str)) { | |||
radix_add_generic_iplist (str, | |||
&spf_module_ctx->whitelist_ip); | |||
} | |||
else { | |||
rspamd_map_add (cfg, str, | |||
rspamd_map_add_from_ucl (cfg, value, | |||
"SPF whitelist", rspamd_radix_read, rspamd_radix_fin, | |||
(void **)&spf_module_ctx->whitelist_ip); | |||
@@ -528,7 +528,7 @@ surbl_module_config (struct rspamd_config *cfg) | |||
if ((value = | |||
rspamd_config_get_module_opt (cfg, "surbl", | |||
"redirector_hosts_map")) != NULL) { | |||
if (!rspamd_map_add (cfg, ucl_obj_tostring (value), | |||
if (!rspamd_map_add_from_ucl (cfg, value, | |||
"SURBL redirectors list", read_redirectors_list, fin_redirectors_list, | |||
(void **)&surbl_module_ctx->redirector_map_data)) { | |||
@@ -546,7 +546,7 @@ surbl_module_config (struct rspamd_config *cfg) | |||
} | |||
if ((value = | |||
rspamd_config_get_module_opt (cfg, "surbl", "exceptions")) != NULL) { | |||
if (rspamd_map_add (cfg, ucl_obj_tostring (value), | |||
if (rspamd_map_add_from_ucl (cfg, value, | |||
"SURBL exceptions list", read_exceptions_list, fin_exceptions_list, | |||
(void **)&surbl_module_ctx->exceptions)) { | |||
surbl_module_ctx->tld2_file = rspamd_mempool_strdup ( | |||
@@ -556,7 +556,7 @@ surbl_module_config (struct rspamd_config *cfg) | |||
} | |||
if ((value = | |||
rspamd_config_get_module_opt (cfg, "surbl", "whitelist")) != NULL) { | |||
if (rspamd_map_add (cfg, ucl_obj_tostring (value), | |||
if (rspamd_map_add_from_ucl (cfg, value, | |||
"SURBL whitelist", rspamd_hosts_read, rspamd_hosts_fin, | |||
(void **)&surbl_module_ctx->whitelist)) { | |||
surbl_module_ctx->whitelist_file = rspamd_mempool_strdup ( |