summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.cpp')
-rw-r--r--Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.cpp29
1 files changed, 14 insertions, 15 deletions
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.cpp b/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.cpp
index 1036e12..25a12ea 100644
--- a/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.cpp
+++ b/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.cpp
@@ -110,25 +110,24 @@ boost::shared_ptr<SOCKS5BytestreamClientSession> SOCKS5BytestreamProxiesManager:
110boost::shared_ptr<SOCKS5BytestreamClientSession> SOCKS5BytestreamProxiesManager::createSOCKS5BytestreamClientSession(HostAddressPort addressPort, const std::string& destAddr) { 110boost::shared_ptr<SOCKS5BytestreamClientSession> SOCKS5BytestreamProxiesManager::createSOCKS5BytestreamClientSession(HostAddressPort addressPort, const std::string& destAddr) {
111 SOCKS5BytestreamClientSession::ref connection = boost::make_shared<SOCKS5BytestreamClientSession>(connectionFactory_->createConnection(), addressPort, destAddr, timerFactory_); 111 SOCKS5BytestreamClientSession::ref connection = boost::make_shared<SOCKS5BytestreamClientSession>(connectionFactory_->createConnection(), addressPort, destAddr, timerFactory_);
112 return connection; 112 return connection;
113} 113}
114 114
115void SOCKS5BytestreamProxiesManager::handleProxyFound(S5BProxyRequest::ref proxy) { 115void SOCKS5BytestreamProxiesManager::handleProxiesFound(std::vector<S5BProxyRequest::ref> proxyHosts) {
116 if (proxy) { 116 foreach(S5BProxyRequest::ref proxy, proxyHosts) {
117 if (HostAddress(proxy->getStreamHost().get().host).isValid()) { 117 if (proxy) {
118 addS5BProxy(proxy); 118 if (HostAddress(proxy->getStreamHost().get().host).isValid()) {
119 onDiscoveredProxiesChanged(); 119 addS5BProxy(proxy);
120 } 120 onDiscoveredProxiesChanged();
121 else { 121 }
122 DomainNameAddressQuery::ref resolveRequest = resolver_->createAddressQuery(proxy->getStreamHost().get().host); 122 else {
123 resolveRequest->onResult.connect(boost::bind(&SOCKS5BytestreamProxiesManager::handleNameLookupResult, this, _1, _2, proxy)); 123 DomainNameAddressQuery::ref resolveRequest = resolver_->createAddressQuery(proxy->getStreamHost().get().host);
124 resolveRequest->run(); 124 resolveRequest->onResult.connect(boost::bind(&SOCKS5BytestreamProxiesManager::handleNameLookupResult, this, _1, _2, proxy));
125 resolveRequest->run();
126 }
125 } 127 }
126 } 128 }
127 else {
128 onDiscoveredProxiesChanged();
129 }
130 proxyFinder_->stop(); 129 proxyFinder_->stop();
131 proxyFinder_.reset(); 130 proxyFinder_.reset();
132} 131}
133 132
134void SOCKS5BytestreamProxiesManager::handleNameLookupResult(const std::vector<HostAddress>& addresses, boost::optional<DomainNameResolveError> error, S5BProxyRequest::ref proxy) { 133void SOCKS5BytestreamProxiesManager::handleNameLookupResult(const std::vector<HostAddress>& addresses, boost::optional<DomainNameResolveError> error, S5BProxyRequest::ref proxy) {
@@ -155,16 +154,16 @@ void SOCKS5BytestreamProxiesManager::handleNameLookupResult(const std::vector<Ho
155} 154}
156 155
157void SOCKS5BytestreamProxiesManager::queryForProxies() { 156void SOCKS5BytestreamProxiesManager::queryForProxies() {
158 proxyFinder_ = boost::make_shared<SOCKS5BytestreamProxyFinder>(serviceRoot_, iqRouter_); 157 proxyFinder_ = boost::make_shared<SOCKS5BytestreamProxyFinder>(serviceRoot_, iqRouter_);
159 158
160 proxyFinder_->onProxyFound.connect(boost::bind(&SOCKS5BytestreamProxiesManager::handleProxyFound, this, _1)); 159 proxyFinder_->onProxiesFound.connect(boost::bind(&SOCKS5BytestreamProxiesManager::handleProxiesFound, this, _1));
161 proxyFinder_->start(); 160 proxyFinder_->start();
162} 161}
163 162
164void SOCKS5BytestreamProxiesManager::handleProxySessionReady(const std::string& sessionID, const JID& jid, boost::shared_ptr<SOCKS5BytestreamClientSession> session, bool error) { 163void SOCKS5BytestreamProxiesManager::handleProxySessionReady(const std::string& sessionID, const JID& jid, boost::shared_ptr<SOCKS5BytestreamClientSession> session, bool error) {
165 session->onSessionReady.disconnect(boost::bind(&SOCKS5BytestreamProxiesManager::handleProxySessionFinished, this, boost::cref(sessionID), boost::cref(jid), session, _1)); 164 session->onSessionReady.disconnect(boost::bind(&SOCKS5BytestreamProxiesManager::handleProxySessionReady, this, boost::cref(sessionID), boost::cref(jid), session, _1));
166 if (!error) { 165 if (!error) {
167 // The SOCKS5 bytestream session to the proxy succeeded; stop and remove other sessions. 166 // The SOCKS5 bytestream session to the proxy succeeded; stop and remove other sessions.
168 if (proxySessions_.find(sessionID) != proxySessions_.end()) { 167 if (proxySessions_.find(sessionID) != proxySessions_.end()) {
169 for (ProxyJIDClientSessionVector::iterator i = proxySessions_[sessionID].begin(); i != proxySessions_[sessionID].end();) { 168 for (ProxyJIDClientSessionVector::iterator i = proxySessions_[sessionID].begin(); i != proxySessions_[sessionID].end();) {
170 if ((i->first == jid) && (i->second != session)) { 169 if ((i->first == jid) && (i->second != session)) {