diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2020-04-18 11:33:22 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2020-04-18 11:34:59 +0200 |
commit | e130ee7358564cfd5572ca0cf1ac6871425548ed (patch) | |
tree | a9ea85596b26b17a0710d4625a17a93017a3424d /src/plugins | |
parent | 80693dcea9b645e54d7ad246d28c2cba39da4e30 (diff) | |
download | weechat-e130ee7358564cfd5572ca0cf1ac6871425548ed.zip |
core: make GnuTLS a required dependency
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/irc/CMakeLists.txt | 6 | ||||
-rw-r--r-- | src/plugins/irc/irc-config.c | 7 | ||||
-rw-r--r-- | src/plugins/irc/irc-sasl.c | 8 | ||||
-rw-r--r-- | src/plugins/irc/irc-server.c | 69 | ||||
-rw-r--r-- | src/plugins/irc/irc-server.h | 10 | ||||
-rw-r--r-- | src/plugins/relay/CMakeLists.txt | 6 | ||||
-rw-r--r-- | src/plugins/relay/relay-client.c | 36 | ||||
-rw-r--r-- | src/plugins/relay/relay-client.h | 4 | ||||
-rw-r--r-- | src/plugins/relay/relay-config.c | 23 | ||||
-rw-r--r-- | src/plugins/relay/relay-network.c | 18 | ||||
-rw-r--r-- | src/plugins/relay/relay-network.h | 4 | ||||
-rw-r--r-- | src/plugins/relay/relay-server.h | 3 |
12 files changed, 10 insertions, 184 deletions
diff --git a/src/plugins/irc/CMakeLists.txt b/src/plugins/irc/CMakeLists.txt index 0ce297113..ed572b6bf 100644 --- a/src/plugins/irc/CMakeLists.txt +++ b/src/plugins/irc/CMakeLists.txt @@ -48,10 +48,8 @@ set_target_properties(irc PROPERTIES PREFIX "") set(LINK_LIBS) -if(GNUTLS_FOUND) - include_directories(${GNUTLS_INCLUDE_PATH}) - list(APPEND LINK_LIBS ${GNUTLS_LIBRARY}) -endif() +include_directories(${GNUTLS_INCLUDE_PATH}) +list(APPEND LINK_LIBS ${GNUTLS_LIBRARY}) list(APPEND LINK_LIBS ${GCRYPT_LDFLAGS}) diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c index 184380628..ec6f4b10b 100644 --- a/src/plugins/irc/irc-config.c +++ b/src/plugins/irc/irc-config.c @@ -986,7 +986,6 @@ irc_config_server_default_change_cb (const void *pointer, void *data, const char * irc_config_check_gnutls_priorities (const char *priorities) { -#ifdef HAVE_GNUTLS gnutls_priority_t priority_cache; const char *pos_error; int rc; @@ -1003,12 +1002,6 @@ irc_config_check_gnutls_priorities (const char *priorities) if (pos_error) return pos_error; return priorities; -#else - /* make C compiler happy */ - (void) priorities; - - return NULL; -#endif /* HAVE_GNUTLS */ } /* diff --git a/src/plugins/irc/irc-sasl.c b/src/plugins/irc/irc-sasl.c index 9938d2252..c2ab2e799 100644 --- a/src/plugins/irc/irc-sasl.c +++ b/src/plugins/irc/irc-sasl.c @@ -26,12 +26,10 @@ #include <arpa/inet.h> #include <gcrypt.h> -#ifdef HAVE_GNUTLS #include <gnutls/gnutls.h> #if LIBGNUTLS_VERSION_NUMBER >= 0x020a01 /* 2.10.1 */ #include <gnutls/abstract.h> #endif /* LIBGNUTLS_VERSION_NUMBER >= 0x020a01 */ -#endif /* HAVE_GNUTLS */ #include "../weechat-plugin.h" #include "irc.h" @@ -144,7 +142,7 @@ irc_sasl_mechanism_ecdsa_nist256p_challenge (struct t_irc_server *server, const char *sasl_username, const char *sasl_key) { -#if defined(HAVE_GNUTLS) && (LIBGNUTLS_VERSION_NUMBER >= 0x030015) /* 3.0.21 */ +#if LIBGNUTLS_VERSION_NUMBER >= 0x030015 /* 3.0.21 */ char *data, *string, *answer_base64; int length_data, length_username, length, ret; char *str_privkey; @@ -316,7 +314,7 @@ irc_sasl_mechanism_ecdsa_nist256p_challenge (struct t_irc_server *server, return answer_base64; -#else /* no gnutls or gnutls < 3.0.21 */ +#else /* GnuTLS < 3.0.21 */ /* make C compiler happy */ (void) data_base64; @@ -329,7 +327,7 @@ irc_sasl_mechanism_ecdsa_nist256p_challenge (struct t_irc_server *server, weechat_prefix ("error")); return NULL; -#endif /* defined(HAVE_GNUTLS) && (LIBGNUTLS_VERSION_NUMBER >= 0x030015) */ +#endif /* LIBGNUTLS_VERSION_NUMBER >= 0x030015 */ } /* diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c index 34b3da566..6e9149a05 100644 --- a/src/plugins/irc/irc-server.c +++ b/src/plugins/irc/irc-server.c @@ -44,10 +44,8 @@ #include <arpa/nameser.h> #include <resolv.h> -#ifdef HAVE_GNUTLS #include <gnutls/gnutls.h> #include <gnutls/x509.h> -#endif /* HAVE_GNUTLS */ #include "../weechat-plugin.h" #include "irc.h" @@ -133,14 +131,12 @@ char *irc_server_chanmodes_default = "beI,k,l"; const char *irc_server_send_default_tags = NULL; /* default tags when */ /* sending a message */ -#ifdef HAVE_GNUTLS gnutls_digest_algorithm_t irc_fingerprint_digest_algos[IRC_FINGERPRINT_NUM_ALGOS] = { GNUTLS_DIG_SHA1, GNUTLS_DIG_SHA256, GNUTLS_DIG_SHA512 }; char *irc_fingerprint_digest_algos_name[IRC_FINGERPRINT_NUM_ALGOS] = { "SHA-1", "SHA-256", "SHA-512" }; int irc_fingerprint_digest_algos_size[IRC_FINGERPRINT_NUM_ALGOS] = { 160, 256, 512 }; -#endif /* HAVE_GNUTLS */ void irc_server_reconnect (struct t_irc_server *server); @@ -398,7 +394,6 @@ irc_server_eval_expression (struct t_irc_server *server, const char *string) char * irc_server_eval_fingerprint (struct t_irc_server *server) { -#ifdef HAVE_GNUTLS const char *ptr_fingerprint; char *fingerprint_eval, **fingerprints, *str_sizes; int i, j, rc, algo, length; @@ -485,12 +480,6 @@ irc_server_eval_fingerprint (struct t_irc_server *server) return NULL; } return fingerprint_eval; -#else - /* make C compiler happy */ - (void) server; - - return strdup (""); -#endif /* HAVE_GNUTLS */ } /* @@ -2311,16 +2300,13 @@ irc_server_send (struct t_irc_server *server, const char *buffer, int size_buf) return 0; } -#ifdef HAVE_GNUTLS if (server->ssl_connected) rc = gnutls_record_send (server->gnutls_sess, buffer, size_buf); else -#endif /* HAVE_GNUTLS */ rc = send (server->sock, buffer, size_buf, 0); if (rc < 0) { -#ifdef HAVE_GNUTLS if (server->ssl_connected) { weechat_printf ( @@ -2330,7 +2316,6 @@ irc_server_send (struct t_irc_server *server, const char *buffer, int size_buf) rc, gnutls_strerror (rc)); } else -#endif /* HAVE_GNUTLS */ { weechat_printf ( server->buffer, @@ -3233,12 +3218,10 @@ irc_server_recv_cb (const void *pointer, void *data, int fd) { end_recv = 1; -#ifdef HAVE_GNUTLS if (server->ssl_connected) num_read = gnutls_record_recv (server->gnutls_sess, buffer, sizeof (buffer) - 2); else -#endif /* HAVE_GNUTLS */ num_read = recv (server->sock, buffer, sizeof (buffer) - 2, 0); if (num_read > 0) @@ -3246,7 +3229,6 @@ irc_server_recv_cb (const void *pointer, void *data, int fd) buffer[num_read] = '\0'; irc_server_msgq_add_buffer (server, buffer); msgq_flush = 1; /* the flush will be done after the loop */ -#ifdef HAVE_GNUTLS if (server->ssl_connected && (gnutls_record_check_pending (server->gnutls_sess) > 0)) { @@ -3256,11 +3238,9 @@ irc_server_recv_cb (const void *pointer, void *data, int fd) */ end_recv = 0; } -#endif /* HAVE_GNUTLS */ } else { -#ifdef HAVE_GNUTLS if (server->ssl_connected) { if ((num_read == 0) @@ -3282,7 +3262,6 @@ irc_server_recv_cb (const void *pointer, void *data, int fd) } } else -#endif /* HAVE_GNUTLS */ { if ((num_read == 0) || ((errno != EAGAIN) && (errno != EWOULDBLOCK))) @@ -3663,7 +3642,6 @@ irc_server_close_connection (struct t_irc_server *server) } else { -#ifdef HAVE_GNUTLS /* close SSL connection */ if (server->ssl_connected) { @@ -3671,7 +3649,6 @@ irc_server_close_connection (struct t_irc_server *server) gnutls_bye (server->gnutls_sess, GNUTLS_SHUT_WR); gnutls_deinit (server->gnutls_sess); } -#endif /* HAVE_GNUTLS */ } if (server->sock != -1) { @@ -4049,7 +4026,6 @@ irc_server_connect_cb (const void *pointer, void *data, _("%s%s: error: %s"), weechat_prefix ("error"), IRC_PLUGIN_NAME, error); } -#ifdef HAVE_GNUTLS if (gnutls_rc == GNUTLS_E_DH_PRIME_UNACCEPTABLE) { weechat_printf ( @@ -4067,9 +4043,6 @@ irc_server_connect_cb (const void *pointer, void *data, IRC_SERVER_OPTION_INTEGER ( server, IRC_SERVER_OPTION_SSL_DHKEY_SIZE) / 4); } -#else - (void) gnutls_rc; -#endif /* HAVE_GNUTLS */ irc_server_close_connection (server); server->current_retry++; irc_server_switch_address (server, 1); @@ -4250,7 +4223,6 @@ irc_server_create_buffer (struct t_irc_server *server) * -1 if not found. */ -#ifdef HAVE_GNUTLS int irc_server_fingerprint_search_algo_with_size (int size) { @@ -4265,7 +4237,6 @@ irc_server_fingerprint_search_algo_with_size (int size) /* digest algorithm not found */ return -1; } -#endif /* HAVE_GNUTLS */ /* * Returns a string with sizes of allowed fingerprint, @@ -4276,7 +4247,6 @@ irc_server_fingerprint_search_algo_with_size (int size) * Note: result must be freed after use. */ -#ifdef HAVE_GNUTLS char * irc_server_fingerprint_str_sizes () { @@ -4297,7 +4267,6 @@ irc_server_fingerprint_str_sizes () return strdup (str_sizes); } -#endif /* HAVE_GNUTLS */ /* * Compares two fingerprints: one hexadecimal (given by user), the second binary @@ -4308,7 +4277,6 @@ irc_server_fingerprint_str_sizes () * -1: fingerprints are different */ -#ifdef HAVE_GNUTLS int irc_server_compare_fingerprints (const char *fingerprint, const unsigned char *fingerprint_server, @@ -4331,7 +4299,6 @@ irc_server_compare_fingerprints (const char *fingerprint, /* fingerprints are the same */ return 0; } -#endif /* HAVE_GNUTLS */ /* * Checks if a GnuTLS session uses the certificate with a given fingerprint. @@ -4341,7 +4308,6 @@ irc_server_compare_fingerprints (const char *fingerprint, * 0: certificate does NOT have the good fingerprint */ -#ifdef HAVE_GNUTLS int irc_server_check_certificate_fingerprint (struct t_irc_server *server, gnutls_x509_crt_t certificate, @@ -4432,7 +4398,6 @@ irc_server_check_certificate_fingerprint (struct t_irc_server *server, return rc; } -#endif /* HAVE_GNUTLS */ /* * GnuTLS callback called during handshake. @@ -4442,7 +4407,6 @@ irc_server_check_certificate_fingerprint (struct t_irc_server *server, * -1: error in certificate */ -#ifdef HAVE_GNUTLS int irc_server_gnutls_callback (const void *pointer, void *data, gnutls_session_t tls_session, @@ -4859,7 +4823,6 @@ end: return rc; } -#endif /* HAVE_GNUTLS */ /* * Connects to a server. @@ -4980,17 +4943,6 @@ irc_server_connect (struct t_irc_server *server) return 0; } -#ifndef HAVE_GNUTLS - if (IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_SSL)) - { - weechat_printf ( - server->buffer, - _("%s%s: cannot connect with SSL because WeeChat was not built " - "with GnuTLS support"), - weechat_prefix ("error"), IRC_PLUGIN_NAME); - return 0; - } -#endif /* HAVE_GNUTLS */ if (proxy_type) { weechat_printf ( @@ -5050,7 +5002,6 @@ irc_server_connect (struct t_irc_server *server) /* init SSL if asked and connect */ server->ssl_connected = 0; -#ifdef HAVE_GNUTLS if (IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_SSL)) server->ssl_connected = 1; if (!server->fake_server) @@ -5070,22 +5021,6 @@ irc_server_connect (struct t_irc_server *server) server, NULL); } -#else - if (!server->fake_server) - { - server->hook_connect = weechat_hook_connect ( - proxy, - server->current_address, - server->current_port, - proxy_type ? weechat_config_integer (proxy_ipv6) : IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_IPV6), - server->current_retry, - NULL, NULL, 0, NULL, - IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_LOCAL_HOSTNAME), - &irc_server_connect_cb, - server, - NULL); - } -#endif /* HAVE_GNUTLS */ /* send signal "irc_server_connecting" with server name */ (void) weechat_hook_signal_send ("irc_server_connecting", @@ -5786,11 +5721,9 @@ irc_server_hdata_server_cb (const void *pointer, void *data, WEECHAT_HDATA_VAR(struct t_irc_server, is_connected, INTEGER, 0, NULL, NULL); WEECHAT_HDATA_VAR(struct t_irc_server, ssl_connected, INTEGER, 0, NULL, NULL); WEECHAT_HDATA_VAR(struct t_irc_server, disconnected, INTEGER, 0, NULL, NULL); -#ifdef HAVE_GNUTLS WEECHAT_HDATA_VAR(struct t_irc_server, gnutls_sess, OTHER, 0, NULL, NULL); WEECHAT_HDATA_VAR(struct t_irc_server, tls_cert, OTHER, 0, NULL, NULL); WEECHAT_HDATA_VAR(struct t_irc_server, tls_cert_key, OTHER, 0, NULL, NULL); -#endif /* HAVE_GNUTLS */ WEECHAT_HDATA_VAR(struct t_irc_server, unterminated_message, STRING, 0, NULL, NULL); WEECHAT_HDATA_VAR(struct t_irc_server, nicks_count, INTEGER, 0, NULL, NULL); WEECHAT_HDATA_VAR(struct t_irc_server, nicks_array, STRING, 0, "nicks_count", NULL); @@ -6419,9 +6352,7 @@ irc_server_print_log () weechat_log_printf (" is_connected . . . . : %d", ptr_server->is_connected); weechat_log_printf (" ssl_connected. . . . : %d", ptr_server->ssl_connected); weechat_log_printf (" disconnected . . . . : %d", ptr_server->disconnected); -#ifdef HAVE_GNUTLS weechat_log_printf (" gnutls_sess. . . . . : 0x%lx", ptr_server->gnutls_sess); -#endif /* HAVE_GNUTLS */ weechat_log_printf (" unterminated_message : '%s'", ptr_server->unterminated_message); weechat_log_printf (" nicks_count. . . . . : %d", ptr_server->nicks_count); weechat_log_printf (" nicks_array. . . . . : 0x%lx", ptr_server->nicks_array); diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h index 09d16fe8b..2d57bf1c2 100644 --- a/src/plugins/irc/irc-server.h +++ b/src/plugins/irc/irc-server.h @@ -25,9 +25,7 @@ #include <sys/time.h> #include <regex.h> -#ifdef HAVE_GNUTLS #include <gnutls/gnutls.h> -#endif /* HAVE_GNUTLS */ #ifndef NI_MAXHOST #define NI_MAXHOST 256 @@ -188,11 +186,9 @@ struct t_irc_server int is_connected; /* 1 if WeeChat is connected to server */ int ssl_connected; /* = 1 if connected with SSL */ int disconnected; /* 1 if server has been disconnected */ -#ifdef HAVE_GNUTLS gnutls_session_t gnutls_sess; /* gnutls session (only if SSL is used) */ gnutls_x509_crt_t tls_cert; /* certificate used if ssl_cert is set */ gnutls_x509_privkey_t tls_cert_key; /* key used if ssl_cert is set */ -#endif /* HAVE_GNUTLS */ char *unterminated_message; /* beginning of a message in input buf */ int nicks_count; /* number of nicknames */ char **nicks_array; /* nicknames (after split) */ @@ -267,7 +263,6 @@ struct t_irc_message /* digest algorithms for fingerprint */ -#ifdef HAVE_GNUTLS enum t_irc_fingerprint_digest_algo { IRC_FINGERPRINT_ALGO_SHA1 = 0, @@ -276,13 +271,10 @@ enum t_irc_fingerprint_digest_algo /* number of digest algorithms */ IRC_FINGERPRINT_NUM_ALGOS, }; -#endif /* HAVE_GNUTLS */ extern struct t_irc_server *irc_servers; -#ifdef HAVE_GNUTLS extern const int gnutls_cert_type_prio[]; extern const int gnutls_prot_prio[]; -#endif /* HAVE_GNUTLS */ extern struct t_irc_message *irc_recv_msgq, *irc_msgq_last_msg; extern char *irc_server_sasl_fail_string[]; extern char *irc_server_options[][2]; @@ -355,10 +347,8 @@ extern void irc_server_msgq_add_buffer (struct t_irc_server *server, extern void irc_server_msgq_flush (); extern void irc_server_set_buffer_title (struct t_irc_server *server); extern struct t_gui_buffer *irc_server_create_buffer (struct t_irc_server *server); -#ifdef HAVE_GNUTLS int irc_server_fingerprint_search_algo_with_size (int size); char *irc_server_fingerprint_str_sizes (); -#endif /* HAVE_GNUTLS */ extern int irc_server_connect (struct t_irc_server *server); extern void irc_server_auto_connect (int auto_connect); extern void irc_server_autojoin_channels (struct t_irc_server *server); diff --git a/src/plugins/relay/CMakeLists.txt b/src/plugins/relay/CMakeLists.txt index a86b32d5e..933f3abc7 100644 --- a/src/plugins/relay/CMakeLists.txt +++ b/src/plugins/relay/CMakeLists.txt @@ -45,10 +45,8 @@ set(LINK_LIBS) list(APPEND LINK_LIBS ${ZLIB_LIBRARY}) -if(GNUTLS_FOUND) - include_directories(${GNUTLS_INCLUDE_PATH}) - list(APPEND LINK_LIBS ${GNUTLS_LIBRARY}) -endif() +include_directories(${GNUTLS_INCLUDE_PATH}) +list(APPEND LINK_LIBS ${GNUTLS_LIBRARY}) list(APPEND LINK_LIBS ${GCRYPT_LDFLAGS}) diff --git a/src/plugins/relay/relay-client.c b/src/plugins/relay/relay-client.c index f5354f8c9..65ee42e4d 100644 --- a/src/plugins/relay/relay-client.c +++ b/src/plugins/relay/relay-client.c @@ -29,9 +29,7 @@ #include <sys/types.h> #include <sys/socket.h> -#ifdef HAVE_GNUTLS #include <gnutls/gnutls.h> -#endif #include "../weechat-plugin.h" #include "relay.h" @@ -233,7 +231,6 @@ relay_client_set_desc (struct t_relay_client *client) * Timer callback for handshake with client (for SSL connection only). */ -#ifdef HAVE_GNUTLS int relay_client_handshake_timer_cb (const void *pointer, void *data, int remaining_calls) @@ -311,7 +308,6 @@ relay_client_handshake_timer_cb (const void *pointer, void *data, /* handshake in progress, we will try again on next call to timer */ return WEECHAT_RC_OK; } -#endif /* HAVE_GNUTLS */ /* * Reads text data from a client: splits data on '\n' and keeps a partial @@ -602,12 +598,10 @@ relay_client_recv_cb (const void *pointer, void *data, int fd) return WEECHAT_RC_OK; } -#ifdef HAVE_GNUTLS if (client->ssl) num_read = gnutls_record_recv (client->gnutls_sess, buffer, sizeof (buffer) - 1); else -#endif /* HAVE_GNUTLS */ num_read = recv (client->sock, buffer, sizeof (buffer) - 1, 0); if (num_read > 0) @@ -693,7 +687,6 @@ relay_client_recv_cb (const void *pointer, void *data, int fd) } else { -#ifdef HAVE_GNUTLS if (client->ssl) { if ((num_read == 0) @@ -714,7 +707,6 @@ relay_client_recv_cb (const void *pointer, void *data, int fd) } } else -#endif /* HAVE_GNUTLS */ { if ((num_read == 0) || ((errno != EAGAIN) && (errno != EWOULDBLOCK))) @@ -972,11 +964,9 @@ relay_client_send (struct t_relay_client *client, } else { -#ifdef HAVE_GNUTLS if (client->ssl) num_sent = gnutls_record_send (client->gnutls_sess, ptr_data, data_size); else -#endif /* HAVE_GNUTLS */ num_sent = send (client->sock, ptr_data, data_size, 0); if (num_sent >= 0) @@ -1005,7 +995,6 @@ relay_client_send (struct t_relay_client *client, } else { -#ifdef HAVE_GNUTLS if (client->ssl) { if ((num_sent == GNUTLS_E_AGAIN) @@ -1033,7 +1022,6 @@ relay_client_send (struct t_relay_client *client, } } else -#endif /* HAVE_GNUTLS */ { if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) { @@ -1078,7 +1066,6 @@ relay_client_send_outqueue (struct t_relay_client *client) while (client->outqueue) { -#ifdef HAVE_GNUTLS if (client->ssl) { num_sent = gnutls_record_send (client->gnutls_sess, @@ -1086,7 +1073,6 @@ relay_client_send_outqueue (struct t_relay_client *client) client->outqueue->data_size); } else -#endif /* HAVE_GNUTLS */ { num_sent = send (client->sock, client->outqueue->data, @@ -1149,7 +1135,6 @@ relay_client_send_outqueue (struct t_relay_client *client) } else { -#ifdef HAVE_GNUTLS if (client->ssl) { if ((num_sent == GNUTLS_E_AGAIN) @@ -1175,7 +1160,6 @@ relay_client_send_outqueue (struct t_relay_client *client) } } else -#endif /* HAVE_GNUTLS */ { if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) { @@ -1271,10 +1255,8 @@ relay_client_new (int sock, const char *address, struct t_relay_server *server) { struct t_relay_client *new_client; int plain_text_password; -#ifdef HAVE_GNUTLS int bits; struct t_config_option *ptr_option; -#endif /* HAVE_GNUTLS */ new_client = malloc (sizeof (*new_client)); if (new_client) @@ -1284,10 +1266,8 @@ relay_client_new (int sock, const char *address, struct t_relay_server *server) new_client->sock = sock; new_client->server_port = server->port; new_client->ssl = server->ssl; -#ifdef HAVE_GNUTLS new_client->hook_timer_handshake = NULL; new_client->gnutls_handshake_ok = 0; -#endif /* HAVE_GNUTLS */ new_client->websocket = 0; new_client->http_headers = NULL; new_client->address = strdup ((address && address[0]) ? @@ -1331,7 +1311,6 @@ relay_client_new (int sock, const char *address, struct t_relay_server *server) relay_client_set_desc (new_client); -#ifdef HAVE_GNUTLS if (new_client->ssl) { if (!relay_network_init_ssl_cert_key_ok) @@ -1382,7 +1361,6 @@ relay_client_new (int sock, const char *address, struct t_relay_server *server) new_client, NULL); } -#endif /* HAVE_GNUTLS */ new_client->protocol_data = NULL; switch (new_client->protocol) @@ -1490,11 +1468,9 @@ relay_client_new_with_infolist (struct t_infolist *infolist) new_client->sock = weechat_infolist_integer (infolist, "sock"); new_client->server_port = weechat_infolist_integer (infolist, "server_port"); new_client->ssl = weechat_infolist_integer (infolist, "ssl"); -#ifdef HAVE_GNUTLS new_client->gnutls_sess = NULL; new_client->hook_timer_handshake = NULL; new_client->gnutls_handshake_ok = 0; -#endif /* HAVE_GNUTLS */ new_client->websocket = weechat_infolist_integer (infolist, "websocket"); new_client->http_headers = NULL; new_client->address = strdup (weechat_infolist_string (infolist, "address")); @@ -1614,14 +1590,12 @@ relay_client_set_status (struct t_relay_client *client, relay_client_outqueue_free_all (client); -#ifdef HAVE_GNUTLS if (client->hook_timer_handshake) { weechat_unhook (client->hook_timer_handshake); client->hook_timer_handshake = NULL; } client->gnutls_handshake_ok = 0; -#endif /* HAVE_GNUTLS */ if (client->hook_fd) { weechat_unhook (client->hook_fd); @@ -1665,16 +1639,12 @@ relay_client_set_status (struct t_relay_client *client, if (client->sock >= 0) { -#ifdef HAVE_GNUTLS if (client->ssl && client->gnutls_handshake_ok) gnutls_bye (client->gnutls_sess, GNUTLS_SHUT_WR); -#endif /* HAVE_GNUTLS */ close (client->sock); client->sock = -1; -#ifdef HAVE_GNUTLS if (client->ssl) gnutls_deinit (client->gnutls_sess); -#endif /* HAVE_GNUTLS */ } } @@ -1721,10 +1691,8 @@ relay_client_free (struct t_relay_client *client) free (client->protocol_args); if (client->nonce) free (client->nonce); -#ifdef HAVE_GNUTLS if (client->hook_timer_handshake) weechat_unhook (client->hook_timer_handshake); -#endif /* HAVE_GNUTLS */ if (client->http_headers) weechat_hashtable_free (client->http_headers); if (client->hook_fd) @@ -1833,12 +1801,10 @@ relay_client_add_to_infolist (struct t_infolist *infolist, return 0; if (!weechat_infolist_new_var_integer (ptr_item, "ssl", client->ssl)) return 0; -#ifdef HAVE_GNUTLS if (!weechat_infolist_new_var_pointer (ptr_item, "hook_timer_handshake", client->hook_timer_handshake)) return 0; if (!weechat_infolist_new_var_integer (ptr_item, "gnutls_handshake_ok", client->gnutls_handshake_ok)) return 0; -#endif /* HAVE_GNUTLS */ if (!weechat_infolist_new_var_integer (ptr_item, "websocket", client->websocket)) return 0; if (!weechat_infolist_new_var_string (ptr_item, "address", client->address)) @@ -1920,11 +1886,9 @@ relay_client_print_log () weechat_log_printf (" sock. . . . . . . . . . . : %d", ptr_client->sock); weechat_log_printf (" server_port . . . . . . . : %d", ptr_client->server_port); weechat_log_printf (" ssl . . . . . . . . . . . : %d", ptr_client->ssl); -#ifdef HAVE_GNUTLS weechat_log_printf (" gnutls_sess . . . . . . . : 0x%lx", ptr_client->gnutls_sess); weechat_log_printf (" hook_timer_handshake. . . : 0x%lx", ptr_client->hook_timer_handshake); weechat_log_printf (" gnutls_handshake_ok . . . : 0x%lx", ptr_client->gnutls_handshake_ok); -#endif /* HAVE_GNUTLS */ weechat_log_printf (" websocket . . . . . . . . : %d", ptr_client->websocket); weechat_log_printf (" http_headers. . . . . . . : 0x%lx (hashtable: '%s')", ptr_client->http_headers, diff --git a/src/plugins/relay/relay-client.h b/src/plugins/relay/relay-client.h index 952055740..9ebecbc6f 100644 --- a/src/plugins/relay/relay-client.h +++ b/src/plugins/relay/relay-client.h @@ -22,9 +22,7 @@ #include <time.h> -#ifdef HAVE_GNUTLS #include <gnutls/gnutls.h> -#endif /* HAVE_GNUTLS */ struct t_relay_server; @@ -92,11 +90,9 @@ struct t_relay_client int sock; /* socket for connection */ int server_port; /* port used for connection */ int ssl; /* 1 if SSL is enabled */ -#ifdef HAVE_GNUTLS gnutls_session_t gnutls_sess; /* gnutls session (only if SSL used) */ struct t_hook *hook_timer_handshake; /* timer for doing gnutls handshake*/ int gnutls_handshake_ok; /* 1 if handshake was done and OK */ -#endif /* HAVE_GNUTLS */ int websocket; /* 0=not a ws, 1=init ws, 2=ws ready */ struct t_hashtable *http_headers; /* HTTP headers for websocket */ char *address; /* string with IP address */ diff --git a/src/plugins/relay/relay-config.c b/src/plugins/relay/relay-config.c index f1d475cf5..b455fcf47 100644 --- a/src/plugins/relay/relay-config.c +++ b/src/plugins/relay/relay-config.c @@ -318,7 +318,6 @@ relay_config_check_network_ssl_priorities (const void *pointer, void *data, struct t_config_option *option, const char *value) { -#ifdef HAVE_GNUTLS gnutls_priority_t priority_cache; const char *pos_error; int rc; @@ -347,15 +346,6 @@ relay_config_check_network_ssl_priorities (const void *pointer, void *data, (pos_error) ? pos_error : value); return 0; -#else - /* make C compiler happy */ - (void) pointer; - (void) data; - (void) option; - (void) value; - - return 1; -#endif /* HAVE_GNUTLS */ } /* @@ -371,13 +361,11 @@ relay_config_change_network_ssl_priorities (const void *pointer, void *data, (void) data; (void) option; -#ifdef HAVE_GNUTLS if (relay_network_init_ok && relay_gnutls_priority_cache) { gnutls_priority_deinit (*relay_gnutls_priority_cache); relay_network_set_priority (); } -#endif /* HAVE_GNUTLS */ } /* @@ -762,17 +750,6 @@ relay_config_create_option_port_path (const void *pointer, void *data, relay_server_get_protocol_args (option_name, &ipv4, &ipv6, &ssl, &unix_socket, &protocol, &protocol_args); -#ifndef HAVE_GNUTLS - if (ssl) - { - weechat_printf (NULL, - _("%s%s: cannot use SSL because WeeChat was not built " - "with GnuTLS support"), - weechat_prefix ("error"), RELAY_PLUGIN_NAME); - rc = WEECHAT_CONFIG_OPTION_SET_ERROR; - } -#endif /* HAVE_GNUTLS */ - if (rc != WEECHAT_CONFIG_OPTION_SET_ERROR) { if (protocol) diff --git a/src/plugins/relay/relay-network.c b/src/plugins/relay/relay-network.c index f702be7e2..bb2fee165 100644 --- a/src/plugins/relay/relay-network.c +++ b/src/plugins/relay/relay-network.c @@ -21,9 +21,7 @@ #include <stdlib.h> -#ifdef HAVE_GNUTLS #include <gnutls/gnutls.h> -#endif /* HAVE_GNUTLS */ #include "../weechat-plugin.h" #include "relay.h" @@ -34,11 +32,9 @@ int relay_network_init_ok = 0; int relay_network_init_ssl_cert_key_ok = 0; -#ifdef HAVE_GNUTLS gnutls_certificate_credentials_t relay_gnutls_x509_cred; gnutls_priority_t *relay_gnutls_priority_cache = NULL; gnutls_dh_params_t *relay_gnutls_dh_params = NULL; -#endif /* HAVE_GNUTLS */ /* @@ -51,7 +47,6 @@ gnutls_dh_params_t *relay_gnutls_dh_params = NULL; void relay_network_set_ssl_cert_key (int verbose) { -#ifdef HAVE_GNUTLS char *certkey_path, *certkey_path2, *weechat_dir; int ret; @@ -99,10 +94,6 @@ relay_network_set_ssl_cert_key (int verbose) } free (certkey_path); } -#else - /* make C compiler happy */ - (void) verbose; -#endif /* HAVE_GNUTLS */ } /* @@ -112,7 +103,6 @@ relay_network_set_ssl_cert_key (int verbose) void relay_network_set_priority () { -#ifdef HAVE_GNUTLS if (gnutls_priority_init (relay_gnutls_priority_cache, weechat_config_string ( relay_config_network_ssl_priorities), @@ -124,7 +114,6 @@ relay_network_set_priority () free (relay_gnutls_priority_cache); relay_gnutls_priority_cache = NULL; } -#endif /* HAVE_GNUTLS */ } /* @@ -134,8 +123,6 @@ relay_network_set_priority () void relay_network_init () { -#ifdef HAVE_GNUTLS - /* credentials */ gnutls_certificate_allocate_credentials (&relay_gnutls_x509_cred); relay_network_set_ssl_cert_key (0); @@ -144,7 +131,7 @@ relay_network_init () relay_gnutls_priority_cache = malloc (sizeof (*relay_gnutls_priority_cache)); if (relay_gnutls_priority_cache) relay_network_set_priority (); -#endif /* HAVE_GNUTLS */ + relay_network_init_ok = 1; } @@ -157,7 +144,6 @@ relay_network_end () { if (relay_network_init_ok) { -#ifdef HAVE_GNUTLS if (relay_gnutls_priority_cache) { gnutls_priority_deinit (*relay_gnutls_priority_cache); @@ -171,7 +157,7 @@ relay_network_end () relay_gnutls_dh_params = NULL; } gnutls_certificate_free_credentials (relay_gnutls_x509_cred); -#endif /* HAVE_GNUTLS */ + relay_network_init_ok = 0; } } diff --git a/src/plugins/relay/relay-network.h b/src/plugins/relay/relay-network.h index fa25bc172..02637d10c 100644 --- a/src/plugins/relay/relay-network.h +++ b/src/plugins/relay/relay-network.h @@ -20,18 +20,14 @@ #ifndef WEECHAT_PLUGIN_RELAY_NETWORK_H #define WEECHAT_PLUGIN_RELAY_NETWORK_H -#ifdef HAVE_GNUTLS #include <gnutls/gnutls.h> -#endif /* HAVE_GNUTLS */ extern int relay_network_init_ok; extern int relay_network_init_ssl_cert_key_ok; -#ifdef HAVE_GNUTLS extern gnutls_certificate_credentials_t relay_gnutls_x509_cred; extern gnutls_priority_t *relay_gnutls_priority_cache; extern gnutls_dh_params_t *relay_gnutls_dh_params; -#endif /* HAVE_GNUTLS */ extern void relay_network_set_ssl_cert_key (int verbose); extern void relay_network_set_priority (); diff --git a/src/plugins/relay/relay-server.h b/src/plugins/relay/relay-server.h index fd82659bb..3fa47bd55 100644 --- a/src/plugins/relay/relay-server.h +++ b/src/plugins/relay/relay-server.h @@ -21,9 +21,8 @@ #define WEECHAT_PLUGIN_RELAY_SERVER_H #include <time.h> -#ifdef HAVE_GNUTLS + #define RELAY_SERVER_GNUTLS_DH_BITS 1024 -#endif /* HAVE_GNUTLS */ struct t_relay_server { |