summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-07-16 08:11:09 (GMT)
committerTobias Markmann <tm@ayena.de>2015-07-17 11:51:49 (GMT)
commit3e982c0a39d1d1833afaf558fc7b0f7aeffd2d64 (patch)
tree2b5c6ea333bfb97066cf60ff97345d73ee167581 /Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h
parentb9edc9bbf5e304a1b2cec8f963c0d8d53ff0e2f2 (diff)
downloadswift-3e982c0a39d1d1833afaf558fc7b0f7aeffd2d64.zip
swift-3e982c0a39d1d1833afaf558fc7b0f7aeffd2d64.tar.bz2
Fix S5B proxy connection management for multiple hosts per JID
A recent commit introduced resolving of S5B proxy domain names to their IPv4 and IPv6 addresses. With that a proxy identified by a JID can have more than one host and we try them in parallel until the first succeeds. The old code just handled one host per proxy JID and a failed IPv6 attempt would override the succeeded connection. The code uses shared pointers and the succeeded connecting is deallocated and disconnected when it is replaced with the failing IPv6 connection. The result is the proxy server complaining that we are not connected as we try to activate the proxy stream. This commit changes the the proxy management to handle multiple connections per proxy JID. Failing connections are removed from the proxy sessions data structure. With the first succeeding connections, others are stopped and also removed. Test-Information: Tested on Linux (Elementary OS 0.2) with "Swiften/QA/FileTransferTest/FileTransferTest 4 4", which forces the use of SOCKS5 bytestream proxy. Change-Id: If3071c3d058e1040556bb72702bf83f4f5f25334
Diffstat (limited to 'Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h')
-rw-r--r--Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h b/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h
index 06db76c..e4bf1d9 100644
--- a/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h
+++ b/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h
@@ -13,14 +13,16 @@
#pragma once
+#include <map>
#include <string>
+#include <utility>
#include <vector>
#include <Swiften/Base/API.h>
#include <Swiften/Elements/S5BProxyRequest.h>
#include <Swiften/FileTransfer/SOCKS5BytestreamClientSession.h>
-#include <Swiften/JID/JID.h>
#include <Swiften/FileTransfer/SOCKS5BytestreamProxyFinder.h>
+#include <Swiften/JID/JID.h>
namespace Swift {
class TimerFactory;
@@ -59,6 +61,9 @@ namespace Swift {
void queryForProxies();
+ void handleProxySessionReady(const std::string& sessionID, const JID& jid, boost::shared_ptr<SOCKS5BytestreamClientSession> session, bool error);
+ void handleProxySessionFinished(const std::string& sessionID, const JID& jid, boost::shared_ptr<SOCKS5BytestreamClientSession> session, boost::optional<FileTransferError> error);
+
private:
ConnectionFactory* connectionFactory_;
TimerFactory* timerFactory_;
@@ -66,8 +71,9 @@ namespace Swift {
IQRouter* iqRouter_;
JID serviceRoot_;
- typedef std::map<JID, boost::shared_ptr<SOCKS5BytestreamClientSession> > ProxyJIDClientSessionMap;
- std::map<std::string, ProxyJIDClientSessionMap> proxySessions_;
+ typedef std::vector<std::pair<JID, boost::shared_ptr<SOCKS5BytestreamClientSession> > > ProxyJIDClientSessionVector;
+ typedef std::map<std::string, ProxyJIDClientSessionVector> ProxySessionsMap;
+ ProxySessionsMap proxySessions_;
boost::shared_ptr<SOCKS5BytestreamProxyFinder> proxyFinder_;