]> source.dussan.org Git - rspamd.git/commitdiff
Add keys support for the router.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 29 Jan 2015 16:30:57 +0000 (16:30 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 29 Jan 2015 16:30:57 +0000 (16:30 +0000)
src/libutil/http.c
src/libutil/http.h

index 74474365be97a978fca6d2cc41e273dbfd8b082c..2e7e144ebb8e041a019eb1fa856c068d16f04aa3 100644 (file)
@@ -1542,7 +1542,7 @@ rspamd_http_router_new (rspamd_http_router_error_handler_t eh,
        struct rspamd_http_connection_router * new;
        struct stat st;
 
-       new = g_slice_alloc (sizeof (struct rspamd_http_connection_router));
+       new = g_slice_alloc0 (sizeof (struct rspamd_http_connection_router));
        new->paths = g_hash_table_new (rspamd_strcase_hash, rspamd_strcase_equal);
        new->conns = NULL;
        new->error_handler = eh;
@@ -1574,6 +1574,18 @@ rspamd_http_router_new (rspamd_http_router_error_handler_t eh,
        return new;
 }
 
+void
+rspamd_http_router_set_key (struct rspamd_http_connection_router *router,
+               gpointer key)
+{
+       struct rspamd_http_keypair *kp = (struct rspamd_http_keypair *)key;
+
+       g_assert (key != NULL);
+       REF_RETAIN (kp);
+
+       router->key = key;
+}
+
 void
 rspamd_http_router_add_path (struct rspamd_http_connection_router *router,
        const gchar *path, rspamd_http_router_handler_t handler)
@@ -1605,6 +1617,10 @@ rspamd_http_router_handle_socket (struct rspamd_http_connection_router *router,
                        0,
                        RSPAMD_HTTP_SERVER);
 
+       if (router->key) {
+               rspamd_http_connection_set_key (conn->conn, router->key);
+       }
+
        rspamd_http_connection_read_message (conn->conn, conn, fd, router->ptv,
                router->ev_base);
        LL_PREPEND (router->conns, conn);
index d88424626caba6fe5ca981bef18ed751a6ea239b..589b382457d9fe642b04b44f26a3c615ad685a96 100644 (file)
@@ -130,6 +130,7 @@ struct rspamd_http_connection_router {
        struct timeval *ptv;
        struct event_base *ev_base;
        gchar *default_fs_path;
+       gpointer key;
        rspamd_http_router_error_handler_t error_handler;
        rspamd_http_router_finish_handler_t finish_handler;
 };
@@ -301,6 +302,14 @@ struct rspamd_http_connection_router * rspamd_http_router_new (
        struct event_base *base,
        const char *default_fs_path);
 
+/**
+ * Set encryption key for the HTTP router
+ * @param router router structure
+ * @param key opaque key structure
+ */
+void rspamd_http_router_set_key (struct rspamd_http_connection_router *router,
+               gpointer key);
+
 /**
  * Add new path to the router
  */