]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
* Write part's hashes to log for messages identify
authorcebka@lenovo-laptop <cebka@lenovo-laptop>
Thu, 28 Jan 2010 18:13:14 +0000 (21:13 +0300)
committercebka@lenovo-laptop <cebka@lenovo-laptop>
Thu, 28 Jan 2010 18:13:14 +0000 (21:13 +0300)
src/protocol.c

index 0cba93b213797157659d9206aa5008e6088738e7..feb57736800a0f77fead6ec2a2a11d0ad5f6b180 100644 (file)
@@ -27,6 +27,7 @@
 #include "util.h"
 #include "cfg_file.h"
 #include "settings.h"
+#include "message.h"
 
 /* Max line size as it is defined in rfc2822 */
 #define OUTBUFSIZ 1000
@@ -404,6 +405,28 @@ struct metric_callback_data {
        int                             log_size;
 };
 
+static void
+write_hashes_to_log (struct worker_task *task, char *logbuf, int offset, int size) 
+{
+       GList                          *cur;
+       struct mime_text_part          *text_part;
+       
+       cur = task->text_parts;
+
+       while (cur && offset < size) {
+               text_part = cur->data;
+               if (text_part->fuzzy) {
+                       if (cur->next != NULL) {
+                               offset += snprintf (logbuf + offset, size - offset, " part: %Xd,", text_part->fuzzy->h);
+                       }
+                       else {
+                               offset += snprintf (logbuf + offset, size - offset, " part: %Xd", text_part->fuzzy->h);
+                       }
+               }
+               cur = g_list_next (cur);
+       }
+}
+
 static void
 show_url_header (struct worker_task *task)
 {
@@ -673,6 +696,8 @@ write_check_reply (struct worker_task *task)
                /* URL stat */
                show_url_header (task);
        }
+       
+       write_hashes_to_log (task, logbuf, cd.log_offset, cd.log_size);
        msg_info ("%s", logbuf);
        rspamd_dispatcher_write (task->dispatcher, CRLF, sizeof (CRLF) - 1, FALSE, TRUE);
 
@@ -724,6 +749,7 @@ write_process_reply (struct worker_task *task)
                g_hash_table_foreach (task->results, show_metric_result, &cd);
                /* URL stat */
        }
+       write_hashes_to_log (task, logbuf, cd.log_offset, cd.log_size);
        msg_info ("%s", logbuf);
 
        outmsg = g_mime_object_to_string (GMIME_OBJECT (task->message));