# HG changeset patch # User Simon van der Linden # Date 1304439156 0 # Node ID 6ec53e134447d82088f3b53b477d8c42fbc0691d # Parent 3e11fa72c5d897f3844059d0f478f97878d6d33a bonjour: Recurse through user IP addresses instead of using the first one only This, among other things, makes interactivity with iChat more reliable because iChat apparently advertises an IPv6 address, but doesn't listen on it. Fixes #13773 committer: Daniel Atallah diff -r 3e11fa72c5d8 -r 6ec53e134447 libpurple/protocols/bonjour/jabber.c --- a/libpurple/protocols/bonjour/jabber.c Tue May 03 12:49:56 2011 +0000 +++ b/libpurple/protocols/bonjour/jabber.c Tue May 03 16:12:36 2011 +0000 @@ -831,12 +831,39 @@ if (source < 0) { PurpleConversation *conv = NULL; PurpleAccount *account = NULL; + GSList *tmp = bb->ips; - purple_debug_error("bonjour", "Error connecting to buddy %s at %s:%d error: %s\n", - purple_buddy_get_name(pb), bb->conversation->ip, bb->port_p2pj, error ? error : "(null)"); + purple_debug_error("bonjour", "Error connecting to buddy %s at %s:%d (%s); Trying next IP address\n", + purple_buddy_get_name(pb), bb->conversation->ip, bb->port_p2pj, error); + + for (; strcmp(bb->conversation->ip, tmp->data) != 0; tmp = g_slist_next(tmp)); + tmp = g_slist_next(tmp); account = purple_buddy_get_account(pb); + if (tmp != NULL) { + const gchar *ip; + PurpleProxyConnectData *connect_data; + + ip = tmp->data; + + purple_debug_info("bonjour", "Starting conversation with %s at %s:%d\n", + purple_buddy_get_name(pb), ip, bb->port_p2pj); + + connect_data = purple_proxy_connect(purple_account_get_connection(account), + account, ip, bb->port_p2pj, _connected_to_buddy, pb); + + if (connect_data != NULL) { + g_free(bb->conversation->ip); + bb->conversation->ip = g_strdup(ip); + bb->conversation->connect_data = connect_data; + + return; + } + } + + purple_debug_error("bonjour", "No more addresses for buddy %s. Aborting", purple_buddy_get_name(pb)); + conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, account); if (conv != NULL) purple_conversation_write(conv, NULL, @@ -995,10 +1022,9 @@ { PurpleProxyConnectData *connect_data; PurpleProxyInfo *proxy_info; - /* For better or worse, use the first IP*/ - const char *ip = bb->ips->data; + const char *ip = bb->ips->data; /* Start with the first IP address. */ - purple_debug_info("bonjour", "Starting conversation with %s\n", to); + purple_debug_info("bonjour", "Starting conversation with %s at %s:%d\n", to, ip, bb->port_p2pj); /* Make sure that the account always has a proxy of "none". * This is kind of dirty, but proxy_connect_none() isn't exposed. */