diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-04-05 16:14:28 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-04-05 16:14:28 +0100 |
commit | 3bb2221337743a15ea2663ab92292be3b6a9546e (patch) | |
tree | 03c2eeff8244f84ebbd009f87218b6b5fc7caedf /src | |
parent | db7f8d68e4fa77df5e09d94b7bb6587deb838852 (diff) | |
download | rspamd-3bb2221337743a15ea2663ab92292be3b6a9546e.tar.gz rspamd-3bb2221337743a15ea2663ab92292be3b6a9546e.zip |
[Feature] Add more verbosity for SPF caching
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/spf.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/plugins/spf.c b/src/plugins/spf.c index dfdf110a1..4c5dff124 100644 --- a/src/plugins/spf.c +++ b/src/plugins/spf.c @@ -361,7 +361,7 @@ spf_module_reconfig (struct rspamd_config *cfg) static gboolean spf_check_element (struct spf_resolved *rec, struct spf_addr *addr, - struct rspamd_task *task) + struct rspamd_task *task, gboolean cached) { gboolean res = FALSE; const guint8 *s, *d; @@ -426,7 +426,7 @@ spf_check_element (struct spf_resolved *rec, struct spf_addr *addr, if (res) { spf_result = rspamd_mempool_alloc (task->task_pool, - strlen (addr->spf_string) + 2); + strlen (addr->spf_string) + 5); switch (addr->mech) { case SPF_FAIL: @@ -478,9 +478,13 @@ spf_check_element (struct spf_resolved *rec, struct spf_addr *addr, break; } - rspamd_strlcpy (spf_result + 1, addr->spf_string, + gint r = rspamd_strlcpy (spf_result + 1, addr->spf_string, strlen (addr->spf_string) + 1); + if (cached) { + rspamd_strlcpy (spf_result + r + 1, ":c", 3); + } + rspamd_task_insert_result (task, spf_symbol, 1, @@ -496,14 +500,14 @@ spf_check_element (struct spf_resolved *rec, struct spf_addr *addr, } static void -spf_check_list (struct spf_resolved *rec, struct rspamd_task *task) +spf_check_list (struct spf_resolved *rec, struct rspamd_task *task, gboolean cached) { guint i; struct spf_addr *addr; for (i = 0; i < rec->elts->len; i ++) { addr = &g_array_index (rec->elts, struct spf_addr, i); - if (spf_check_element (rec, addr, task)) { + if (spf_check_element (rec, addr, task, cached)) { break; } } @@ -557,12 +561,19 @@ spf_plugin_callback (struct spf_resolved *record, struct rspamd_task *task, rspamd_lru_hash_insert (spf_module_ctx->spf_hash, record->domain, spf_record_ref (l), task->tv.tv_sec, record->ttl); + + msg_info_task ("stored record for %s in LRU cache for %d seconds, " + "%d/%d elements in the cache", + record->domain, + record->ttl, + rspamd_lru_hash_size (spf_module_ctx->spf_hash), + rspamd_lru_hash_capacity (spf_module_ctx->spf_hash)); } } spf_record_ref (l); - spf_check_list (l, task); + spf_check_list (l, task, FALSE); spf_record_unref (l); spf_record_unref (record); @@ -621,7 +632,7 @@ spf_symbol_callback (struct rspamd_task *task, rspamd_lru_hash_lookup (spf_module_ctx->spf_hash, domain, task->tv.tv_sec)) != NULL) { spf_record_ref (l); - spf_check_list (l, task); + spf_check_list (l, task, TRUE); spf_record_unref (l); } else { |