From 3b1b4f5de2b2d05dc3f84290309b577453969a7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Tue, 20 Mar 2018 17:56:22 -0400 Subject: [PATCH] p2p: do not destroy current ConnectedTurnTransport when a new file is incoming When a new file is incoming, onTurnPeerConnection is triggered and the previous turn endpoint deleted. This is dangerous if an user receives multiple files at the same time. turn_ep_ should keep previous endpoints to allow incoming files from multiple contacts. Change-Id: Ia2c5b55bcc491a7d65936d27115b31809e6200ce --- src/ringdht/p2p.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ringdht/p2p.cpp b/src/ringdht/p2p.cpp index 496bc9f640..6557c06d69 100644 --- a/src/ringdht/p2p.cpp +++ b/src/ringdht/p2p.cpp @@ -201,7 +201,7 @@ public: Channel<std::unique_ptr<CtrlMsgBase>> ctrl; private: - std::unique_ptr<ConnectedTurnTransport> turn_ep_; + std::list<std::unique_ptr<ConnectedTurnTransport>> turn_ep_; std::unique_ptr<TurnTransport> turn_; // key: Stored certificate PublicKey id (normaly it's the DeviceId) @@ -441,7 +441,8 @@ DhtPeerConnector::Impl::onTurnPeerConnection(const IpAddr& peer_addr) servers_.emplace(peer_addr, std::move(connection)); // note: operating this way let endpoint to be deleted safely in case of exceptions - turn_ep_ = std::move(turn_ep); + std::remove(turn_ep_.begin(), turn_ep_.end(), nullptr); + turn_ep_.emplace_back(std::move(turn_ep)); } void -- GitLab