aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-03-30 13:15:14 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-03-30 13:15:14 +0100
commitbd61e464bc4a9728429859948d76e2e9303b7d55 (patch)
treee608cf4c155dcde730c862f00cf91a397751e08c /src/libserver
parent826050f3a80eb9b2490fa1f472f37002a7620afa (diff)
downloadrspamd-bd61e464bc4a9728429859948d76e2e9303b7d55.tar.gz
rspamd-bd61e464bc4a9728429859948d76e2e9303b7d55.zip
Add ability to append control json within rspamd request.
Diffstat (limited to 'src/libserver')
-rw-r--r--src/libserver/protocol.c15
-rw-r--r--src/libserver/task.h16
2 files changed, 24 insertions, 7 deletions
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c
index b879db7ff..08e7bc3c3 100644
--- a/src/libserver/protocol.c
+++ b/src/libserver/protocol.c
@@ -96,6 +96,7 @@
#define HOSTNAME_HEADER "Hostname"
#define DELIVER_TO_HEADER "Deliver-To"
#define NO_LOG_HEADER "Log"
+#define MLEN_HEADER "Message-Length"
static GList *custom_commands = NULL;
@@ -387,6 +388,20 @@ rspamd_protocol_handle_headers (struct rspamd_task *task,
validh = FALSE;
}
break;
+ case 'm':
+ case 'M':
+ if (g_ascii_strcasecmp (headern, MLEN_HEADER) == 0) {
+ task->message_len = strtoul (h->value->str, NULL, 10);
+
+ if (task->message_len == 0) {
+ msg_err ("Invalid message length header: %s", h->value->str);
+ validh = FALSE;
+ }
+ }
+ else {
+ validh = FALSE;
+ }
+ break;
default:
debug_task ("unknown header: %s", headern);
validh = FALSE;
diff --git a/src/libserver/task.h b/src/libserver/task.h
index 5cec573e7..52c45c9d4 100644
--- a/src/libserver/task.h
+++ b/src/libserver/task.h
@@ -60,6 +60,7 @@ enum rspamd_metric_action {
#define RSPAMD_TASK_FLAG_PASS_ALL (1 << 6)
#define RSPAMD_TASK_FLAG_NO_LOG (1 << 7)
#define RSPAMD_TASK_FLAG_NO_IP (1 << 8)
+#define RSPAMD_TASK_FLAG_HAS_JSON (1 << 9)
#define RSPAMD_TASK_IS_SKIPPED(task) (((task)->flags & RSPAMD_TASK_FLAG_SKIP))
#define RSPAMD_TASK_IS_JSON(task) (((task)->flags & RSPAMD_TASK_FLAG_JSON))
@@ -77,6 +78,7 @@ struct custom_command {
*/
struct rspamd_task {
struct rspamd_worker *worker; /**< pointer to worker object */
+ struct custom_command *custom_cmd; /**< custom command if any */
enum {
READ_MESSAGE,
WAIT_PRE_FILTER,
@@ -87,18 +89,18 @@ struct rspamd_task {
CLOSING_CONNECTION
} state; /**< current session state */
enum rspamd_command cmd; /**< command */
- struct custom_command *custom_cmd; /**< custom command if any */
gint sock; /**< socket descriptor */
- guint flags;
+ guint flags; /**< Bit flags */
+ guint message_len; /**< Message length */
- gchar *helo; /**< helo header value */
- gchar *queue_id; /**< queue id if specified */
- const gchar *message_id; /**< message id */
+ gchar *helo; /**< helo header value */
+ gchar *queue_id; /**< queue id if specified */
+ const gchar *message_id; /**< message id */
rspamd_inet_addr_t *from_addr; /**< from addr for a task */
rspamd_inet_addr_t *client_addr; /**< address of connected socket */
gchar *deliver_to; /**< address to deliver */
- gchar *user; /**< user to deliver */
+ gchar *user; /**< user to deliver */
gchar *subject; /**< subject (for non-mime) */
gchar *hostname; /**< hostname reported by MTA */
GHashTable *request_headers; /**< HTTP headers in a request */
@@ -114,7 +116,7 @@ struct rspamd_task {
GMimeObject *parser_parent_part; /**< current parent part */
GList *parts; /**< list of parsed parts */
GList *text_parts; /**< list of text parts */
- gchar *raw_headers_str; /**< list of raw headers */
+ gchar *raw_headers_str; /**< list of raw headers */
GList *received; /**< list of received headers */
GTree *urls; /**< list of parsed urls */
GTree *emails; /**< list of parsed emails */