From 824c28e11ebfdf468f839765f1873de88c16645e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Fri, 9 Jan 2015 14:48:41 -0500
Subject: [PATCH] don't duplicate <sip:> hostname encapsulation in IP2IP

Refs #63591

Change-Id: I33a4a215db406d07f1ceb13db9b2a818b1d98e10
---
 daemon/src/sip/sipaccount.cpp | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/daemon/src/sip/sipaccount.cpp b/daemon/src/sip/sipaccount.cpp
index be6d8046a8..72f55af2a9 100644
--- a/daemon/src/sip/sipaccount.cpp
+++ b/daemon/src/sip/sipaccount.cpp
@@ -184,7 +184,6 @@ SIPAccount::newOutgoingCall(const std::string& id, const std::string& toUrl)
         ipv6 = IpAddr::isIpv6(toUrl);
 #endif
         to = ipv6 ? IpAddr(toUrl).toString(false, true) : toUrl;
-        toUri = getToUri(to);
         family = ipv6 ? pj_AF_INET6() : pj_AF_INET();
 
         // TODO: resolve remote host using SIPVoIPLink::resolveSrvName
@@ -200,14 +199,6 @@ SIPAccount::newOutgoingCall(const std::string& id, const std::string& toUrl)
     }
     else {
         to = toUrl;
-
-        // If toUrl is not a well formatted sip URI, use account information to process it
-        if (toUrl.find("sip:") != std::string::npos or
-            toUrl.find("sips:") != std::string::npos)
-            toUri = toUrl;
-        else
-            toUri = getToUri(to);
-
         call->setTransport(transport_);
         // FIXME : for now, use the same address family as the SIP transport
         family = pjsip_transport_type_get_af(getTransportType());
@@ -215,6 +206,12 @@ SIPAccount::newOutgoingCall(const std::string& id, const std::string& toUrl)
         RING_DBG("UserAgent: New registered account call to %s", toUrl.c_str());
     }
 
+    // If toUrl is not a well formatted sip URI, use account information to process it
+    if (toUrl.find("sip:") != std::string::npos or
+        toUrl.find("sips:") != std::string::npos)
+        toUri = toUrl;
+    else
+        toUri = getToUri(to);
     call->initIceTransport(true);
 
     call->setIPToIP(isIP2IP());
-- 
GitLab