From: Vsevolod Stakhov Date: Sun, 8 Oct 2017 10:34:45 +0000 (+0100) Subject: [Feature] Add DKIM trace symbol X-Git-Tag: 1.7.0~572 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a10819e96987b1082fc503fa4a07409fc7ea31f2;p=thirdparty%2Frspamd.git [Feature] Add DKIM trace symbol --- diff --git a/src/plugins/dkim_check.c b/src/plugins/dkim_check.c index b554ec48cb..055498746c 100644 --- a/src/plugins/dkim_check.c +++ b/src/plugins/dkim_check.c @@ -546,6 +546,9 @@ dkim_module_config (struct rspamd_config *cfg) rspamd_config_add_metric_symbol (cfg, "DKIM_SIGN", 0.0, "DKIM signature fake symbol", "dkim", RSPAMD_SYMBOL_FLAG_IGNORE, 1, 1); + rspamd_config_add_metric_symbol (cfg, + "DKIM_TRACE", 0.0, "DKIM trace symbol", + "dkim", RSPAMD_SYMBOL_FLAG_IGNORE, 1, 1); } else { @@ -886,7 +889,7 @@ dkim_module_check (struct dkim_check_result *res) if (all_done) { DL_FOREACH (first, cur) { - const gchar *symbol = NULL; + const gchar *symbol = NULL, *trace = NULL; int symbol_weight = 1; if (cur->ctx == NULL) { @@ -894,24 +897,41 @@ dkim_module_check (struct dkim_check_result *res) } if (cur->res == DKIM_REJECT) { symbol = dkim_module_ctx->symbol_reject; + trace = "-"; symbol_weight = cur->mult_deny * 1.0; } else if (cur->res == DKIM_CONTINUE) { symbol = dkim_module_ctx->symbol_allow; + trace = "+"; symbol_weight = cur->mult_allow * 1.0; } else if (cur->res == DKIM_PERM_ERROR) { + trace = "~"; symbol = dkim_module_ctx->symbol_permfail; } else if (cur->res == DKIM_TRYAGAIN) { + trace = "?"; symbol = dkim_module_ctx->symbol_tempfail; } if (symbol != NULL) { + const gchar *domain = rspamd_dkim_get_domain (cur->ctx); + gsize tracelen; + gchar *tracebuf; + + tracelen = strlen (domain) + 3; /* :\0 */ + tracebuf = rspamd_mempool_alloc (cur->task->task_pool, + tracelen); + rspamd_snprintf (tracebuf, tracelen, "%s:%s", domain, trace); + rspamd_task_insert_result (cur->task, symbol, symbol_weight, - rspamd_dkim_get_domain (cur->ctx)); + domain); + rspamd_task_insert_result (cur->task, + "DKIM_TRACE", + 0.0, + tracebuf); } } rspamd_session_watcher_pop (res->task->s, res->w);