]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Core: Add milter actions concept
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 26 Jan 2019 13:26:36 +0000 (13:26 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 26 Jan 2019 13:26:36 +0000 (13:26 +0000)
src/libserver/cfg_file.h
src/libserver/cfg_utils.c

index 5c245a31b4c18bed0c9347b10585c210dc3b336c..8ecb84d263b274912f32e594bcefa34f0c37a59d 100644 (file)
@@ -270,6 +270,8 @@ enum rspamd_action_type {
        METRIC_ACTION_NOACTION,
        METRIC_ACTION_MAX,
        METRIC_ACTION_CUSTOM = 999,
+       METRIC_ACTION_MILTER_DISCARD,
+       METRIC_ACTION_MILTER_QUARANTINE
 };
 
 enum rspamd_action_flags {
@@ -277,6 +279,7 @@ enum rspamd_action_flags {
        RSPAMD_ACTION_NO_THRESHOLD = (1u << 0),
        RSPAMD_ACTION_THRESHOLD_ONLY = (1u << 1),
        RSPAMD_ACTION_HAM = (1u << 2),
+       RSPAMD_ACTION_MILTER = (1u << 3),
 };
 
 
index a854f45caea64a731e65afa922094fe4de15ada4..42e4bbc4ad20633e26f6d1b38fd85e7d96176818 100644 (file)
@@ -1929,6 +1929,24 @@ rspamd_config_action_from_ucl (struct rspamd_config *cfg,
                                }
                        }
                }
+
+               elt = ucl_object_lookup (obj, "milter");
+
+               if (elt) {
+                       const gchar *milter_action = ucl_object_tostring (elt);
+
+                       if (strcmp (milter_action, "discard") == 0) {
+                               flags |= RSPAMD_ACTION_MILTER;
+                               act->action_type = METRIC_ACTION_MILTER_DISCARD;
+                       }
+                       else if (strcmp (milter_action, "quarantine") == 0) {
+                               flags |= RSPAMD_ACTION_MILTER;
+                               act->action_type = METRIC_ACTION_MILTER_QUARANTINE;
+                       }
+                       else {
+                               msg_warn_config ("unknown milter action: %s", milter_action);
+                       }
+               }
        }
        else if (obj_type == UCL_FLOAT || obj_type == UCL_INT) {
                threshold = ucl_object_todouble (obj);
@@ -1946,11 +1964,12 @@ rspamd_config_action_from_ucl (struct rspamd_config *cfg,
        act->threshold = threshold;
        act->flags = flags;
 
-       if (rspamd_action_from_str (act->name, &std_act)) {
-               act->action_type = std_act;
-       }
-       else {
-               act->action_type = METRIC_ACTION_CUSTOM;
+       if (!(flags & RSPAMD_ACTION_MILTER)) {
+               if (rspamd_action_from_str (act->name, &std_act)) {
+                       act->action_type = std_act;
+               } else {
+                       act->action_type = METRIC_ACTION_CUSTOM;
+               }
        }
 
        return TRUE;