From 3bbfa9f34108fe65d1fcfac560f7f0977066e602 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Mon, 13 Apr 2015 22:54:02 +0000 Subject: [PATCH] FS-7407: when using proxy, make sure to pick the right transport to the proxy --- src/mod/endpoints/mod_sofia/sofia_presence.c | 48 +++++++++++--------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index 7e31b4cfdd..d7255e8bfc 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -2201,9 +2201,23 @@ static void _send_presence_notify(sofia_profile_t *profile, path = sofia_glue_get_path_from_contact((char *) o_contact); } - tmp = (char *)o_contact; - o_contact_dup = sofia_glue_get_url_from_contact(tmp, 1); + dst = sofia_glue_get_destination((char *) o_contact); + switch_assert(dst); + if (!zstr(dst->contact)) { + contact = sofia_glue_get_url_from_contact(dst->contact, 1); + } else { + contact = strdup(o_contact); + } + + if (dst->route_uri) { + route_uri = sofia_glue_strip_uri(dst->route_uri); + tmp = (char *)route_uri; + } else { + tmp = (char *)o_contact; + } + + o_contact_dup = sofia_glue_get_url_from_contact(tmp, 1); if ((tp = switch_stristr("transport=", o_contact_dup))) { tp += 10; @@ -2272,19 +2286,6 @@ static void _send_presence_notify(sofia_profile_t *profile, free(to_uri); } - dst = sofia_glue_get_destination((char *) o_contact); - switch_assert(dst); - - if (!zstr(dst->contact)) { - contact = sofia_glue_get_url_from_contact(dst->contact, 1); - } else { - contact = strdup(o_contact); - } - - if (dst->route_uri) { - route_uri = sofia_glue_strip_uri(dst->route_uri); - } - if (expires) { long ltmp = atol(expires); @@ -4023,7 +4024,7 @@ void sofia_presence_handle_sip_i_subscribe(int status, char *sticky = NULL; char *contactstr = profile->url, *cs = NULL; char *p = NULL, *new_contactstr = NULL; - + sofia_transport_t transport; if (np.is_nat) { char params[128] = ""; @@ -4040,20 +4041,23 @@ void sofia_presence_handle_sip_i_subscribe(int status, contactstr = profile->url; } + if (sip->sip_via) { + transport = sofia_glue_via2transport(sip->sip_via); + } else { + transport = sofia_glue_url2transport(contact->m_url); + } - if (switch_stristr("port=tcp", contact->m_url->url_params)) { + if (transport == SOFIA_TRANSPORT_TCP) { if (np.is_auto_nat) { cs = profile->tcp_public_contact; } else { cs = profile->tcp_contact; } - } else if (switch_stristr("port=tls", contact->m_url->url_params)) { + } else if (transport == SOFIA_TRANSPORT_TCP_TLS) { if (np.is_auto_nat) { - cs = sofia_test_pflag(profile, PFLAG_TLS) ? - profile->tls_public_contact : profile->tcp_public_contact; + cs = sofia_test_pflag(profile, PFLAG_TLS) ? profile->tls_public_contact : profile->tcp_public_contact; } else { - cs = sofia_test_pflag(profile, PFLAG_TLS) ? - profile->tls_contact : profile->tcp_contact; + cs = sofia_test_pflag(profile, PFLAG_TLS) ? profile->tls_contact : profile->tcp_contact; } }