summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-01-09 16:39:11 (GMT)
committerSwift Review <review@swift.im>2015-02-11 09:35:21 (GMT)
commit779f0d57bc9d90300aad0b1386dc937612ac35f4 (patch)
tree2b7beb4db6af92eef45a6adaf0118d3ba149056b /Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h
parent66567c962202920b0d6bc06029ed37565cd4a81c (diff)
downloadswift-779f0d57bc9d90300aad0b1386dc937612ac35f4.zip
swift-779f0d57bc9d90300aad0b1386dc937612ac35f4.tar.bz2
Support domain names in S5B proxy <streamhost> tags.
S5BProxyManager now resolves DNS names of proxy entries discovered via service discovery. Test-Information: Tested against a XMPP installation that uses domain names in proxy entires. Change-Id: I728243333ec6e62e86f088f2a7b6e222c629757b
Diffstat (limited to 'Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h')
-rw-r--r--Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h49
1 files changed, 38 insertions, 11 deletions
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h b/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h
index f3fed80..06db76c 100644
--- a/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h
+++ b/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h
@@ -4,6 +4,13 @@
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
+/*
+ * Copyright (c) 2015 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+
#pragma once
#include <string>
@@ -13,11 +20,13 @@
#include <Swiften/Elements/S5BProxyRequest.h>
#include <Swiften/FileTransfer/SOCKS5BytestreamClientSession.h>
#include <Swiften/JID/JID.h>
-#include <Swiften/Network/ConnectionFactory.h>
-#include <Swiften/Network/TimerFactory.h>
+#include <Swiften/FileTransfer/SOCKS5BytestreamProxyFinder.h>
namespace Swift {
- class SOCKS5BytestreamProxiesDiscoverRequest;
+ class TimerFactory;
+ class ConnectionFactory;
+ class DomainNameResolver;
+ class DomainNameResolveError;
/**
* - manages list of working S5B proxies
@@ -25,26 +34,44 @@ namespace Swift {
*/
class SWIFTEN_API SOCKS5BytestreamProxiesManager {
public:
- SOCKS5BytestreamProxiesManager(ConnectionFactory*, TimerFactory*);
-
- boost::shared_ptr<SOCKS5BytestreamProxiesDiscoverRequest> createDiscoverProxiesRequest();
+ SOCKS5BytestreamProxiesManager(ConnectionFactory*, TimerFactory*, DomainNameResolver*, IQRouter*, const JID&);
+ ~SOCKS5BytestreamProxiesManager();
void addS5BProxy(S5BProxyRequest::ref);
- const std::vector<S5BProxyRequest::ref>& getS5BProxies() const;
+
+ /*
+ * Returns a list of external S5B proxies. If the optinal return value is not initialized a discovery process has been started and
+ * onDiscoveredProxiesChanged signal will be emitted when it is finished.
+ */
+ const boost::optional<std::vector<S5BProxyRequest::ref> >& getOrDiscoverS5BProxies();
void connectToProxies(const std::string& sessionID);
boost::shared_ptr<SOCKS5BytestreamClientSession> getProxySessionAndCloseOthers(const JID& proxyJID, const std::string& sessionID);
boost::shared_ptr<SOCKS5BytestreamClientSession> createSOCKS5BytestreamClientSession(HostAddressPort addressPort, const std::string& destAddr);
+ public:
+ boost::signal<void ()> onDiscoveredProxiesChanged;
+
+ private:
+ void handleProxyFound(S5BProxyRequest::ref proxy);
+ void handleNameLookupResult(const std::vector<HostAddress>&, boost::optional<DomainNameResolveError>, S5BProxyRequest::ref proxy);
+
+ void queryForProxies();
+
private:
- ConnectionFactory* connectionFactory;
- TimerFactory* timerFactory;
+ ConnectionFactory* connectionFactory_;
+ TimerFactory* timerFactory_;
+ DomainNameResolver* resolver_;
+ IQRouter* iqRouter_;
+ JID serviceRoot_;
typedef std::map<JID, boost::shared_ptr<SOCKS5BytestreamClientSession> > ProxyJIDClientSessionMap;
- std::map<std::string, ProxyJIDClientSessionMap> proxySessions;
+ std::map<std::string, ProxyJIDClientSessionMap> proxySessions_;
+
+ boost::shared_ptr<SOCKS5BytestreamProxyFinder> proxyFinder_;
- std::vector<S5BProxyRequest::ref> localS5BProxies;
+ boost::optional<std::vector<S5BProxyRequest::ref> > localS5BProxies_;
};
}