From 8f35361a2b71b58aaa5a18111778d85e397f347d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Mon, 1 Feb 2021 11:50:27 -0500
Subject: [PATCH] connectionManager: fix answerTo logic

Previous answerTo's logic was weird. hasPublicIp() should be
unnecessary here and we should send remote candidates when
gathered (before ice->start).

Change-Id: I3dc9466a1979878e5557fc7dd05cee6049935523
---
 src/jamidht/connectionmanager.cpp | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/src/jamidht/connectionmanager.cpp b/src/jamidht/connectionmanager.cpp
index 0f93f54b05..27459ab8d0 100644
--- a/src/jamidht/connectionmanager.cpp
+++ b/src/jamidht/connectionmanager.cpp
@@ -611,7 +611,7 @@ ConnectionManager::Impl::onRequestStartIce(const PeerConnectionRequest& req)
     }
 
     auto sdp = IceTransport::parse_SDP(req.ice_msg, *ice);
-    auto hasPubIp = hasPublicIp(sdp);
+    answerTo(*ice, req.id, req.from);
     if (not ice->startIce({sdp.rem_ufrag, sdp.rem_pwd}, sdp.rem_candidates)) {
         JAMI_ERR("[Account:%s] start ICE failed - fallback to TURN", account.getAccountID().c_str());
         ice = nullptr;
@@ -619,9 +619,6 @@ ConnectionManager::Impl::onRequestStartIce(const PeerConnectionRequest& req)
             connReadyCb_(req.from, "", nullptr);
         return;
     }
-
-    if (hasPubIp)
-        answerTo(*ice, req.id, req.from);
 }
 
 void
@@ -640,11 +637,6 @@ ConnectionManager::Impl::onRequestOnNegoDone(const PeerConnectionRequest& req)
         return;
     }
 
-    auto sdp = IceTransport::parse_SDP(req.ice_msg, *ice);
-    auto hasPubIp = hasPublicIp(sdp);
-    if (!hasPubIp)
-        answerTo(*ice, req.id, req.from);
-
     // Build socket
     auto endpoint = std::make_unique<IceSocketEndpoint>(std::shared_ptr<IceTransport>(
                                                             std::move(ice)),
-- 
GitLab