/* SSL private key */ | /* SSL private key */ | ||||
gchar *ssl_key; | gchar *ssl_key; | ||||
/* A map of secure IP */ | /* A map of secure IP */ | ||||
GList *secure_ip; | |||||
const ucl_object_t *secure_ip; | |||||
radix_compressed_t *secure_map; | radix_compressed_t *secure_map; | ||||
/* Static files dir */ | /* Static files dir */ | ||||
rspamd_rcl_register_worker_option (cfg, | rspamd_rcl_register_worker_option (cfg, | ||||
type, | type, | ||||
"secure_ip", | "secure_ip", | ||||
rspamd_rcl_parse_struct_string_list, | |||||
rspamd_rcl_parse_struct_ucl, | |||||
ctx, | ctx, | ||||
G_STRUCT_OFFSET (struct rspamd_controller_worker_ctx, secure_ip), | G_STRUCT_OFFSET (struct rspamd_controller_worker_ctx, secure_ip), | ||||
0, | 0, | ||||
rspamd_rcl_register_worker_option (cfg, | rspamd_rcl_register_worker_option (cfg, | ||||
type, | type, | ||||
"trusted_ips", | "trusted_ips", | ||||
rspamd_rcl_parse_struct_string_list, | |||||
rspamd_rcl_parse_struct_ucl, | |||||
ctx, | ctx, | ||||
G_STRUCT_OFFSET (struct rspamd_controller_worker_ctx, secure_ip), | G_STRUCT_OFFSET (struct rspamd_controller_worker_ctx, secure_ip), | ||||
0, | 0, | ||||
start_controller_worker (struct rspamd_worker *worker) | start_controller_worker (struct rspamd_worker *worker) | ||||
{ | { | ||||
struct rspamd_controller_worker_ctx *ctx = worker->ctx; | struct rspamd_controller_worker_ctx *ctx = worker->ctx; | ||||
GList *cur; | |||||
struct module_ctx *mctx; | struct module_ctx *mctx; | ||||
GHashTableIter iter; | GHashTableIter iter; | ||||
gpointer key, value; | gpointer key, value; | ||||
struct rspamd_keypair_cache *cache; | struct rspamd_keypair_cache *cache; | ||||
gchar *secure_ip; | |||||
const ucl_object_t *cur; | |||||
ucl_object_iter_t it = NULL; | |||||
gpointer m; | gpointer m; | ||||
ctx->ev_base = rspamd_prepare_worker (worker, | ctx->ev_base = rspamd_prepare_worker (worker, | ||||
ctx->custom_commands = g_hash_table_new (rspamd_strcase_hash, | ctx->custom_commands = g_hash_table_new (rspamd_strcase_hash, | ||||
rspamd_strcase_equal); | rspamd_strcase_equal); | ||||
if (ctx->secure_ip != NULL) { | 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", | "Allow webui access from the specified IP", | ||||
rspamd_radix_read, rspamd_radix_fin, | rspamd_radix_read, rspamd_radix_fin, | ||||
(void **)&ctx->secure_map); | (void **)&ctx->secure_map); | ||||
} | |||||
cur = g_list_next (cur); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
if ((value = | if ((value = | ||||
rspamd_config_get_module_opt (cfg, "dkim", "whitelist")) != NULL) { | rspamd_config_get_module_opt (cfg, "dkim", "whitelist")) != NULL) { | ||||
str = ucl_obj_tostring (value); | str = ucl_obj_tostring (value); | ||||
if (!rspamd_map_is_map (str)) { | |||||
if (str && !rspamd_map_is_map (str)) { | |||||
radix_add_generic_iplist (str, | radix_add_generic_iplist (str, | ||||
&dkim_module_ctx->whitelist_ip); | &dkim_module_ctx->whitelist_ip); | ||||
} | } | ||||
else { | else { | ||||
rspamd_map_add (cfg, str, | |||||
rspamd_map_add_from_ucl (cfg, value, | |||||
"DKIM whitelist", rspamd_radix_read, rspamd_radix_fin, | "DKIM whitelist", rspamd_radix_read, rspamd_radix_fin, | ||||
(void **)&dkim_module_ctx->whitelist_ip); | (void **)&dkim_module_ctx->whitelist_ip); | ||||
} | } | ||||
if ((value = | if ((value = | ||||
rspamd_config_get_module_opt (cfg, "dkim", "domains")) != NULL) { | 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, | "DKIM domains", rspamd_kv_list_read, rspamd_kv_list_fin, | ||||
(void **)&dkim_module_ctx->dkim_domains)) { | (void **)&dkim_module_ctx->dkim_domains)) { | ||||
msg_warn_config ("cannot load dkim domains list from %s", | msg_warn_config ("cannot load dkim domains list from %s", | ||||
} | } | ||||
if (!got_trusted && (value = | if (!got_trusted && (value = | ||||
rspamd_config_get_module_opt (cfg, "dkim", "trusted_domains")) != NULL) { | 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, | "DKIM domains", rspamd_kv_list_read, rspamd_kv_list_fin, | ||||
(void **)&dkim_module_ctx->dkim_domains)) { | (void **)&dkim_module_ctx->dkim_domains)) { | ||||
msg_warn_config ("cannot load dkim domains list from %s", | msg_warn_config ("cannot load dkim domains list from %s", |
str = ucl_obj_tostring (value); | str = ucl_obj_tostring (value); | ||||
if (!rspamd_map_is_map (str)) { | |||||
if (str && !rspamd_map_is_map (str)) { | |||||
radix_add_generic_iplist (str, | radix_add_generic_iplist (str, | ||||
&fuzzy_module_ctx->whitelist); | &fuzzy_module_ctx->whitelist); | ||||
} | } | ||||
else { | else { | ||||
rspamd_map_add (cfg, str, | |||||
rspamd_map_add_from_ucl (cfg, value, | |||||
"Fuzzy whitelist", rspamd_radix_read, rspamd_radix_fin, | "Fuzzy whitelist", rspamd_radix_read, rspamd_radix_fin, | ||||
(void **)&fuzzy_module_ctx->whitelist); | (void **)&fuzzy_module_ctx->whitelist); | ||||
str = ucl_obj_tostring (value); | str = ucl_obj_tostring (value); | ||||
if (!rspamd_map_is_map (str)) { | |||||
if (str && !rspamd_map_is_map (str)) { | |||||
radix_add_generic_iplist (str, | radix_add_generic_iplist (str, | ||||
&spf_module_ctx->whitelist_ip); | &spf_module_ctx->whitelist_ip); | ||||
} | } | ||||
else { | else { | ||||
rspamd_map_add (cfg, str, | |||||
rspamd_map_add_from_ucl (cfg, value, | |||||
"SPF whitelist", rspamd_radix_read, rspamd_radix_fin, | "SPF whitelist", rspamd_radix_read, rspamd_radix_fin, | ||||
(void **)&spf_module_ctx->whitelist_ip); | (void **)&spf_module_ctx->whitelist_ip); | ||||
if ((value = | if ((value = | ||||
rspamd_config_get_module_opt (cfg, "surbl", | rspamd_config_get_module_opt (cfg, "surbl", | ||||
"redirector_hosts_map")) != NULL) { | "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, | "SURBL redirectors list", read_redirectors_list, fin_redirectors_list, | ||||
(void **)&surbl_module_ctx->redirector_map_data)) { | (void **)&surbl_module_ctx->redirector_map_data)) { | ||||
} | } | ||||
if ((value = | if ((value = | ||||
rspamd_config_get_module_opt (cfg, "surbl", "exceptions")) != NULL) { | 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, | "SURBL exceptions list", read_exceptions_list, fin_exceptions_list, | ||||
(void **)&surbl_module_ctx->exceptions)) { | (void **)&surbl_module_ctx->exceptions)) { | ||||
surbl_module_ctx->tld2_file = rspamd_mempool_strdup ( | surbl_module_ctx->tld2_file = rspamd_mempool_strdup ( | ||||
} | } | ||||
if ((value = | if ((value = | ||||
rspamd_config_get_module_opt (cfg, "surbl", "whitelist")) != NULL) { | 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, | "SURBL whitelist", rspamd_hosts_read, rspamd_hosts_fin, | ||||
(void **)&surbl_module_ctx->whitelist)) { | (void **)&surbl_module_ctx->whitelist)) { | ||||
surbl_module_ctx->whitelist_file = rspamd_mempool_strdup ( | surbl_module_ctx->whitelist_file = rspamd_mempool_strdup ( |