aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-02-06 13:22:42 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-02-06 13:22:42 +0000
commit81e728813bcd1f48030d29a66d27378029b1be30 (patch)
treec475354b256511390b721e43280c1de767627f47 /utils
parent07b0348c09572417d7b3f9511e32c8392b9ee0d7 (diff)
downloadrspamd-81e728813bcd1f48030d29a66d27378029b1be30.tar.gz
rspamd-81e728813bcd1f48030d29a66d27378029b1be30.zip
Fix benchmarks
Diffstat (limited to 'utils')
-rw-r--r--utils/CMakeLists.txt20
-rw-r--r--utils/rspamd_http_bench.c20
-rw-r--r--utils/rspamd_http_server.c19
3 files changed, 26 insertions, 33 deletions
diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt
index 762ae2c6a..f9eefb4f0 100644
--- a/utils/CMakeLists.txt
+++ b/utils/CMakeLists.txt
@@ -1,17 +1,17 @@
SET(UTILSERVERSRC rspamd_http_server.c)
SET(UTILBENCHSRC rspamd_http_bench.c)
-#ADD_EXECUTABLE(rspamd-http-server ${UTILSERVERSRC})
-#SET_TARGET_PROPERTIES(rspamd-http-server PROPERTIES LINKER_LANGUAGE C)
-#TARGET_LINK_LIBRARIES(rspamd-http-server rspamd-server)
-#TARGET_LINK_LIBRARIES(rspamd-http-server rspamd-http-parser)
-#TARGET_LINK_LIBRARIES(rspamd-http-server ${RSPAMD_REQUIRED_LIBRARIES})
+ADD_EXECUTABLE(rspamd-http-server ${UTILSERVERSRC})
+SET_TARGET_PROPERTIES(rspamd-http-server PROPERTIES LINKER_LANGUAGE C)
+TARGET_LINK_LIBRARIES(rspamd-http-server rspamd-server)
+TARGET_LINK_LIBRARIES(rspamd-http-server rspamd-http-parser)
+TARGET_LINK_LIBRARIES(rspamd-http-server ${RSPAMD_REQUIRED_LIBRARIES})
-#ADD_EXECUTABLE(rspamd-http-bench ${UTILBENCHSRC})
-#SET_TARGET_PROPERTIES(rspamd-http-bench PROPERTIES LINKER_LANGUAGE C)
-#TARGET_LINK_LIBRARIES(rspamd-http-bench rspamd-server)
-#TARGET_LINK_LIBRARIES(rspamd-http-bench rspamd-http-parser)
-#TARGET_LINK_LIBRARIES(rspamd-http-bench ${RSPAMD_REQUIRED_LIBRARIES})
+ADD_EXECUTABLE(rspamd-http-bench ${UTILBENCHSRC})
+SET_TARGET_PROPERTIES(rspamd-http-bench PROPERTIES LINKER_LANGUAGE C)
+TARGET_LINK_LIBRARIES(rspamd-http-bench rspamd-server)
+TARGET_LINK_LIBRARIES(rspamd-http-bench rspamd-http-parser)
+TARGET_LINK_LIBRARIES(rspamd-http-bench ${RSPAMD_REQUIRED_LIBRARIES})
# Redirector
IF (ENABLE_REDIRECTOR MATCHES "ON")
diff --git a/utils/rspamd_http_bench.c b/utils/rspamd_http_bench.c
index 72582afea..8007d891b 100644
--- a/utils/rspamd_http_bench.c
+++ b/utils/rspamd_http_bench.c
@@ -131,7 +131,9 @@ rspamd_client_finish (struct rspamd_http_connection *conn,
static void
rspamd_http_client_func (struct event_base *ev_base, struct lat_elt *latency,
guint32 *wconns,
- gpointer peer_key, gpointer client_key, struct rspamd_keypair_cache *c)
+ struct rspamd_cryptobox_pubkey *peer_key,
+ struct rspamd_cryptobox_keypair* client_key,
+ struct rspamd_keypair_cache *c)
{
struct rspamd_http_message *msg;
struct rspamd_http_connection *conn;
@@ -154,7 +156,7 @@ rspamd_http_client_func (struct event_base *ev_base, struct lat_elt *latency,
if (peer_key != NULL) {
g_assert (client_key != NULL);
rspamd_http_connection_set_key (conn, client_key);
- msg->peer_key = rspamd_http_connection_key_ref (peer_key);
+ msg->peer_key = rspamd_pubkey_ref (peer_key);
}
cb = g_malloc (sizeof (*cb));
@@ -174,13 +176,15 @@ rspamd_worker_func (struct lat_elt *plat, guint32 *wconns)
struct event_base *ev_base;
struct itimerval itv;
struct rspamd_keypair_cache *c = NULL;
- gpointer client_key = NULL;
- gpointer peer_key = NULL;
+ struct rspamd_cryptobox_keypair *client_key = NULL;
+ struct rspamd_cryptobox_pubkey *peer_key = NULL;
if (server_key) {
- peer_key = rspamd_http_connection_make_peer_key (server_key);
+ peer_key = rspamd_pubkey_from_base32 (server_key, 0, RSPAMD_KEYPAIR_KEX,
+ openssl_mode ? RSPAMD_CRYPTOBOX_MODE_NIST : RSPAMD_CRYPTOBOX_MODE_25519);
g_assert (peer_key != NULL);
- client_key = rspamd_http_connection_gen_key ();
+ client_key = rspamd_keypair_new (RSPAMD_KEYPAIR_KEX,
+ openssl_mode ? RSPAMD_CRYPTOBOX_MODE_NIST : RSPAMD_CRYPTOBOX_MODE_25519);
if (cache_size > 0) {
c = rspamd_keypair_cache_new (cache_size);
@@ -329,10 +333,6 @@ main (int argc, char **argv)
exit (1);
}
- if (openssl_mode) {
- g_assert (rspamd_cryptobox_openssl_mode (TRUE));
- }
-
rspamd_parse_inet_address (&addr, host, 0);
g_assert (addr != NULL);
rspamd_inet_address_set_port (addr, port);
diff --git a/utils/rspamd_http_server.c b/utils/rspamd_http_server.c
index 40a050584..f861b8a1f 100644
--- a/utils/rspamd_http_server.c
+++ b/utils/rspamd_http_server.c
@@ -19,6 +19,7 @@
#include "http.h"
#include "ottery.h"
#include "cryptobox.h"
+#include "keypair.h"
#include "unix-std.h"
#include <math.h>
@@ -33,7 +34,7 @@ static gboolean openssl_mode = FALSE;
static GHashTable *maps = NULL;
static gchar *key = NULL;
static struct rspamd_keypair_cache *c;
-static gpointer server_key;
+static struct rspamd_cryptobox_keypair *server_key;
static struct timeval io_tv = {
.tv_sec = 20,
.tv_usec = 0
@@ -260,23 +261,15 @@ main (int argc, gchar **argv)
maps = g_hash_table_new (g_int_hash, g_int_equal);
- if (openssl_mode) {
- g_assert (rspamd_cryptobox_openssl_mode (TRUE));
- }
-
if (key == NULL) {
- server_key = rspamd_http_connection_gen_key ();
- b32_key = rspamd_http_connection_print_key (server_key,
+ server_key = rspamd_keypair_new (RSPAMD_KEYPAIR_KEX,
+ openssl_mode ? RSPAMD_CRYPTOBOX_MODE_NIST : RSPAMD_CRYPTOBOX_MODE_25519);
+ b32_key = rspamd_keypair_print (server_key,
RSPAMD_KEYPAIR_PUBKEY | RSPAMD_KEYPAIR_BASE32);
rspamd_printf ("key: %v\n", b32_key);
}
else {
- server_key = rspamd_http_connection_make_key (key, strlen (key));
-
- if (server_key == NULL) {
- rspamd_fprintf (stderr, "cannot load key %s\n", key);
- exit (EXIT_FAILURE);
- }
+ /* TODO: add key loading */
}
if (cache_size > 0) {