diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-01-29 16:30:57 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-01-29 16:30:57 +0000 |
commit | 3a0bbd8895c957d57a27ed90fcb320d60bb8b104 (patch) | |
tree | ba4ec10d3f26930fbeff60081c954e73d9dee79f /src/libutil | |
parent | 1ff1b64500d0423a7a2bf8f4ef66ebec2de1a201 (diff) | |
download | rspamd-3a0bbd8895c957d57a27ed90fcb320d60bb8b104.tar.gz rspamd-3a0bbd8895c957d57a27ed90fcb320d60bb8b104.zip |
Add keys support for the router.
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/http.c | 18 | ||||
-rw-r--r-- | src/libutil/http.h | 9 |
2 files changed, 26 insertions, 1 deletions
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; @@ -1575,6 +1575,18 @@ rspamd_http_router_new (rspamd_http_router_error_handler_t eh, } 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; }; @@ -302,6 +303,14 @@ struct rspamd_http_connection_router * rspamd_http_router_new ( 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 */ void rspamd_http_router_add_path (struct rspamd_http_connection_router *router, |