From: Vsevolod Stakhov Date: Thu, 29 Jan 2015 16:30:57 +0000 (+0000) Subject: Add keys support for the router. X-Git-Tag: 0.9.0~816 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3a0bbd8895c957d57a27ed90fcb320d60bb8b104;p=rspamd.git Add keys support for the router. --- diff --git a/src/libutil/http.c b/src/libutil/http.c index 74474365b..2e7e144eb 100644 --- a/src/libutil/http.c +++ b/src/libutil/http.c @@ -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); diff --git a/src/libutil/http.h b/src/libutil/http.h index d88424626..589b38245 100644 --- a/src/libutil/http.h +++ b/src/libutil/http.h @@ -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 */