]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Implement SSL support in http client
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 13 Jun 2016 13:27:48 +0000 (14:27 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 13 Jun 2016 16:31:29 +0000 (17:31 +0100)
15 files changed:
src/client/rspamdclient.c
src/fuzzy_storage.c
src/libserver/rspamd_control.c
src/libutil/http.c
src/libutil/http.h
src/libutil/map.c
src/libutil/ssl_util.c
src/lua/lua_http.c
src/plugins/surbl.c
src/rspamadm/control.c
src/rspamd_proxy.c
src/worker.c
test/rspamd_http_test.c
utils/rspamd_http_bench.c
utils/rspamd_http_server.c

index 5932da38b89c0a34f5ae9f33bf696af0e9e29e8a..753f64c746f64290e86f999cc3b2209c0fda86c8 100644 (file)
@@ -167,7 +167,8 @@ rspamd_client_init (struct event_base *ev_base, const gchar *name,
                        rspamd_client_finish_handler,
                        0,
                        RSPAMD_HTTP_CLIENT,
-                       conn->keys_cache);
+                       conn->keys_cache,
+                       NULL);
 
        conn->server_name = g_string_new (name);
        if (port != 0) {
index b49a359849ae0223d757d7b2570d12b2de9062e4..04498f84d5687ac0bb06debd6335e9d60242be65 100644 (file)
@@ -363,13 +363,13 @@ rspamd_fuzzy_send_update_mirror (struct rspamd_fuzzy_storage_ctx *ctx,
        msg = rspamd_http_new_message (HTTP_REQUEST);
        rspamd_printf_fstring (&msg->url, "/update_v1/%s", m->name);
 
-       conn->http_conn = rspamd_http_connection_new (
-                       NULL,
+       conn->http_conn = rspamd_http_connection_new (NULL,
                        fuzzy_mirror_error_handler,
                        fuzzy_mirror_finish_handler,
                        RSPAMD_HTTP_CLIENT_SIMPLE,
                        RSPAMD_HTTP_CLIENT,
-                       ctx->keypair_cache);
+                       ctx->keypair_cache,
+                       NULL);
 
        rspamd_http_connection_set_key (conn->http_conn,
                        ctx->sync_keypair);
@@ -1200,13 +1200,13 @@ accept_fuzzy_mirror_socket (gint fd, short what, void *arg)
        }
 
        session = g_slice_alloc0 (sizeof (*session));
-       http_conn = rspamd_http_connection_new (
-                       NULL,
+       http_conn = rspamd_http_connection_new (NULL,
                        rspamd_fuzzy_mirror_error_handler,
                        rspamd_fuzzy_mirror_finish_handler,
                        0,
                        RSPAMD_HTTP_SERVER,
-                       ctx->keypair_cache);
+                       ctx->keypair_cache,
+                       NULL);
 
        rspamd_http_connection_set_key (http_conn, ctx->sync_keypair);
        session->ctx = ctx;
index a925c0bb187ddb6b2469e8f3575ed9276a477e4c..da573fa94a645a568b1ee8fe8957a59b97018bf5 100644 (file)
@@ -503,8 +503,13 @@ rspamd_control_process_client_socket (struct rspamd_main *rspamd_main,
        session = g_slice_alloc0 (sizeof (*session));
 
        session->fd = fd;
-       session->conn = rspamd_http_connection_new (NULL, rspamd_control_error_handler,
-                       rspamd_control_finish_handler, 0, RSPAMD_HTTP_SERVER, NULL);
+       session->conn = rspamd_http_connection_new (NULL,
+                       rspamd_control_error_handler,
+                       rspamd_control_finish_handler,
+                       0,
+                       RSPAMD_HTTP_SERVER,
+                       NULL,
+                       NULL);
        session->rspamd_main = rspamd_main;
        rspamd_http_connection_read_message (session->conn, session, session->fd,
                        &io_timeout, rspamd_main->ev_base);
index 57618653a94ce908492962e59f6023087c709b0f..46ebf486c9f3909754aa328c2dd32e142be5a06c 100644 (file)
@@ -24,6 +24,7 @@
 #include "keypair_private.h"
 #include "cryptobox.h"
 #include "unix-std.h"
+#include "libutil/ssl_util.h"
 
 #define ENCRYPTED_VERSION " HTTP/1.0"
 
@@ -42,6 +43,8 @@ enum rspamd_http_priv_flags {
 #define IS_CONN_RESETED(c) ((c)->flags & RSPAMD_HTTP_CONN_FLAG_RESETED)
 
 struct rspamd_http_connection_private {
+       gpointer ssl_ctx;
+       struct rspamd_ssl_connection *ssl;
        struct _rspamd_http_privbuf *buf;
        struct rspamd_cryptobox_pubkey *peer_key;
        struct rspamd_cryptobox_keypair *local_key;
@@ -834,9 +837,15 @@ static void
 rspamd_http_simple_client_helper (struct rspamd_http_connection *conn)
 {
        struct event_base *base;
+       struct rspamd_http_connection_private *priv;
+       gpointer ssl;
 
+       priv = conn->priv;
        base = conn->priv->ev.ev_base;
+       ssl = priv->ssl;
+       priv->ssl = NULL;
        rspamd_http_connection_reset (conn);
+       priv->ssl = ssl;
        /* Plan read message */
        rspamd_http_connection_read_message (conn, conn->ud, conn->fd,
                        conn->priv->ptv, base);
@@ -951,6 +960,16 @@ rspamd_http_try_read (gint fd,
        return r;
 }
 
+static void
+rspamd_http_ssl_err_handler (gpointer ud, GError *err)
+{
+       struct rspamd_http_connection *conn = (struct rspamd_http_connection *)ud;
+
+       rspamd_http_connection_ref (conn);
+       conn->error_handler (conn, err);
+       rspamd_http_connection_unref (conn);
+}
+
 static void
 rspamd_http_event_handler (int fd, short what, gpointer ud)
 {
@@ -1084,39 +1103,42 @@ rspamd_http_parser_reset (struct rspamd_http_connection *conn)
 }
 
 struct rspamd_http_connection *
-rspamd_http_connection_new (rspamd_http_body_handler_t body_handler,
-       rspamd_http_error_handler_t error_handler,
-       rspamd_http_finish_handler_t finish_handler,
-       unsigned opts,
-       enum rspamd_http_connection_type type,
-       struct rspamd_keypair_cache *cache)
-{
-       struct rspamd_http_connection *new;
+rspamd_http_connection_new (
+               rspamd_http_body_handler_t body_handler,
+               rspamd_http_error_handler_t error_handler,
+               rspamd_http_finish_handler_t finish_handler,
+               unsigned opts,
+               enum rspamd_http_connection_type type,
+               struct rspamd_keypair_cache *cache,
+               gpointer ssl_ctx)
+{
+       struct rspamd_http_connection *conn;
        struct rspamd_http_connection_private *priv;
 
        if (error_handler == NULL || finish_handler == NULL) {
                return NULL;
        }
 
-       new = g_slice_alloc0 (sizeof (struct rspamd_http_connection));
-       new->opts = opts;
-       new->type = type;
-       new->body_handler = body_handler;
-       new->error_handler = error_handler;
-       new->finish_handler = finish_handler;
-       new->fd = -1;
-       new->ref = 1;
-       new->finished = FALSE;
-       new->cache = cache;
+       conn = g_slice_alloc0 (sizeof (struct rspamd_http_connection));
+       conn->opts = opts;
+       conn->type = type;
+       conn->body_handler = body_handler;
+       conn->error_handler = error_handler;
+       conn->finish_handler = finish_handler;
+       conn->fd = -1;
+       conn->ref = 1;
+       conn->finished = FALSE;
+       conn->cache = cache;
 
        /* Init priv */
        priv = g_slice_alloc0 (sizeof (struct rspamd_http_connection_private));
-       new->priv = priv;
+       conn->priv = priv;
+       priv->ssl_ctx = ssl_ctx;
 
-       rspamd_http_parser_reset (new);
-       priv->parser.data = new;
+       rspamd_http_parser_reset (conn);
+       priv->parser.data = conn;
 
-       return new;
+       return conn;
 }
 
 void
@@ -1156,6 +1178,11 @@ rspamd_http_connection_reset (struct rspamd_http_connection *conn)
                priv->out = NULL;
        }
 
+       if (priv->ssl) {
+               rspamd_ssl_connection_free (priv->ssl);
+               priv->ssl = NULL;
+       }
+
        priv->flags |= RSPAMD_HTTP_CONN_FLAG_RESETED;
 }
 
@@ -1504,6 +1531,7 @@ rspamd_http_connection_write_message_common (struct rspamd_http_connection *conn
        guchar *np = NULL, *mp = NULL, *meth_pos = NULL;
        struct rspamd_cryptobox_pubkey *peer_key = NULL;
        enum rspamd_cryptobox_mode mode;
+       GError *err;
 
        conn->fd = fd;
        conn->ud = ud;
@@ -1900,18 +1928,51 @@ rspamd_http_connection_write_message_common (struct rspamd_http_connection *conn
                }
        }
 
+       priv->flags &= ~RSPAMD_HTTP_CONN_FLAG_RESETED;
+
        if (base != NULL && event_get_base (&priv->ev) == base) {
                event_del (&priv->ev);
        }
 
-       event_set (&priv->ev, fd, EV_WRITE, rspamd_http_event_handler, conn);
+       if (msg->flags & RSPAMD_HTTP_FLAG_SSL) {
+               if (base != NULL) {
+                       event_base_set (base, &priv->ev);
+               }
+               if (!priv->ssl_ctx) {
+                       err = g_error_new (HTTP_ERROR, errno, "ssl message requested "
+                                       "with no ssl ctx");
+                       rspamd_http_connection_ref (conn);
+                       conn->error_handler (conn, err);
+                       rspamd_http_connection_unref (conn);
+                       g_error_free (err);
+                       return;
+               }
+               else {
+                       priv->ssl = rspamd_ssl_connection_new (priv->ssl_ctx);
+                       g_assert (priv->ssl != NULL);
+
+                       if (!rspamd_ssl_connect_fd (priv->ssl, fd, host, &priv->ev,
+                                       priv->ptv, rspamd_http_event_handler,
+                                       rspamd_http_ssl_err_handler, conn)) {
 
-       if (base != NULL) {
-               event_base_set (base, &priv->ev);
+                               err = g_error_new (HTTP_ERROR, errno, "ssl connection error");
+                               rspamd_http_connection_ref (conn);
+                               conn->error_handler (conn, err);
+                               rspamd_http_connection_unref (conn);
+                               g_error_free (err);
+                               return;
+                       }
+               }
        }
+       else {
+               event_set (&priv->ev, fd, EV_WRITE, rspamd_http_event_handler, conn);
 
-       priv->flags &= ~RSPAMD_HTTP_CONN_FLAG_RESETED;
-       event_add (&priv->ev, priv->ptv);
+               if (base != NULL) {
+                       event_base_set (base, &priv->ev);
+               }
+
+               event_add (&priv->ev, priv->ptv);
+       }
 }
 
 void
@@ -1961,6 +2022,7 @@ rspamd_http_message_from_url (const gchar *url)
        struct rspamd_http_message *msg;
        const gchar *host, *path;
        size_t pathlen, urllen;
+       guint flags = 0;
 
        if (url == NULL) {
                return NULL;
@@ -1977,6 +2039,14 @@ rspamd_http_message_from_url (const gchar *url)
                msg_warn ("no host argument in URL: %s", url);
                return NULL;
        }
+
+       if ((pu.field_set & (1 << UF_SCHEMA))) {
+               if (pu.field_data[UF_SCHEMA].len == sizeof ("https") - 1 &&
+                               memcmp (url + pu.field_data[UF_SCHEMA].off, "https", 5) == 0) {
+                       flags |= RSPAMD_HTTP_FLAG_SSL;
+               }
+       }
+
        if ((pu.field_set & (1 << UF_PATH)) == 0) {
                path = "/";
                pathlen = 1;
@@ -1988,13 +2058,19 @@ rspamd_http_message_from_url (const gchar *url)
 
        msg = rspamd_http_new_message (HTTP_REQUEST);
        host = url + pu.field_data[UF_HOST].off;
+       msg->flags = flags;
 
        if ((pu.field_set & (1 << UF_PORT)) != 0) {
                msg->port = pu.port;
        }
        else {
                /* XXX: magic constant */
-               msg->port = 80;
+               if (flags & RSPAMD_HTTP_FLAG_SSL) {
+                       msg->port = 443;
+               }
+               else {
+                       msg->port = 80;
+               }
        }
 
        msg->host = rspamd_fstring_new_init (host, pu.field_data[UF_HOST].len);
@@ -2724,7 +2800,9 @@ rspamd_http_router_handle_socket (struct rspamd_http_connection_router *router,
                        rspamd_http_router_error_handler,
                        rspamd_http_router_finish_handler,
                        0,
-                       RSPAMD_HTTP_SERVER, router->cache);
+                       RSPAMD_HTTP_SERVER,
+                       router->cache,
+                       NULL);
 
        if (router->key) {
                rspamd_http_connection_set_key (conn->conn, router->key);
index 4cbcaf5fb11eea2add05b2c2ee1af6f07071b5b6..e85e7ccee88e1f5ada959bede010292718ccb7ca 100644 (file)
@@ -53,6 +53,10 @@ struct rspamd_http_connection_entry;
  * Store body of the message in an immutable shared memory segment
  */
 #define RSPAMD_HTTP_FLAG_SHMEM_IMMUTABLE (1 << 3)
+/**
+ * Use tls for this message
+ */
+#define RSPAMD_HTTP_FLAG_SSL (1 << 4)
 
 /**
  * Options for HTTP connection
@@ -64,24 +68,24 @@ enum rspamd_http_options {
 };
 
 typedef int (*rspamd_http_body_handler_t) (struct rspamd_http_connection *conn,
-       struct rspamd_http_message *msg,
-       const gchar *chunk,
-       gsize len);
+               struct rspamd_http_message *msg,
+               const gchar *chunk,
+               gsize len);
 
 typedef void (*rspamd_http_error_handler_t) (struct rspamd_http_connection *conn,
-       GError *err);
+               GError *err);
 
 typedef int (*rspamd_http_finish_handler_t) (struct rspamd_http_connection *conn,
-       struct rspamd_http_message *msg);
+               struct rspamd_http_message *msg);
 
 typedef int (*rspamd_http_router_handler_t) (struct rspamd_http_connection_entry
-       *conn_ent,
-       struct rspamd_http_message *msg);
+               *conn_ent,
+               struct rspamd_http_message *msg);
 typedef void (*rspamd_http_router_error_handler_t) (struct
-       rspamd_http_connection_entry *conn_ent,
-       GError *err);
+               rspamd_http_connection_entry *conn_ent,
+               GError *err);
 typedef void (*rspamd_http_router_finish_handler_t) (struct
-       rspamd_http_connection_entry *conn_ent);
+               rspamd_http_connection_entry *conn_ent);
 
 /**
  * HTTP connection structure
@@ -127,13 +131,14 @@ struct rspamd_http_connection_router {
  * @param opts options
  * @return new connection structure
  */
-struct rspamd_http_connection * rspamd_http_connection_new (
-       rspamd_http_body_handler_t body_handler,
-       rspamd_http_error_handler_t error_handler,
-       rspamd_http_finish_handler_t finish_handler,
-       unsigned opts,
-       enum rspamd_http_connection_type type,
-       struct rspamd_keypair_cache *cache);
+struct rspamd_http_connection *rspamd_http_connection_new (
+               rspamd_http_body_handler_t body_handler,
+               rspamd_http_error_handler_t error_handler,
+               rspamd_http_finish_handler_t finish_handler,
+               unsigned opts,
+               enum rspamd_http_connection_type type,
+               struct rspamd_keypair_cache *cache,
+               gpointer ssl_ctx);
 
 
 /**
@@ -335,8 +340,8 @@ gboolean rspamd_http_message_append_body (struct rspamd_http_message *msg,
  * @param value
  */
 void rspamd_http_message_add_header (struct rspamd_http_message *msg,
-       const gchar *name,
-       const gchar *value);
+               const gchar *name,
+               const gchar *value);
 
 /**
  * Search for a specified header in message
@@ -354,7 +359,7 @@ const rspamd_ftok_t * rspamd_http_message_find_header (
  * @return
  */
 gboolean rspamd_http_message_remove_header (struct rspamd_http_message *msg,
-       const gchar *name);
+               const gchar *name);
 
 /**
  * Free HTTP message
@@ -390,12 +395,12 @@ time_t rspamd_http_parse_date (const gchar *header, gsize len);
  * @return
  */
 struct rspamd_http_connection_router * rspamd_http_router_new (
-       rspamd_http_router_error_handler_t eh,
-       rspamd_http_router_finish_handler_t fh,
-       struct timeval *timeout,
-       struct event_base *base,
-       const char *default_fs_path,
-       struct rspamd_keypair_cache *cache);
+               rspamd_http_router_error_handler_t eh,
+               rspamd_http_router_finish_handler_t fh,
+               struct timeval *timeout,
+               struct event_base *base,
+               const char *default_fs_path,
+               struct rspamd_keypair_cache *cache);
 
 /**
  * Set encryption key for the HTTP router
@@ -409,7 +414,7 @@ void rspamd_http_router_set_key (struct rspamd_http_connection_router *router,
  * Add new path to the router
  */
 void rspamd_http_router_add_path (struct rspamd_http_connection_router *router,
-       const gchar *path, rspamd_http_router_handler_t handler);
+               const gchar *path, rspamd_http_router_handler_t handler);
 
 /**
  * Handle new accepted socket
@@ -418,9 +423,9 @@ void rspamd_http_router_add_path (struct rspamd_http_connection_router *router,
  * @param ud opaque userdata
  */
 void rspamd_http_router_handle_socket (
-       struct rspamd_http_connection_router *router,
-       gint fd,
-       gpointer ud);
+               struct rspamd_http_connection_router *router,
+               gint fd,
+               gpointer ud);
 
 /**
  * Free router and all connections associated
index b747b6a96cca4c0d57e3b66c44fd1fe974a00558..6bc0ef257ec7e5f788f953a37de559091e0deaa0 100644 (file)
@@ -646,9 +646,13 @@ rspamd_map_dns_callback (struct rdns_reply *reply, void *arg)
                                if (cbd->fd != -1) {
                                        cbd->stage = map_load_file;
                                        cbd->conn = rspamd_http_connection_new (http_map_read,
-                                                       http_map_error, http_map_finish,
-                                                       RSPAMD_HTTP_BODY_PARTIAL|RSPAMD_HTTP_CLIENT_SIMPLE,
-                                                       RSPAMD_HTTP_CLIENT, NULL);
+                                                       http_map_error,
+                                                       http_map_finish,
+                                                       RSPAMD_HTTP_BODY_PARTIAL |
+                                                                       RSPAMD_HTTP_CLIENT_SIMPLE,
+                                                       RSPAMD_HTTP_CLIENT,
+                                                       NULL,
+                                                       NULL);
 
                                        write_http_request (cbd);
                                }
index d0f73a907023cac2900849d12bdff249c0fd1503..6c426761b8ea8ad86de25a76d39afa7cc8b1110c 100644 (file)
@@ -363,7 +363,7 @@ rspamd_ssl_event_handler (gint fd, short what, gpointer ud)
                        /* Verify certificate */
                        if (rspamd_ssl_peer_verify (c)) {
                                c->state = ssl_conn_connected;
-                               c->handler (fd, what, c->handler_data);
+                               c->handler (fd, EV_WRITE, c->handler_data);
                        }
                        else {
                                /* Error handler has been called from peer verify */
index 0e9c99cc7943b8055fa799ad32f973e18d48e76b..298da5a47594e799ed30d024f7c5aa48af76e8fb 100644 (file)
@@ -201,9 +201,13 @@ lua_http_make_connection (struct lua_http_cbdata *cbd)
                return FALSE;
        }
        cbd->fd = fd;
-       cbd->conn = rspamd_http_connection_new (NULL, lua_http_error_handler,
-                       lua_http_finish_handler, RSPAMD_HTTP_CLIENT_SIMPLE,
-                       RSPAMD_HTTP_CLIENT, NULL);
+       cbd->conn = rspamd_http_connection_new (NULL,
+                       lua_http_error_handler,
+                       lua_http_finish_handler,
+                       RSPAMD_HTTP_CLIENT_SIMPLE,
+                       RSPAMD_HTTP_CLIENT,
+                       NULL,
+                       NULL);
 
        rspamd_http_connection_write_message (cbd->conn, cbd->msg,
                        NULL, cbd->mime_type, cbd, fd, &cbd->tv, cbd->ev_base);
index 4cd594b8fc90ff363cf01e8f16fdcce88b55ca68..1e0eacff18510f03128ca12b225bf82dfb2032ac 100644 (file)
@@ -1329,10 +1329,13 @@ register_redirector_call (struct rspamd_url *url, struct rspamd_task *task,
                        sizeof (struct redirector_param));
        param->url = url;
        param->task = task;
-       param->conn = rspamd_http_connection_new (NULL, surbl_redirector_error,
+       param->conn = rspamd_http_connection_new (NULL,
+                       surbl_redirector_error,
                        surbl_redirector_finish,
                        RSPAMD_HTTP_CLIENT_SIMPLE,
-                       RSPAMD_HTTP_CLIENT, NULL);
+                       RSPAMD_HTTP_CLIENT,
+                       NULL,
+                       NULL);
        msg = rspamd_http_new_message (HTTP_REQUEST);
        msg->url = rspamd_fstring_assign (msg->url, url->string, url->urllen);
        param->sock = s;
index 52fec99c6756a81441a30ea4208299ea07f79031..2bdccc876bbac0fc7d3011f95974078dce240cd7 100644 (file)
@@ -230,9 +230,13 @@ rspamadm_control (gint argc, gchar **argv)
 
        L = rspamd_lua_init ();
 
-       conn = rspamd_http_connection_new (NULL, rspamd_control_error_handler,
-                       rspamd_control_finish_handler, RSPAMD_HTTP_CLIENT_SIMPLE,
-                       RSPAMD_HTTP_CLIENT, NULL);
+       conn = rspamd_http_connection_new (NULL,
+                       rspamd_control_error_handler,
+                       rspamd_control_finish_handler,
+                       RSPAMD_HTTP_CLIENT_SIMPLE,
+                       RSPAMD_HTTP_CLIENT,
+                       NULL,
+                       NULL);
        msg = rspamd_http_new_message (HTTP_REQUEST);
        msg->url = rspamd_fstring_new_init (path, strlen (path));
        double_to_tv (timeout, &tv);
index 8290795f86ae2b2b9e0a58eddf788c6c62142e13..b7e0c961868f756fcbe485e108f5ce4316fe06c8 100644 (file)
@@ -1023,13 +1023,13 @@ proxy_open_mirror_connections (struct rspamd_proxy_session *session)
                        rspamd_http_message_add_header (msg, "Settings-ID", m->settings_id);
                }
 
-               bk_conn->backend_conn = rspamd_http_connection_new (
-                               NULL,
+               bk_conn->backend_conn = rspamd_http_connection_new (NULL,
                                proxy_backend_mirror_error_handler,
                                proxy_backend_mirror_finish_handler,
                                RSPAMD_HTTP_CLIENT_SIMPLE,
                                RSPAMD_HTTP_CLIENT,
-                               session->ctx->keys_cache);
+                               session->ctx->keys_cache,
+                               NULL);
 
                rspamd_http_connection_set_key (bk_conn->backend_conn,
                                session->ctx->local_key);
@@ -1219,7 +1219,8 @@ proxy_client_finish_handler (struct rspamd_http_connection *conn,
                                        proxy_backend_master_finish_handler,
                                        RSPAMD_HTTP_CLIENT_SIMPLE,
                                        RSPAMD_HTTP_CLIENT,
-                                       session->ctx->keys_cache);
+                                       session->ctx->keys_cache,
+                                       NULL);
                        session->master_conn->parser_from_ref = backend->parser_from_ref;
                        session->master_conn->parser_to_ref = backend->parser_to_ref;
 
@@ -1291,13 +1292,13 @@ proxy_accept_socket (gint fd, short what, void *arg)
        session->mirror_conns = g_ptr_array_sized_new (ctx->mirrors->len);
 
        session->pool = rspamd_mempool_new (rspamd_mempool_suggest_size (), "proxy");
-       session->client_conn = rspamd_http_connection_new (
-               NULL,
-               proxy_client_error_handler,
-               proxy_client_finish_handler,
-               0,
-               RSPAMD_HTTP_SERVER,
-               ctx->keys_cache);
+       session->client_conn = rspamd_http_connection_new (NULL,
+                       proxy_client_error_handler,
+                       proxy_client_finish_handler,
+                       0,
+                       RSPAMD_HTTP_SERVER,
+                       ctx->keys_cache,
+                       NULL);
        session->ctx = ctx;
 
        if (ctx->key) {
index 81c5b1c63e3b224d271e9861c9c16659fe295c9d..a099e817730a4e2ef44491cf46957a9e39d94c80 100644 (file)
@@ -298,13 +298,13 @@ accept_socket (gint fd, short what, void *arg)
        /* TODO: allow to disable autolearn in protocol */
        task->flags |= RSPAMD_TASK_FLAG_LEARN_AUTO;
 
-       task->http_conn = rspamd_http_connection_new (
-               rspamd_worker_body_handler,
-               rspamd_worker_error_handler,
-               rspamd_worker_finish_handler,
-               0,
-               RSPAMD_HTTP_SERVER,
-               ctx->keys_cache);
+       task->http_conn = rspamd_http_connection_new (rspamd_worker_body_handler,
+                       rspamd_worker_error_handler,
+                       rspamd_worker_finish_handler,
+                       0,
+                       RSPAMD_HTTP_SERVER,
+                       ctx->keys_cache,
+                       NULL);
        task->ev_base = ctx->ev_base;
        worker->nconns++;
        rspamd_mempool_add_destructor (task->task_pool,
index 882b148fc7e46366a24ac2cee9b9c61bd806d889..4ce859efda8752b3048e2323c849bd9323d154b0 100644 (file)
@@ -156,9 +156,13 @@ rspamd_http_client_func (const gchar *path, rspamd_inet_addr_t *addr,
        gint fd;
 
        g_assert ((fd = rspamd_inet_address_connect (addr, SOCK_STREAM, TRUE)) != -1);
-       conn = rspamd_http_connection_new (rspamd_client_body, rspamd_client_err,
-                       rspamd_client_finish, RSPAMD_HTTP_CLIENT_SIMPLE,
-                       RSPAMD_HTTP_CLIENT, c);
+       conn = rspamd_http_connection_new (rspamd_client_body,
+                       rspamd_client_err,
+                       rspamd_client_finish,
+                       RSPAMD_HTTP_CLIENT_SIMPLE,
+                       RSPAMD_HTTP_CLIENT,
+                       c,
+                       NULL);
        rspamd_snprintf (urlbuf, sizeof (urlbuf), "http://127.0.0.1/%s", path);
        msg = rspamd_http_message_from_url (urlbuf);
 
index 64b4e6ed21f5fd2171458a1c37bb124c5f51183e..32aedb3344b1e4aac3df416627e572ccf443b13e 100644 (file)
@@ -146,9 +146,13 @@ rspamd_http_client_func (struct event_base *ev_base, struct lat_elt *latency,
        g_assert (fd != -1);
        flags = 1;
        (void)setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &flags, sizeof (flags));
-       conn = rspamd_http_connection_new (rspamd_client_body, rspamd_client_err,
-                       rspamd_client_finish, RSPAMD_HTTP_CLIENT_SIMPLE,
-                       RSPAMD_HTTP_CLIENT, c);
+       conn = rspamd_http_connection_new (rspamd_client_body,
+                       rspamd_client_err,
+                       rspamd_client_finish,
+                       RSPAMD_HTTP_CLIENT_SIMPLE,
+                       RSPAMD_HTTP_CLIENT,
+                       c,
+                       NULL);
        rspamd_snprintf (urlbuf, sizeof (urlbuf), "http://%s/%d", host, file_size);
        msg = rspamd_http_message_from_url (urlbuf);
 
index d920c425de345ce1048bd0fa920ad68fb6d6611f..69ef852e67e09f3f804985de495e21b1ceed3eae 100644 (file)
@@ -150,8 +150,13 @@ rspamd_server_accept (gint fd, short what, void *arg)
 
                rspamd_inet_address_destroy (addr);
                session = g_slice_alloc (sizeof (*session));
-               session->conn = rspamd_http_connection_new (NULL, rspamd_server_error,
-                               rspamd_server_finish, 0, RSPAMD_HTTP_SERVER, c);
+               session->conn = rspamd_http_connection_new (NULL,
+                               rspamd_server_error,
+                               rspamd_server_finish,
+                               0,
+                               RSPAMD_HTTP_SERVER,
+                               c,
+                               NULL);
                rspamd_http_connection_set_key (session->conn, server_key);
                rspamd_http_connection_read_message (session->conn,
                                session,