summaryrefslogtreecommitdiff
path: root/src/plugins/jabber
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2009-01-30 12:22:10 +0100
committerSebastien Helleu <flashcode@flashtux.org>2009-01-30 12:22:10 +0100
commit228ef56860c4f754576f6d44bd2b5b31195a2c2f (patch)
tree6a4272e90f55dc29060492666145cb3203b3c939 /src/plugins/jabber
parent16c9217d524d95fff21308d9d5b9e761eace5c83 (diff)
downloadweechat-228ef56860c4f754576f6d44bd2b5b31195a2c2f.zip
Fix some bugs with TLS connections in Jabber pluigin (TLS still not working in Jabber)
Diffstat (limited to 'src/plugins/jabber')
-rw-r--r--src/plugins/jabber/jabber-debug.c2
-rw-r--r--src/plugins/jabber/jabber-server.c41
-rw-r--r--src/plugins/jabber/jabber-xmpp.c1
3 files changed, 36 insertions, 8 deletions
diff --git a/src/plugins/jabber/jabber-debug.c b/src/plugins/jabber/jabber-debug.c
index b5914f8a5..82537eead 100644
--- a/src/plugins/jabber/jabber-debug.c
+++ b/src/plugins/jabber/jabber-debug.c
@@ -93,12 +93,12 @@ jabber_debug_printf (struct t_jabber_server *server, int send, int modified,
weechat_printf (jabber_debug_buffer,
"%s%s%s%s%s%s\t%s",
(server) ? weechat_color ("chat_server") : "",
+ (iks_is_secure (server->iks_parser)) ? "[S]" : "",
(server) ? server->name : "",
(server) ? " " : "",
(send) ?
weechat_color ("chat_prefix_quit") :
weechat_color ("chat_prefix_join"),
- (iks_is_secure (server->iks_parser)) ? "* " : "",
(send) ?
((modified) ? JABBER_DEBUG_PREFIX_SEND_MOD : JABBER_DEBUG_PREFIX_SEND) :
((modified) ? JABBER_DEBUG_PREFIX_RECV_MOD : JABBER_DEBUG_PREFIX_RECV),
diff --git a/src/plugins/jabber/jabber-server.c b/src/plugins/jabber/jabber-server.c
index 859ce51dc..40467c57a 100644
--- a/src/plugins/jabber/jabber-server.c
+++ b/src/plugins/jabber/jabber-server.c
@@ -1004,19 +1004,24 @@ jabber_server_iks_transport_recv (void *socket, char *buffer, size_t buf_len,
{
int sock;
fd_set fds;
- struct timeval tv;
+ struct timeval tv, *ptr_tv;
int len;
- /* make C compiler happy */
- (void) timeout;
-
tv.tv_sec = 0;
tv.tv_usec = 0;
sock = (int) socket;
FD_ZERO (&fds);
FD_SET (sock, &fds);
- if (select (sock + 1, &fds, NULL, NULL, &tv) > 0)
+ tv.tv_sec = timeout;
+ ptr_tv = (timeout != -1) ? &tv : NULL;
+
+ /* FIXME: force timeout to 1 second, otherwise WeeChat may freeze when
+ iksemel calls this function with -1 (for TLS connection) */
+ tv.tv_sec = 1;
+ ptr_tv = &tv;
+
+ if (select (sock + 1, &fds, NULL, NULL, ptr_tv) > 0)
{
len = recv (sock, buffer, buf_len, 0);
if (len > 0)
@@ -1578,13 +1583,37 @@ int
jabber_server_recv_cb (void *arg_server)
{
struct t_jabber_server *server;
+ int rc;
server = (struct t_jabber_server *)arg_server;
if (!server)
return WEECHAT_RC_ERROR;
- iks_recv (server->iks_parser, 0);
+ rc = iks_recv (server->iks_parser, 1);
+
+ if (rc == IKS_NET_TLSFAIL)
+ {
+ weechat_printf (server->buffer,
+ _("%s%s: TLS handshake failed"),
+ jabber_buffer_get_server_prefix (server,
+ "error"),
+ JABBER_PLUGIN_NAME);
+ jabber_server_disconnect (server, 0);
+ return WEECHAT_RC_ERROR;
+ }
+
+ if ((rc != IKS_OK) && (rc != IKS_HOOK))
+ {
+ weechat_printf (server->buffer,
+ _("%s%s: I/O error (%d)"),
+ jabber_buffer_get_server_prefix (server,
+ "error"),
+ JABBER_PLUGIN_NAME,
+ rc);
+ jabber_server_disconnect (server, 0);
+ return WEECHAT_RC_ERROR;
+ }
return WEECHAT_RC_OK;
}
diff --git a/src/plugins/jabber/jabber-xmpp.c b/src/plugins/jabber/jabber-xmpp.c
index ffc68452b..e33b8db54 100644
--- a/src/plugins/jabber/jabber-xmpp.c
+++ b/src/plugins/jabber/jabber-xmpp.c
@@ -274,7 +274,6 @@ jabber_xmpp_iks_stream_hook (void *user_data, int type, iks *node)
jabber_buffer_get_server_prefix (server,
"error"),
JABBER_PLUGIN_NAME);
-
jabber_server_disconnect (server, 0);
}
else if (strcmp ("success", iks_name (node)) == 0)