aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/milter.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-06-07 19:33:35 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-06-07 22:13:18 +0100
commit0450fb4e79f13e110a9ebec861c3d6fa3b7536f8 (patch)
tree2ea212a6dcc97d1396e77b944992ecad0107e97a /src/libserver/milter.c
parenta8936659c5f7774716aaedb010bd13459ef0e8ee (diff)
downloadrspamd-0450fb4e79f13e110a9ebec861c3d6fa3b7536f8.tar.gz
rspamd-0450fb4e79f13e110a9ebec861c3d6fa3b7536f8.zip
[Minor] Allow to set custom spam header in milter module
Diffstat (limited to 'src/libserver/milter.c')
-rw-r--r--src/libserver/milter.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/libserver/milter.c b/src/libserver/milter.c
index 67f47e95b..ceea53cf8 100644
--- a/src/libserver/milter.c
+++ b/src/libserver/milter.c
@@ -45,6 +45,12 @@
G_STRFUNC, \
__VA_ARGS__)
+struct rspamd_milter_context {
+ gchar *spam_header;
+};
+
+static struct rspamd_milter_context *milter_ctx = NULL;
+
static gboolean rspamd_milter_handle_session (
struct rspamd_milter_session *session,
struct rspamd_milter_private *priv);
@@ -962,6 +968,11 @@ rspamd_milter_handle_socket (gint fd, const struct timeval *tv,
g_assert (finish_cb != NULL);
g_assert (error_cb != NULL);
+ if (G_UNLIKELY (milter_ctx == NULL)) {
+ milter_ctx = g_malloc (sizeof (*milter_ctx));
+ milter_ctx->spam_header = g_strdup (RSPAMD_MILTER_SPAM_HEADER);
+ }
+
session = g_malloc0 (sizeof (*session));
priv = g_malloc0 (sizeof (*priv));
priv->fd = fd;
@@ -1449,9 +1460,11 @@ rspamd_milter_send_task_results (struct rspamd_milter_session *session,
break;
case METRIC_ACTION_ADD_HEADER:
- hname = g_string_new (RSPAMD_MILTER_SPAM_HEADER);
+ hname = g_string_new (milter_ctx->spam_header);
+ /* TODO: Perhaps, we can customize it as well */
hvalue = g_string_new ("Yes");
+ /* TODO: We to track headers to make it work fine */
rspamd_milter_send_action (session, RSPAMD_MILTER_CHGHEADER,
(guint32)1, hname, hvalue);
g_string_free (hname, TRUE);