diff options
Diffstat (limited to 'protocols/jabber/io.c')
-rw-r--r-- | protocols/jabber/io.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/protocols/jabber/io.c b/protocols/jabber/io.c index 5b9149af..6f79b2d1 100644 --- a/protocols/jabber/io.c +++ b/protocols/jabber/io.c @@ -3,7 +3,7 @@ * BitlBee - An IRC to IM gateway * * Jabber module - I/O stuff (plain, SSL), queues, etc * * * -* Copyright 2006 Wilmer van der Gaast <wilmer@gaast.net> * +* Copyright 2006-2012 Wilmer van der Gaast <wilmer@gaast.net> * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -452,8 +452,39 @@ static xt_status jabber_pkt_proceed_tls( struct xt_node *node, gpointer data ) static xt_status jabber_pkt_stream_error( struct xt_node *node, gpointer data ) { struct im_connection *ic = data; + struct jabber_data *jd = ic->proto_data; int allow_reconnect = TRUE; struct jabber_error *err; + struct xt_node *host; + + if( !( ic->flags & OPT_LOGGED_IN ) && + ( host = xt_find_node( node->children, "see-other-host" ) ) && + host->text ) + { + char *s; + int port = set_getint( &ic->acc->set, "port" ); + + /* Let's try to obey this request, if we're not logged + in yet (i.e. not have too much state yet). */ + if( jd->ssl ) + ssl_disconnect( jd->ssl ); + closesocket( jd->fd ); + b_event_remove( jd->r_inpa ); + b_event_remove( jd->w_inpa ); + + jd->ssl = NULL; + jd->r_inpa = jd->w_inpa = 0; + jd->flags &= JFLAG_XMLCONSOLE; + + s = strchr( host->text, ':' ); + if( s != NULL ) + sscanf( s + 1, "%d", &port ); + + imcb_log( ic, "Redirected to %s", host->text ); + jd->fd = proxy_connect( host->text, port, jabber_connected_plain, ic ); + + return XT_ABORT; + } err = jabber_error_parse( node, XMLNS_STREAM_ERROR ); |