summaryrefslogtreecommitdiffstats
path: root/src/plugins/dkim_check.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-10-01 17:35:47 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-10-01 17:35:47 +0100
commit6f8fa405cf5d394491b987d824f5e1b74c14a4c8 (patch)
tree461a516b628265e9e4767f890f13766218535b41 /src/plugins/dkim_check.c
parentebdf58dc0aed1014374dc56c0b28fe76f3b0c0b1 (diff)
downloadrspamd-6f8fa405cf5d394491b987d824f5e1b74c14a4c8.tar.gz
rspamd-6f8fa405cf5d394491b987d824f5e1b74c14a4c8.zip
Rework parsing of ip lists.
Diffstat (limited to 'src/plugins/dkim_check.c')
-rw-r--r--src/plugins/dkim_check.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/plugins/dkim_check.c b/src/plugins/dkim_check.c
index 075d23c88..bc687065e 100644
--- a/src/plugins/dkim_check.c
+++ b/src/plugins/dkim_check.c
@@ -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");
/*