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 /Swiften
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
Diffstat (limited to 'Swiften')
-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 @@
#include <vector>
-#include <boost/shared_ptr.hpp>
#include <boost/bind.hpp>
+#include <boost/shared_ptr.hpp>
#include <boost/smart_ptr/make_shared.hpp>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Base/Log.h>
+#include <Swiften/Base/foreach.h>
#include <Swiften/Elements/JingleS5BTransportPayload.h>
#include <Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h>
#include <Swiften/FileTransfer/SOCKS5BytestreamServerManager.h>
-#include <Swiften/FileTransfer/SOCKS5BytestreamServerResourceUser.h>
#include <Swiften/FileTransfer/SOCKS5BytestreamServerPortForwardingUser.h>
+#include <Swiften/FileTransfer/SOCKS5BytestreamServerResourceUser.h>
static const unsigned int LOCAL_PREFERENCE = 0;
@@ -73,6 +73,9 @@ void LocalJingleTransportCandidateGenerator::start() {
}
void LocalJingleTransportCandidateGenerator::stop() {
+ if (s5bServerResourceUser_) {
+ s5bServerResourceUser_->onSuccessfulInitialized.disconnect(boost::bind(&LocalJingleTransportCandidateGenerator::handleS5BServerInitialized, this, _1));
+ }
s5bServerResourceUser_.reset();
}
@@ -82,6 +85,7 @@ void LocalJingleTransportCandidateGenerator::handleS5BServerInitialized(bool suc
if (options_.isAssistedAllowed()) {
// try to setup port forwarding
s5bServerPortForwardingUser_ = s5bServerManager->aquirePortForwardingUser();
+ s5bServerPortForwardingUser_->onSetup.connect(boost::bind(&LocalJingleTransportCandidateGenerator::handlePortForwardingSetup, this, _1));
if (s5bServerPortForwardingUser_->isForwardingSetup()) {
handlePortForwardingSetup(true);
}
@@ -89,13 +93,19 @@ void LocalJingleTransportCandidateGenerator::handleS5BServerInitialized(bool suc
}
else {
SWIFT_LOG(warning) << "Unable to start SOCKS5 server" << std::endl;
+ if (s5bServerResourceUser_) {
+ s5bServerResourceUser_->onSuccessfulInitialized.disconnect(boost::bind(&LocalJingleTransportCandidateGenerator::handleS5BServerInitialized, this, _1));
+ }
s5bServerResourceUser_.reset();
handlePortForwardingSetup(false);
}
checkS5BCandidatesReady();
}
-void LocalJingleTransportCandidateGenerator::handlePortForwardingSetup(bool success) {
+void LocalJingleTransportCandidateGenerator::handlePortForwardingSetup(bool /* success */) {
+ if (s5bServerPortForwardingUser_) {
+ s5bServerPortForwardingUser_->onSetup.disconnect(boost::bind(&LocalJingleTransportCandidateGenerator::handlePortForwardingSetup, this, _1));
+ }
triedForwarding_ = true;
checkS5BCandidatesReady();
}
@@ -109,7 +119,7 @@ void LocalJingleTransportCandidateGenerator::handleDiscoveredProxiesChanged() {
void LocalJingleTransportCandidateGenerator::checkS5BCandidatesReady() {
if ((!options_.isDirectAllowed() || (options_.isDirectAllowed() && triedServerInit_)) &&
(!options_.isProxiedAllowed() || (options_.isProxiedAllowed() && triedProxyDiscovery_)) &&
- (!options_.isDirectAllowed() || (options_.isDirectAllowed() && triedServerInit_))) {
+ (!options_.isAssistedAllowed() || (options_.isAssistedAllowed() && triedForwarding_))) {
emitOnLocalTransportCandidatesGenerated();
}
}