summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-06-19 10:46:56 (GMT)
committerKevin Smith <kevin.smith@isode.com>2015-07-08 07:07:30 (GMT)
commit4f26d4f044f909a73a1ce3183e21419e18a0dd43 (patch)
treeec6f498dfa21f950bff23009e01b1024677e7f4a
parentf4b96b3e1d66f1a7f3e13f5d3e3b293509190db2 (diff)
downloadswift-4f26d4f044f909a73a1ce3183e21419e18a0dd43.zip
swift-4f26d4f044f909a73a1ce3183e21419e18a0dd43.tar.bz2
Wait for assisted candidate detection before emitting candidates
Due to missing signal connection and a copy'n'paste bug, Swift did not wait for port forwarding/public IP detection before emitting the list of local candidates. This is fixed now. The signal is automatically disconnected when the file transfer is finished and s5bServerPortForwardingUser_ is freed. Test-Information: Send a file between two Swift instances and verified log output. Change-Id: I6530a7ac1cbf6941061bd99aa3f3b0624ebc984c
-rw-r--r--Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.cpp b/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.cpp
index 6a059bf..483fdb3 100644
--- a/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.cpp
+++ b/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.cpp
@@ -14,17 +14,17 @@
14 14
15#include <vector> 15#include <vector>
16 16
17#include <boost/shared_ptr.hpp>
18#include <boost/bind.hpp> 17#include <boost/bind.hpp>
18#include <boost/shared_ptr.hpp>
19#include <boost/smart_ptr/make_shared.hpp> 19#include <boost/smart_ptr/make_shared.hpp>
20 20
21#include <Swiften/Base/foreach.h>
22#include <Swiften/Base/Log.h> 21#include <Swiften/Base/Log.h>
22#include <Swiften/Base/foreach.h>
23#include <Swiften/Elements/JingleS5BTransportPayload.h> 23#include <Swiften/Elements/JingleS5BTransportPayload.h>
24#include <Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h> 24#include <Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h>
25#include <Swiften/FileTransfer/SOCKS5BytestreamServerManager.h> 25#include <Swiften/FileTransfer/SOCKS5BytestreamServerManager.h>
26#include <Swiften/FileTransfer/SOCKS5BytestreamServerResourceUser.h>
27#include <Swiften/FileTransfer/SOCKS5BytestreamServerPortForwardingUser.h> 26#include <Swiften/FileTransfer/SOCKS5BytestreamServerPortForwardingUser.h>
27#include <Swiften/FileTransfer/SOCKS5BytestreamServerResourceUser.h>
28 28
29static const unsigned int LOCAL_PREFERENCE = 0; 29static const unsigned int LOCAL_PREFERENCE = 0;
30 30
@@ -73,6 +73,9 @@ void LocalJingleTransportCandidateGenerator::start() {
73} 73}
74 74
75void LocalJingleTransportCandidateGenerator::stop() { 75void LocalJingleTransportCandidateGenerator::stop() {
76 if (s5bServerResourceUser_) {
77 s5bServerResourceUser_->onSuccessfulInitialized.disconnect(boost::bind(&LocalJingleTransportCandidateGenerator::handleS5BServerInitialized, this, _1));
78 }
76 s5bServerResourceUser_.reset(); 79 s5bServerResourceUser_.reset();
77} 80}
78 81
@@ -82,6 +85,7 @@ void LocalJingleTransportCandidateGenerator::handleS5BServerInitialized(bool suc
82 if (options_.isAssistedAllowed()) { 85 if (options_.isAssistedAllowed()) {
83 // try to setup port forwarding 86 // try to setup port forwarding
84 s5bServerPortForwardingUser_ = s5bServerManager->aquirePortForwardingUser(); 87 s5bServerPortForwardingUser_ = s5bServerManager->aquirePortForwardingUser();
88 s5bServerPortForwardingUser_->onSetup.connect(boost::bind(&LocalJingleTransportCandidateGenerator::handlePortForwardingSetup, this, _1));
85 if (s5bServerPortForwardingUser_->isForwardingSetup()) { 89 if (s5bServerPortForwardingUser_->isForwardingSetup()) {
86 handlePortForwardingSetup(true); 90 handlePortForwardingSetup(true);
87 } 91 }
@@ -89,13 +93,19 @@ void LocalJingleTransportCandidateGenerator::handleS5BServerInitialized(bool suc
89 } 93 }
90 else { 94 else {
91 SWIFT_LOG(warning) << "Unable to start SOCKS5 server" << std::endl; 95 SWIFT_LOG(warning) << "Unable to start SOCKS5 server" << std::endl;
96 if (s5bServerResourceUser_) {
97 s5bServerResourceUser_->onSuccessfulInitialized.disconnect(boost::bind(&LocalJingleTransportCandidateGenerator::handleS5BServerInitialized, this, _1));
98 }
92 s5bServerResourceUser_.reset(); 99 s5bServerResourceUser_.reset();
93 handlePortForwardingSetup(false); 100 handlePortForwardingSetup(false);
94 } 101 }
95 checkS5BCandidatesReady(); 102 checkS5BCandidatesReady();
96} 103}
97 104
98void LocalJingleTransportCandidateGenerator::handlePortForwardingSetup(bool success) { 105void LocalJingleTransportCandidateGenerator::handlePortForwardingSetup(bool /* success */) {
106 if (s5bServerPortForwardingUser_) {
107 s5bServerPortForwardingUser_->onSetup.disconnect(boost::bind(&LocalJingleTransportCandidateGenerator::handlePortForwardingSetup, this, _1));
108 }
99 triedForwarding_ = true; 109 triedForwarding_ = true;
100 checkS5BCandidatesReady(); 110 checkS5BCandidatesReady();
101} 111}
@@ -109,7 +119,7 @@ void LocalJingleTransportCandidateGenerator::handleDiscoveredProxiesChanged() {
109void LocalJingleTransportCandidateGenerator::checkS5BCandidatesReady() { 119void LocalJingleTransportCandidateGenerator::checkS5BCandidatesReady() {
110 if ((!options_.isDirectAllowed() || (options_.isDirectAllowed() && triedServerInit_)) && 120 if ((!options_.isDirectAllowed() || (options_.isDirectAllowed() && triedServerInit_)) &&
111 (!options_.isProxiedAllowed() || (options_.isProxiedAllowed() && triedProxyDiscovery_)) && 121 (!options_.isProxiedAllowed() || (options_.isProxiedAllowed() && triedProxyDiscovery_)) &&
112 (!options_.isDirectAllowed() || (options_.isDirectAllowed() && triedServerInit_))) { 122 (!options_.isAssistedAllowed() || (options_.isAssistedAllowed() && triedForwarding_))) {
113 emitOnLocalTransportCandidatesGenerated(); 123 emitOnLocalTransportCandidatesGenerated();
114 } 124 }
115} 125}