summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-01-30 18:25:37 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-01-30 18:25:37 +0000
commit0fdf87238f0894cdb4813c19f0806330de486b2c (patch)
treec78434a5bd3c71926da3eee3521d8543215508a0 /src
parent0d16792e387ccb9d71afe31101a7e77eb70314ef (diff)
downloadrspamd-0fdf87238f0894cdb4813c19f0806330de486b2c.tar.gz
rspamd-0fdf87238f0894cdb4813c19f0806330de486b2c.zip
Preserve keys inside HTTP session.
Diffstat (limited to 'src')
-rw-r--r--src/libutil/http.c17
-rw-r--r--src/libutil/http.h1
2 files changed, 17 insertions, 1 deletions
diff --git a/src/libutil/http.c b/src/libutil/http.c
index dc4774c2f..914ee6d6a 100644
--- a/src/libutil/http.c
+++ b/src/libutil/http.c
@@ -48,6 +48,7 @@ struct rspamd_http_connection_private {
} *buf;
gboolean new_header;
gboolean encrypted;
+ gpointer peer_key;
struct rspamd_http_keypair *local_key;
struct rspamd_http_header *header;
struct http_parser parser;
@@ -557,6 +558,7 @@ rspamd_http_on_headers_complete (http_parser * parser)
priv->msg->body = g_string_sized_new (BUFSIZ);
}
+ priv->msg->body_buf.str = priv->msg->body->str;
priv->msg->method = parser->method;
priv->msg->code = parser->status_code;
@@ -618,6 +620,9 @@ rspamd_http_on_message_complete (http_parser * parser)
m += crypto_box_ZEROBYTES;
dec_len -= crypto_box_ZEROBYTES;
+ priv->msg->body->str = m;
+ priv->msg->body->len = dec_len;
+
rspamd_http_connection_ref (conn);
ret = conn->body_handler (conn,
priv->msg,
@@ -898,6 +903,9 @@ rspamd_http_connection_reset (struct rspamd_http_connection *conn)
/* Clear request */
if (msg != NULL) {
+ if (msg->peer_key) {
+ priv->peer_key = msg->peer_key;
+ }
rspamd_http_message_free (msg);
priv->msg = NULL;
}
@@ -945,6 +953,11 @@ rspamd_http_connection_read_message (struct rspamd_http_connection *conn,
conn->type == RSPAMD_HTTP_SERVER ? HTTP_REQUEST : HTTP_RESPONSE);
priv->msg = req;
+ if (priv->peer_key) {
+ priv->msg->peer_key = priv->peer_key;
+ priv->encrypted = TRUE;
+ }
+
if (timeout == NULL) {
priv->ptv = NULL;
}
@@ -1191,6 +1204,7 @@ rspamd_http_new_message (enum http_parser_type type)
new->headers = NULL;
new->date = 0;
new->body = NULL;
+ memset (&new->body_buf, 0, sizeof (new->body_buf));
new->status = NULL;
new->host = NULL;
new->port = 80;
@@ -1261,7 +1275,8 @@ rspamd_http_message_free (struct rspamd_http_message *msg)
g_slice_free1 (sizeof (struct rspamd_http_header), hdr);
}
if (msg->body != NULL) {
- g_string_free (msg->body, TRUE);
+ g_string_free (msg->body, FALSE);
+ g_free (msg->body_buf.str);
}
if (msg->url != NULL) {
g_string_free (msg->url, TRUE);
diff --git a/src/libutil/http.h b/src/libutil/http.h
index c290d803c..59ac5ef20 100644
--- a/src/libutil/http.h
+++ b/src/libutil/http.h
@@ -58,6 +58,7 @@ struct rspamd_http_message {
GString *status;
struct rspamd_http_header *headers;
GString *body;
+ GString body_buf;
gpointer peer_key;
enum http_parser_type type;
time_t date;