From cf8a20f90565d0018879f1671608e844adad3032 Mon Sep 17 00:00:00 2001 From: Anibal Avelar Date: Tue, 19 Jan 2010 02:51:38 -0600 Subject: [PATCH] Real server auto-discovery support. First step. The server auto-discovery support works only when the SRV records backs an errorfor each domain { "sipinternaltls", "tcp", SIPE_TRANSPORT_TLS }, /* for internal TLS connections */ { "sipinternal", "tcp", SIPE_TRANSPORT_TCP }, /* for internal TCP connections */ { "sip", "tls", SIPE_TRANSPORT_TLS }, /* for external TLS connections */ { "sip", "tcp", SIPE_TRANSPORT_TCP }, /*.for external TCP connections */ but the dns server retuns results doesn't mean we can connect to that server, just mean the domain was resolve. Unfortunately the process stays in an infinite loop with this wrong domain. The good way is to continue with the next domain if it fails to connect. The process backs to the begin after the last domain in the list. Works for me on OCS2007 with a external TLS server. --- src/core/sipe.c | 35 +++++++++++++++++++++++------------ src/core/sipe.h | 2 ++ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/core/sipe.c b/src/core/sipe.c index 9d12beab..5b5fdeab 100644 --- a/src/core/sipe.c +++ b/src/core/sipe.c @@ -799,15 +799,17 @@ void send_sip_response(PurpleConnection *gc, struct sipmsg *msg, int code, static void transactions_remove(struct sipe_account_data *sip, struct transaction *trans) { - sip->transactions = g_slist_remove(sip->transactions, trans); + if (sip->transactions) sip->transactions = g_slist_remove(sip->transactions, trans); purple_debug_info("sipe", "sip->transactions count:%d after removal\n", g_slist_length(sip->transactions)); - if (sip->transactions && trans->msg) sipmsg_free(trans->msg); - if (trans->payload) { - (*trans->payload->destroy)(trans->payload->data); - g_free(trans->payload); - } - g_free(trans->key); - g_free(trans); + if (sip->transactions){ + if(trans->msg) sipmsg_free(trans->msg); + if (trans->payload) { + (*trans->payload->destroy)(trans->payload->data); + g_free(trans->payload); + } + g_free(trans->key); + g_free(trans); + } } static struct transaction * @@ -7477,13 +7479,16 @@ static void sipe_ssl_connect_failure(SIPE_UNUSED_PARAMETER PurpleSslConnection * { PurpleConnection *gc = data; struct sipe_account_data *sip; - + /* If the connection is already disconnected, we don't need to do anything else */ if (!PURPLE_CONNECTION_IS_VALID(gc)) return; sip = gc->proto_data; - sip->fd = -1; + current_service = sip->service_data; + purple_debug_info("sipe", "current_service->transport (%s), current_service->service: (%s)\n", current_service->transport, current_service->service); + + sip->fd = -1; sip->gsc = NULL; switch(error) { @@ -7687,7 +7692,7 @@ static void sipe_login(PurpleAccount *account) purple_connection_error(gc, _("SIP Exchange user name contains invalid characters")); return; } - + gc->proto_data = sip = g_new0(struct sipe_account_data, 1); gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_FORMATTING_WBFO | PURPLE_CONNECTION_NO_BGCOLOR | PURPLE_CONNECTION_NO_FONTSIZE | PURPLE_CONNECTION_NO_URLDESC | PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY; @@ -7790,7 +7795,13 @@ static void sipe_login(PurpleAccount *account) /* Server auto-discovery */ if (strcmp(transport, "auto") == 0) { sip->auto_transport = TRUE; - resolve_next_service(sip, purple_ssl_is_supported() ? service_autodetect : service_tcp); + if(current_service && current_service->transport != NULL && current_service->service != NULL ){ + current_service++; + resolve_next_service(sip, current_service); + } + else{ + resolve_next_service(sip, purple_ssl_is_supported() ? service_autodetect : service_tcp); + } } else if (strcmp(transport, "tls") == 0) { resolve_next_service(sip, service_tls); } else if (strcmp(transport, "tcp") == 0) { diff --git a/src/core/sipe.h b/src/core/sipe.h index 9900424b..192b1946 100644 --- a/src/core/sipe.h +++ b/src/core/sipe.h @@ -105,6 +105,8 @@ struct sipe_service_data { sipe_transport_type type; }; +const struct sipe_service_data *current_service; + /** MS-PRES publication */ struct sipe_publication { gchar *category; -- 2.11.4.GIT