]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Feature] Pass settings id to log helper
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 27 Apr 2016 12:09:10 +0000 (13:09 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 27 Apr 2016 12:09:10 +0000 (13:09 +0100)
src/libserver/protocol.c
src/libserver/protocol.h

index 0426022a7cabc0e4c6a7332e782b6d1a8768f2e4..ea5eb8bcc89468b16ea45dd8bc70e26b05232e29 100644 (file)
@@ -23,6 +23,7 @@
 #include "http.h"
 #include "email_addr.h"
 #include "worker_private.h"
+#include "xxhash.h"
 
 /* Max line size */
 #define OUTBUFSIZ BUFSIZ
@@ -1082,6 +1083,7 @@ rspamd_protocol_write_log_pipe (struct rspamd_worker_ctx *ctx,
        struct metric_result *mres;
        GHashTableIter it;
        gpointer k, v;
+       rspamd_ftok_t srch, *hdr;
        struct symbol *sym;
        gint id, i;
        gsize sz;
@@ -1097,6 +1099,22 @@ rspamd_protocol_write_log_pipe (struct rspamd_worker_ctx *ctx,
                                                        sizeof (struct rspamd_protocol_log_symbol_result) *
                                                        g_hash_table_size (mres->symbols);
                                        ls = g_slice_alloc (sz);
+
+                                       /* Handle settings id */
+                                       srch.begin = "Settings-Id";
+                                       srch.len = sizeof ("Settings-Id") - 1;
+                                       hdr = g_hash_table_lookup (task->request_headers, &srch);
+
+                                       if (hdr) {
+                                               guint64 h;
+
+                                               h = XXH64 (hdr->begin, hdr->len, 0xdeadbabe);
+                                               memcpy (&ls->settings_id, &h, sizeof (ls->settings_id));
+                                       }
+                                       else {
+                                               ls->settings_id = 0;
+                                       }
+
                                        ls->score = mres->score;
                                        ls->required_score = mres->actions_limits[METRIC_ACTION_REJECT];
                                        ls->nresults = g_hash_table_size (mres->symbols);
index 9ba1d67ca5d6e6db2e2f6333783c145ff0215e8c..3c83835659f8649fbf1ed3b7660ccc910ff70f26 100644 (file)
@@ -24,6 +24,7 @@ struct rspamd_protocol_log_symbol_result {
 };
 struct rspamd_protocol_log_message_sum {
        guint32 nresults;
+       guint32 settings_id;
        gdouble score;
        gdouble required_score;
        struct rspamd_protocol_log_symbol_result results[];