@@ -1645,7 +1645,7 @@ start_controller_worker (struct rspamd_worker *worker) | |||
if (!add_map (worker->srv->cfg, ctx->secure_ip, | |||
"Allow webui access from the specified IP", | |||
read_radix_list, fin_radix_list, (void **)&ctx->secure_map)) { | |||
if (!rspamd_config_parse_ip_list (ctx->secure_ip, | |||
if (!radix_add_generic_iplist (ctx->secure_ip, | |||
&ctx->secure_map)) { | |||
msg_warn ("cannot load or parse ip list from '%s'", | |||
ctx->secure_ip); |
@@ -1058,7 +1058,7 @@ start_fuzzy (struct rspamd_worker *worker) | |||
if (!add_map (worker->srv->cfg, ctx->update_map, | |||
"Allow fuzzy updates from specified addresses", | |||
read_radix_list, fin_radix_list, (void **)&ctx->update_ips)) { | |||
if (!rspamd_config_parse_ip_list (ctx->update_map, | |||
if (!radix_add_generic_iplist (ctx->update_map, | |||
&ctx->update_ips)) { | |||
msg_warn ("cannot load or parse ip list from '%s'", | |||
ctx->update_map); |
@@ -476,12 +476,6 @@ struct rspamd_classifier_config * rspamd_config_find_classifier ( | |||
struct rspamd_config *cfg, | |||
const gchar *name); | |||
/* | |||
* Parse input `ip_list` to radix tree `tree`. Now supports only IPv4 addresses. | |||
*/ | |||
gboolean rspamd_config_parse_ip_list (const gchar *ip_list, | |||
radix_compressed_t **tree); | |||
void rspamd_ucl_add_conf_macros (struct ucl_parser *parser, | |||
struct rspamd_config *cfg); | |||
@@ -1004,16 +1004,6 @@ rspamd_ucl_fin_cb (rspamd_mempool_t * pool, struct map_cb_data *data) | |||
} | |||
} | |||
gboolean | |||
rspamd_config_parse_ip_list (const gchar *ip_list, radix_compressed_t **tree) | |||
{ | |||
if (*tree == NULL) { | |||
*tree = radix_create_compressed (); | |||
} | |||
return (rspamd_radix_add_iplist (ip_list, ",; ", *tree) > 0); | |||
} | |||
/* | |||
* vi:ts=4 | |||
*/ |
@@ -342,7 +342,7 @@ rspamd_set_logger (struct rspamd_config *cfg, | |||
"IP addresses for which debug logs are enabled", | |||
read_radix_list, fin_radix_list, | |||
(void **)&rspamd->logger->debug_ip)) { | |||
rspamd_config_parse_ip_list (rspamd->cfg->debug_ip_map, | |||
radix_add_generic_iplist (rspamd->cfg->debug_ip_map, | |||
&rspamd->logger->debug_ip); | |||
} | |||
} |
@@ -962,6 +962,16 @@ rspamd_radix_add_iplist (const gchar *list, const gchar *separators, | |||
return res; | |||
} | |||
gboolean | |||
radix_add_generic_iplist (const gchar *ip_list, radix_compressed_t **tree) | |||
{ | |||
if (*tree == NULL) { | |||
*tree = radix_create_compressed (); | |||
} | |||
return (rspamd_radix_add_iplist (ip_list, ",; ", *tree) > 0); | |||
} | |||
/* | |||
* vi:ts=4 | |||
*/ |
@@ -130,4 +130,11 @@ radix_compressed_t *radix_create_compressed (void); | |||
gint rspamd_radix_add_iplist (const gchar *list, const gchar *separators, | |||
radix_compressed_t *tree); | |||
/** | |||
* Generic version of @see rspamd_radix_add_iplist. This function creates tree | |||
* if `tree` is NULL. | |||
*/ | |||
gboolean radix_add_generic_iplist (const gchar *ip_list, | |||
radix_compressed_t **tree); | |||
#endif |
@@ -59,7 +59,7 @@ struct dkim_ctx { | |||
const gchar *symbol_allow; | |||
rspamd_mempool_t *dkim_pool; | |||
radix_tree_t *whitelist_ip; | |||
radix_compressed_t *whitelist_ip; | |||
GHashTable *dkim_domains; | |||
guint strict_multiplier; | |||
guint time_jitter; | |||
@@ -106,7 +106,7 @@ dkim_module_config (struct rspamd_config *cfg) | |||
guint cache_size, cache_expire; | |||
gboolean got_trusted = FALSE; | |||
dkim_module_ctx->whitelist_ip = radix_tree_create (); | |||
dkim_module_ctx->whitelist_ip = radix_create_compressed (); | |||
if ((value = | |||
rspamd_config_get_module_opt (cfg, "dkim", "symbol_reject")) != NULL) { | |||
@@ -158,8 +158,8 @@ dkim_module_config (struct rspamd_config *cfg) | |||
if (!add_map (cfg, ucl_obj_tostring (value), | |||
"DKIM whitelist", read_radix_list, fin_radix_list, | |||
(void **)&dkim_module_ctx->whitelist_ip)) { | |||
msg_warn ("cannot load whitelist from %s", | |||
ucl_obj_tostring (value)); | |||
radix_add_generic_iplist (ucl_obj_tostring (value), | |||
&dkim_module_ctx->whitelist_ip); | |||
} | |||
} | |||
if ((value = | |||
@@ -234,7 +234,7 @@ gint | |||
dkim_module_reconfig (struct rspamd_config *cfg) | |||
{ | |||
rspamd_mempool_delete (dkim_module_ctx->dkim_pool); | |||
radix_tree_free (dkim_module_ctx->whitelist_ip); | |||
radix_destroy_compressed (dkim_module_ctx->whitelist_ip); | |||
if (dkim_module_ctx->dkim_domains) { | |||
g_hash_table_destroy (dkim_module_ctx->dkim_domains); | |||
} | |||
@@ -368,10 +368,8 @@ dkim_symbol_callback (struct rspamd_task *task, void *unused) | |||
if (hlist != NULL) { | |||
/* Check whitelist */ | |||
msg_debug ("dkim signature found"); | |||
if (task->from_addr.af == AF_INET || | |||
radix32tree_find (dkim_module_ctx->whitelist_ip, | |||
ntohl (task->from_addr.addr.s4.sin_addr.s_addr)) == | |||
RADIX_NO_VALUE) { | |||
if (radix_find_compressed_addr (dkim_module_ctx->whitelist_ip, | |||
&task->from_addr) == RADIX_NO_VALUE) { | |||
/* Parse signature */ | |||
msg_debug ("create dkim signature"); | |||
/* |
@@ -486,7 +486,7 @@ fuzzy_check_module_config (struct rspamd_config *cfg) | |||
if (!add_map (cfg, ucl_obj_tostring (value), | |||
"Fuzzy whitelist", read_radix_list, fin_radix_list, | |||
(void **)&fuzzy_module_ctx->whitelist)) { | |||
rspamd_config_parse_ip_list (ucl_obj_tostring (value), | |||
radix_add_generic_iplist (ucl_obj_tostring (value), | |||
&fuzzy_module_ctx->whitelist); | |||
} | |||
} |
@@ -140,7 +140,7 @@ spf_module_config (struct rspamd_config *cfg) | |||
if (!add_map (cfg, ucl_obj_tostring (value), | |||
"SPF whitelist", read_radix_list, fin_radix_list, | |||
(void **)&spf_module_ctx->whitelist_ip)) { | |||
rspamd_config_parse_ip_list (ucl_obj_tostring (value), | |||
radix_add_generic_iplist (ucl_obj_tostring (value), | |||
&spf_module_ctx->whitelist_ip); | |||
} | |||
} |