aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-10-01 17:28:27 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-10-01 17:28:27 +0100
commitebdf58dc0aed1014374dc56c0b28fe76f3b0c0b1 (patch)
tree9cb0a9dca7d57a49c0e07115315d8c2b75ab5d40 /src
parent90b430d2a72688da7e735e75039185563a2b2714 (diff)
downloadrspamd-ebdf58dc0aed1014374dc56c0b28fe76f3b0c0b1.tar.gz
rspamd-ebdf58dc0aed1014374dc56c0b28fe76f3b0c0b1.zip
Fix fuzzy_check and spf.
Diffstat (limited to 'src')
-rw-r--r--src/plugins/fuzzy_check.c14
-rw-r--r--src/plugins/spf.c12
2 files changed, 14 insertions, 12 deletions
diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c
index 3bac2f7b2..323246f71 100644
--- a/src/plugins/fuzzy_check.c
+++ b/src/plugins/fuzzy_check.c
@@ -92,7 +92,7 @@ struct fuzzy_ctx {
struct rspamd_config *cfg;
const gchar *default_symbol;
guint32 min_hash_len;
- radix_tree_t *whitelist;
+ radix_compressed_t *whitelist;
guint32 min_bytes;
guint32 min_height;
guint32 min_width;
@@ -482,11 +482,12 @@ fuzzy_check_module_config (struct rspamd_config *cfg)
if ((value =
rspamd_config_get_module_opt (cfg, "fuzzy_check",
"whitelist")) != NULL) {
- fuzzy_module_ctx->whitelist = radix_tree_create ();
+ fuzzy_module_ctx->whitelist = radix_create_compressed ();
if (!add_map (cfg, ucl_obj_tostring (value),
"Fuzzy whitelist", read_radix_list, fin_radix_list,
(void **)&fuzzy_module_ctx->whitelist)) {
- msg_err ("cannot add whitelist '%s'", ucl_obj_tostring (value));
+ rspamd_config_parse_ip_list (ucl_obj_tostring (value),
+ &fuzzy_module_ctx->whitelist);
}
}
else {
@@ -913,10 +914,9 @@ fuzzy_symbol_callback (struct rspamd_task *task, void *unused)
GList *cur;
/* Check whitelist */
- if (fuzzy_module_ctx->whitelist && task->from_addr.af == AF_INET) {
- if (radix32tree_find (fuzzy_module_ctx->whitelist,
- ntohl (task->from_addr.addr.s4.sin_addr.s_addr)) !=
- RADIX_NO_VALUE) {
+ if (fuzzy_module_ctx->whitelist) {
+ if (radix_find_compressed_addr (fuzzy_module_ctx->whitelist,
+ &task->from_addr) != RADIX_NO_VALUE) {
msg_info ("<%s>, address %s is whitelisted, skip fuzzy check",
task->message_id,
rspamd_inet_address_to_string (&task->from_addr));
diff --git a/src/plugins/spf.c b/src/plugins/spf.c
index 34eb69a25..e435da36d 100644
--- a/src/plugins/spf.c
+++ b/src/plugins/spf.c
@@ -53,7 +53,7 @@ struct spf_ctx {
const gchar *symbol_allow;
rspamd_mempool_t *spf_pool;
- radix_tree_t *whitelist_ip;
+ radix_compressed_t *whitelist_ip;
rspamd_lru_hash_t *spf_hash;
};
@@ -97,7 +97,7 @@ spf_module_config (struct rspamd_config *cfg)
gint res = TRUE;
guint cache_size, cache_expire;
- spf_module_ctx->whitelist_ip = radix_tree_create ();
+ spf_module_ctx->whitelist_ip = radix_create_compressed ();
if ((value =
rspamd_config_get_module_opt (cfg, "spf", "symbol_fail")) != NULL) {
@@ -140,7 +140,8 @@ 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)) {
- msg_warn ("cannot load whitelist from %s", value);
+ rspamd_config_parse_ip_list (ucl_obj_tostring (value),
+ &spf_module_ctx->whitelist_ip);
}
}
@@ -165,7 +166,7 @@ gint
spf_module_reconfig (struct rspamd_config *cfg)
{
rspamd_mempool_delete (spf_module_ctx->spf_pool);
- radix_tree_free (spf_module_ctx->whitelist_ip);
+ radix_destroy_compressed (spf_module_ctx->whitelist_ip);
memset (spf_module_ctx, 0, sizeof (*spf_module_ctx));
spf_module_ctx->spf_pool = rspamd_mempool_new (
rspamd_mempool_suggest_size ());
@@ -324,7 +325,8 @@ spf_symbol_callback (struct rspamd_task *task, void *unused)
gchar *domain;
GList *l;
- if (task->from_addr.af != AF_UNIX) {
+ if (radix_find_compressed_addr (spf_module_ctx->whitelist_ip,
+ &task->from_addr) == RADIX_NO_VALUE) {
domain = get_spf_domain (task);
if (domain) {
if ((l =