summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-06-19 12:50:07 (GMT)
committerKevin Smith <kevin.smith@isode.com>2015-07-08 07:08:30 (GMT)
commit67fef39ed463533157e66a72c17f31f9d078d5a2 (patch)
tree46e57023e0901940e938f470cf64a159df69d2b7 /Swiften/FileTransfer
parenta2b065eb22755f9341c58096805875021faffa67 (diff)
downloadswift-67fef39ed463533157e66a72c17f31f9d078d5a2.zip
swift-67fef39ed463533157e66a72c17f31f9d078d5a2.tar.bz2
Create S5B proxy candidates for each DNS lookup result
If the S5B proxy lookup result has no direct IP address listed the name is resolved using DNS. This change will create a proxy result per resolved result address and not only the first result address. Test-Information: Verified the candidate list contains both entires for a proxy name that resolves to an A and an AAAA record. Change-Id: Iec21ff90af981030ff49fb53803d88a59694767c
Diffstat (limited to 'Swiften/FileTransfer')
-rw-r--r--Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.cpp b/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.cpp
index 26ad8b5..2956ff7 100644
--- a/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.cpp
+++ b/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.cpp
@@ -13,17 +13,17 @@
#include <Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h>
-#include <boost/smart_ptr/make_shared.hpp>
#include <boost/bind.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
+#include <Swiften/Base/Log.h>
#include <Swiften/Base/foreach.h>
#include <Swiften/FileTransfer/SOCKS5BytestreamClientSession.h>
-#include <Swiften/Base/Log.h>
-#include <Swiften/Network/DomainNameResolver.h>
#include <Swiften/Network/ConnectionFactory.h>
-#include <Swiften/Network/TimerFactory.h>
#include <Swiften/Network/DomainNameAddressQuery.h>
#include <Swiften/Network/DomainNameResolveError.h>
+#include <Swiften/Network/DomainNameResolver.h>
+#include <Swiften/Network/TimerFactory.h>
namespace Swift {
@@ -44,7 +44,6 @@ void SOCKS5BytestreamProxiesManager::addS5BProxy(S5BProxyRequest::ref proxy) {
localS5BProxies_ = std::vector<S5BProxyRequest::ref>();
}
localS5BProxies_->push_back(proxy);
- onDiscoveredProxiesChanged();
}
}
@@ -106,6 +105,7 @@ void SOCKS5BytestreamProxiesManager::handleProxyFound(S5BProxyRequest::ref proxy
if (proxy) {
if (HostAddress(proxy->getStreamHost().get().host).isValid()) {
addS5BProxy(proxy);
+ onDiscoveredProxiesChanged();
}
else {
DomainNameAddressQuery::ref resolveRequest = resolver_->createAddressQuery(proxy->getStreamHost().get().host);
@@ -120,20 +120,25 @@ void SOCKS5BytestreamProxiesManager::handleProxyFound(S5BProxyRequest::ref proxy
proxyFinder_.reset();
}
-void SOCKS5BytestreamProxiesManager::handleNameLookupResult(const std::vector<HostAddress>& address, boost::optional<DomainNameResolveError> error, S5BProxyRequest::ref proxy) {
+void SOCKS5BytestreamProxiesManager::handleNameLookupResult(const std::vector<HostAddress>& addresses, boost::optional<DomainNameResolveError> error, S5BProxyRequest::ref proxy) {
if (error) {
onDiscoveredProxiesChanged();
}
else {
- if (address.empty()) {
+ if (addresses.empty()) {
SWIFT_LOG(warning) << "S5B proxy hostname does not resolve." << std::endl;
onDiscoveredProxiesChanged();
}
else {
- S5BProxyRequest::StreamHost streamHost = proxy->getStreamHost().get();
- streamHost.host = address[0].toString();
- proxy->setStreamHost(streamHost);
- addS5BProxy(proxy);
+ // generate proxy per returned address
+ foreach (const HostAddress& address, addresses) {
+ S5BProxyRequest::StreamHost streamHost = proxy->getStreamHost().get();
+ S5BProxyRequest::ref proxyForAddress = boost::make_shared<S5BProxyRequest>(*proxy);
+ streamHost.host = address.toString();
+ proxyForAddress->setStreamHost(streamHost);
+ addS5BProxy(proxyForAddress);
+ }
+ onDiscoveredProxiesChanged();
}
}
}