X-Git-Url: https://ruderich.org/simon/gitweb/?p=tlsproxy%2Ftlsproxy.git;a=blobdiff_plain;f=src%2Ftlsproxy.c;h=40729f08c8240938ea24dca75597a96115c2c474;hp=2d2ea1e2cf44f92759a65f58ae33ef0f68e96938;hb=4b64428fe11db22f70c304de1bc9f0cc95f1d189;hpb=19b4321866194060cfc28419d52531a924f1b986 diff --git a/src/tlsproxy.c b/src/tlsproxy.c index 2d2ea1e..40729f0 100644 --- a/src/tlsproxy.c +++ b/src/tlsproxy.c @@ -32,9 +32,11 @@ #include #include +#if GNUTLS_VERSION_NUMBER <= 0x020b00 /* Necessary for GnuTLS when used with threads. */ #include GCRY_THREAD_OPTION_PTHREAD_IMPL; +#endif /* Size of ringbuffer. */ @@ -53,7 +55,7 @@ GCRY_THREAD_OPTION_PTHREAD_IMPL; /* Server should shut down. Set by SIGINT handler. */ -static volatile int done = 0; +static volatile int done; /* = 0 */ /* Number of threads. */ static size_t thread_count; @@ -107,8 +109,8 @@ int main(int argc, char **argv) { return EXIT_FAILURE; } + memset(&action, 0, sizeof(action)); sigemptyset(&action.sa_mask); - action.sa_flags = 0; #ifdef DEBUG /* Setup our SIGINT signal handler which allows a "normal" termination of * the server in DEBUG mode. */ @@ -159,7 +161,7 @@ int main(int argc, char **argv) { } /* Fast rebinding for debug mode, could cause invalid packets. */ - if (global_log_level >= LOG_DEBUG_LEVEL) { + if (global_log_level >= LOG_DEBUG1_LEVEL) { int socket_option = 1; setsockopt(server_socket, SOL_SOCKET, SO_REUSEADDR, &socket_option, sizeof(socket_option)); @@ -187,7 +189,7 @@ int main(int argc, char **argv) { return EXIT_FAILURE; } - if (global_log_level >= LOG_DEBUG_LEVEL) { + if (global_log_level >= LOG_DEBUG1_LEVEL) { printf("tlsproxy %s\n", VERSION); printf("Listening for connections on port %d.\n", port); @@ -364,6 +366,9 @@ static void print_usage(const char *argv) { static void initialize_gnutls(void) { int result; +/* Recent versions of GnuTLS automatically initialize the cryptography layer + * in gnutls_global_init(). */ +#if GNUTLS_VERSION_NUMBER <= 0x020b00 gcry_error_t error; /* Thread safe setup. Must be called before gnutls_global_init(). */ @@ -380,6 +385,7 @@ static void initialize_gnutls(void) { gcry_strerror(error)); exit(EXIT_FAILURE); } +#endif /* Initialize GnuTLS. */ result = gnutls_global_init();