]> source.dussan.org Git - rspamd.git/commitdiff
Fix benchmarks
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 6 Feb 2016 13:22:42 +0000 (13:22 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 6 Feb 2016 13:22:42 +0000 (13:22 +0000)
utils/CMakeLists.txt
utils/rspamd_http_bench.c
utils/rspamd_http_server.c

index 762ae2c6a0e5e387f3d4b0dac702ee7272c86801..f9eefb4f0257b1f4f93b028948d12204a013a657 100644 (file)
@@ -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")
index 72582afea3ba33ac4d376120e72ae2556e26273d..8007d891bb9a11cfbc13f33e0a97df30c767afbb 100644 (file)
@@ -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);
index 40a050584c4d5ffbf51355bfc15f563f5159336f..f861b8a1fc4937b3a6d5d1ecd8fb32294a0139ff 100644 (file)
@@ -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) {