]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Allow to skip real action and add a header instead
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 10 Aug 2017 18:04:56 +0000 (19:04 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 10 Aug 2017 18:05:30 +0000 (19:05 +0100)
src/libserver/milter.c
src/libserver/milter_internal.h

index 18f888e2212fc4359560099bf08e5e8a6f58e793..61261dff5775886506265e8b366aa37af2d3184f 100644 (file)
@@ -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) {
index 771272b4a0b5c5463d126125f0cac59e3b59770b..b2a2dc712c58b5f5b5844680cc5b73d55f6fcff7 100644 (file)
@@ -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