aboutsummaryrefslogtreecommitdiffstats
path: root/src/protocol.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2011-02-11 16:51:02 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2011-02-11 16:51:02 +0300
commit234e7468612c110feafce72b87a0b4b242050406 (patch)
tree9fcb127fc1fd7ae36fc7fede02334a7fd98fa4a0 /src/protocol.c
parent0aab87dab86cc9186e267b1448373411d816136e (diff)
downloadrspamd-234e7468612c110feafce72b87a0b4b242050406.tar.gz
rspamd-234e7468612c110feafce72b87a0b4b242050406.zip
* Write Emails: header in output
Diffstat (limited to 'src/protocol.c')
-rw-r--r--src/protocol.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/protocol.c b/src/protocol.c
index 08bd88059..f5ef6bac2 100644
--- a/src/protocol.c
+++ b/src/protocol.c
@@ -550,6 +550,61 @@ show_url_header (struct worker_task *task)
return rspamd_dispatcher_write (task->dispatcher, outbuf, r, FALSE, FALSE);
}
+static gboolean
+show_email_header (struct worker_task *task)
+{
+ gint r = 0;
+ gchar outbuf[OUTBUFSIZ];
+ struct uri *url;
+ GList *cur;
+ gsize len;
+ GTree *url_tree;
+
+ r = rspamd_snprintf (outbuf, sizeof (outbuf), "Emails: ");
+ url_tree = g_tree_new (compare_url_func);
+ cur = task->emails;
+ while (cur) {
+ url = cur->data;
+ if (g_tree_lookup (url_tree, url) == NULL && url->hostlen > 0) {
+ g_tree_insert (url_tree, url, url);
+ len = url->hostlen + url->userlen + 1;
+ /* Skip long hosts to avoid protocol coollisions */
+ if (len > OUTBUFSIZ) {
+ cur = g_list_next (cur);
+ continue;
+ }
+ /* Do header folding */
+ if (len + r >= OUTBUFSIZ - 3) {
+ outbuf[r++] = '\r';
+ outbuf[r++] = '\n';
+ outbuf[r] = ' ';
+ if (! rspamd_dispatcher_write (task->dispatcher, outbuf, r, TRUE, FALSE)) {
+ return FALSE;
+ }
+ r = 0;
+ }
+ /* Write url host to buf */
+ if (g_list_next (cur) != NULL) {
+ r += rspamd_snprintf (outbuf + r, sizeof (outbuf) - r, "%*s@%*s, ",
+ url->userlen, url->user,
+ url->hostlen, url->host);
+ }
+ else {
+ r += rspamd_snprintf (outbuf + r, sizeof (outbuf) - r, "%*s@%*s",
+ url->userlen, url->user,
+ url->hostlen, url->host);
+ }
+ }
+ cur = g_list_next (cur);
+ }
+ if (r == 0) {
+ return TRUE;
+ }
+ r += rspamd_snprintf (outbuf + r, sizeof (outbuf) - r, CRLF);
+
+ return rspamd_dispatcher_write (task->dispatcher, outbuf, r, FALSE, FALSE);
+}
+
static void
metric_symbols_callback (gpointer key, gpointer value, void *user_data)
{
@@ -853,6 +908,10 @@ write_check_reply (struct worker_task *task)
if (! show_url_header (task)) {
return FALSE;
}
+ /* Emails stat */
+ if (! show_email_header (task)) {
+ return FALSE;
+ }
}
write_hashes_to_log (task, logbuf, cd.log_offset, cd.log_size);