diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-08-10 19:04:56 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-08-10 19:05:30 +0100 |
commit | bb56713f25a5904d9f1a35309fdd78971b120969 (patch) | |
tree | 417ae149e41be3fda22db38de675ba6ea2b5db4b /src/libserver | |
parent | e3616e98b6f30b84439700348c6b83c26514f7b6 (diff) | |
download | rspamd-bb56713f25a5904d9f1a35309fdd78971b120969.tar.gz rspamd-bb56713f25a5904d9f1a35309fdd78971b120969.zip |
[Feature] Allow to skip real action and add a header instead
Diffstat (limited to 'src/libserver')
-rw-r--r-- | src/libserver/milter.c | 21 | ||||
-rw-r--r-- | src/libserver/milter_internal.h | 2 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/libserver/milter.c b/src/libserver/milter.c index 18f888e22..61261dff5 100644 --- a/src/libserver/milter.c +++ b/src/libserver/milter.c @@ -1482,6 +1482,12 @@ rspamd_milter_process_milter_block (struct rspamd_milter_session *session, priv->discard_on_reject = FALSE; } } + + elt = ucl_object_lookup (obj, "no_action"); + + if (elt && ucl_object_type (elt) == UCL_BOOLEAN) { + priv->no_action = ucl_object_toboolean (elt); + } } if (action == METRIC_ACTION_ADD_HEADER) { @@ -1598,6 +1604,21 @@ rspamd_milter_send_task_results (struct rspamd_milter_session *session, goto cleanup; } + if (priv->no_action) { + msg_info_milter ("do not apply action %s, no_action is set", + str_action); + hname = g_string_new (RSPAMD_MILTER_ACTION_HEADER); + hvalue = g_string_new (str_action); + + rspamd_milter_send_action (session, RSPAMD_MILTER_ADDHEADER, + hname, hvalue); + g_string_free (hname, TRUE); + g_string_free (hvalue, TRUE); + rspamd_milter_send_action (session, RSPAMD_MILTER_ACCEPT); + + goto cleanup; + } + switch (action) { case METRIC_ACTION_REJECT: if (priv->discard_on_reject) { diff --git a/src/libserver/milter_internal.h b/src/libserver/milter_internal.h index 771272b4a..b2a2dc712 100644 --- a/src/libserver/milter_internal.h +++ b/src/libserver/milter_internal.h @@ -66,6 +66,7 @@ struct rspamd_milter_private { enum rspamd_milter_io_state state; int fd; gboolean discard_on_reject; + gboolean no_action; }; enum rspamd_milter_io_cmd { @@ -151,4 +152,5 @@ enum rspamd_milter_connect_proto { #define RSPAMD_MILTER_TEMPFAIL_MESSAGE "Try again later" #define RSPAMD_MILTER_SPAM_HEADER "X-Spam" #define RSPAMD_MILTER_DKIM_HEADER "DKIM-Signature" +#define RSPAMD_MILTER_ACTION_HEADER "X-Rspamd-Action" #endif |