summaryrefslogtreecommitdiff
path: root/src/plugins/relay/relay.c
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2012-07-27 17:54:08 +0200
committerSebastien Helleu <flashcode@flashtux.org>2012-07-27 17:54:08 +0200
commit782e01f17798478322f7634c43d35653e92c2b2a (patch)
tree9babde108b57ca7a5b1014e4b5e2f357805ab8a4 /src/plugins/relay/relay.c
parent32b8f345673f5eb736a27090e98de808f6e7fda2 (diff)
downloadweechat-782e01f17798478322f7634c43d35653e92c2b2a.zip
relay: add support of SSL (for irc and weechat protocols), new option relay.network.ssl_cert_key (task #12044)
Diffstat (limited to 'src/plugins/relay/relay.c')
-rw-r--r--src/plugins/relay/relay.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/plugins/relay/relay.c b/src/plugins/relay/relay.c
index 92b010dd3..5e392e31f 100644
--- a/src/plugins/relay/relay.c
+++ b/src/plugins/relay/relay.c
@@ -31,6 +31,7 @@
#include "relay-completion.h"
#include "relay-config.h"
#include "relay-info.h"
+#include "relay-network.h"
#include "relay-raw.h"
#include "relay-server.h"
#include "relay-upgrade.h"
@@ -81,6 +82,8 @@ relay_signal_upgrade_cb (void *data, const char *signal, const char *type_data,
void *signal_data)
{
struct t_relay_server *ptr_server;
+ struct t_relay_client *ptr_client;
+ int disconnected;
/* make C compiler happy */
(void) data;
@@ -90,12 +93,47 @@ relay_signal_upgrade_cb (void *data, const char *signal, const char *type_data,
relay_signal_upgrade_received = 1;
+ /* close socket for relay servers */
for (ptr_server = relay_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
relay_server_close_socket (ptr_server);
}
+ /*
+ * FIXME: it's not possible to upgrade with SSL clients connected (GnuTLS
+ * lib can't reload data after upgrade), so we close connection for
+ * all SSL clients currently connected
+ */
+ disconnected = 0;
+ for (ptr_client = relay_clients; ptr_client;
+ ptr_client = ptr_client->next_client)
+ {
+ if ((ptr_client->sock >= 0) && ptr_client->ssl)
+ {
+ disconnected++;
+ weechat_printf (NULL,
+ _("%s%s: disconnecting from client %s%s%s because "
+ "upgrade can't work for clients connected via SSL"),
+ weechat_prefix ("error"),
+ RELAY_PLUGIN_NAME,
+ RELAY_COLOR_CHAT_CLIENT,
+ ptr_client->desc,
+ RELAY_COLOR_CHAT);
+ relay_client_set_status (ptr_client, RELAY_STATUS_DISCONNECTED);
+ }
+ }
+ if (disconnected > 0)
+ {
+ weechat_printf (NULL,
+ /* TRANSLATORS: "%s" after "%d" is "client" or "clients" */
+ _("%s%s: disconnected from %d %s (SSL connection "
+ "not supported with upgrade)"),
+ weechat_prefix ("error"), RELAY_PLUGIN_NAME,
+ disconnected,
+ NG_("client", "clients", disconnected));
+ }
+
return WEECHAT_RC_OK;
}
@@ -151,6 +189,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
if (relay_config_read () < 0)
return WEECHAT_RC_ERROR;
+ relay_network_init ();
+
relay_command_init ();
/* hook completions */
@@ -211,5 +251,7 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
relay_client_free_all ();
}
+ relay_network_end ();
+
return WEECHAT_RC_OK;
}