diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-01-30 15:19:04 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-01-30 15:19:04 +0000 |
commit | 39c853952b97d56726839e6e5681cd7e1849c364 (patch) | |
tree | 500ec6cf01f380fb22308159c290e0901310d892 /src/libserver | |
parent | ef18538d25cc8e39fd0eb71424cecef516412d90 (diff) | |
download | rspamd-39c853952b97d56726839e6e5681cd7e1849c364.tar.gz rspamd-39c853952b97d56726839e6e5681cd7e1849c364.zip |
Rework message store to allow encryption.
Diffstat (limited to 'src/libserver')
-rw-r--r-- | src/libserver/dkim.c | 6 | ||||
-rw-r--r-- | src/libserver/protocol.c | 2 | ||||
-rw-r--r-- | src/libserver/roll_history.c | 2 | ||||
-rw-r--r-- | src/libserver/task.c | 23 | ||||
-rw-r--r-- | src/libserver/task.h | 8 |
5 files changed, 16 insertions, 25 deletions
diff --git a/src/libserver/dkim.c b/src/libserver/dkim.c index dc0b73166..e178cfea4 100644 --- a/src/libserver/dkim.c +++ b/src/libserver/dkim.c @@ -1591,12 +1591,12 @@ rspamd_dkim_check (rspamd_dkim_context_t *ctx, g_return_val_if_fail (ctx != NULL, DKIM_ERROR); g_return_val_if_fail (key != NULL, DKIM_ERROR); - g_return_val_if_fail (task->msg != NULL, DKIM_ERROR); + g_return_val_if_fail (task->msg.len > 0, DKIM_ERROR); /* First of all find place of body */ - p = task->msg->str; + p = task->msg.start; - end = task->msg->str + task->msg->len; + end = task->msg.start + task->msg.len; while (p <= end) { /* Search for \r\n\r\n at the end of headers */ diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c index 9632418c4..25dcee1c0 100644 --- a/src/libserver/protocol.c +++ b/src/libserver/protocol.c @@ -735,7 +735,7 @@ rspamd_metric_result_ucl (struct rspamd_task *task, #ifdef HAVE_CLOCK_GETTIME rspamd_printf_gstring (logbuf, "]), len: %z, time: %s, dns req: %d,", - task->msg->len, calculate_check_time (&task->tv, &task->ts, + task->msg.len, calculate_check_time (&task->tv, &task->ts, task->cfg->clock_res, &task->scan_milliseconds), task->dns_requests); #else rspamd_printf_gstring (logbuf, "]), len: %z, time: %s, dns req: %d,", diff --git a/src/libserver/roll_history.c b/src/libserver/roll_history.c index 4e6ee01a8..5edf5bea0 100644 --- a/src/libserver/roll_history.c +++ b/src/libserver/roll_history.c @@ -146,7 +146,7 @@ rspamd_roll_history_update (struct roll_history *history, } row->scan_time = task->scan_milliseconds; - row->len = (task->msg == NULL ? 0 : task->msg->len); + row->len = task->msg.len; row->completed = TRUE; } diff --git a/src/libserver/task.c b/src/libserver/task.c index b8d042dc6..699e129ab 100644 --- a/src/libserver/task.c +++ b/src/libserver/task.c @@ -293,29 +293,16 @@ rspamd_task_free_soft (gpointer ud) gboolean rspamd_task_process (struct rspamd_task *task, - struct rspamd_http_message *msg, GThreadPool *classify_pool, + struct rspamd_http_message *msg, const gchar *start, gsize len, + GThreadPool *classify_pool, gboolean process_extra_filters) { gint r; GError *err = NULL; - if (msg->body->len == 0) { - msg_err ("got zero length body"); - task->last_error = "message's body is empty"; - return FALSE; - } - - /* XXX: awful hack */ - if (msg->peer_key != NULL) { - task->msg = rspamd_mempool_alloc (task->task_pool, sizeof (GString)); - task->msg->len = msg->body->len - 16; - task->msg->allocated_len = 0; - task->msg->str = msg->body->str + 16; - } - else { - task->msg = msg->body; - } - debug_task ("got string of length %z", task->msg->len); + task->msg.start = start; + task->msg.len = len; + debug_task ("got string of length %z", task->msg.len); /* We got body, set wanna_die flag */ task->s->wanna_die = TRUE; diff --git a/src/libserver/task.h b/src/libserver/task.h index 9702befa5..43349ffa9 100644 --- a/src/libserver/task.h +++ b/src/libserver/task.h @@ -93,7 +93,10 @@ struct rspamd_task { gchar *hostname; /**< hostname reported by MTA */ GHashTable *request_headers; /**< HTTP headers in a request */ GHashTable *reply_headers; /**< Custom reply headers */ - GString *msg; /**< message buffer */ + struct { + const gchar *start; + gsize len; + } msg; /**< message buffer */ struct rspamd_http_connection *http_conn; /**< HTTP server connection */ struct rspamd_async_session * s; /**< async session object */ gint parts_count; /**< mime parts count */ @@ -181,7 +184,8 @@ gboolean rspamd_task_fin (void *arg); * @return task has been successfully parsed and processed */ gboolean rspamd_task_process (struct rspamd_task *task, - struct rspamd_http_message *msg, GThreadPool *classify_pool, + struct rspamd_http_message *msg, const gchar *start, gsize len, + GThreadPool *classify_pool, gboolean process_extra_filters); /** |