summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-04-08 19:37:51 (GMT)
committerKevin Smith <kevin.smith@isode.com>2015-04-08 20:35:23 (GMT)
commitd321b10cb84b4ebb919b62de50c76aac6eb72a4d (patch)
tree384e57b0bd7c9834ac1c9d67f212a96614defe7c /Swiften
parent9451f9218a04c27504895e2866454c508af118c6 (diff)
downloadswift-d321b10cb84b4ebb919b62de50c76aac6eb72a4d.zip
swift-d321b10cb84b4ebb919b62de50c76aac6eb72a4d.tar.bz2
Skip name lookup if manual hostname is a valid IP address
Removed dead debugging code and unnecessary includes as well. Test-Information: Tested with Swiften/QA/ClientTest, adjusted to have a manual hostname set in the ClientOptions. Tested on OS X 10.9.5, with NDK API level 14 on an emulated Android 4.0 ARM instance. Without this patch the connector timed out during name lookup trying to resolve the IP set in the ClientOptions::manualHostname. With this patch it skips lookup and connects successfully. Tested and verified unchanged behavior with this patch and without the manual address override set. Change-Id: I737327b2e66c9da78a1963e754bcf201b7d40626
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Network/Connector.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/Swiften/Network/Connector.cpp b/Swiften/Network/Connector.cpp
index cb062d7..5510acb 100644
--- a/Swiften/Network/Connector.cpp
+++ b/Swiften/Network/Connector.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Isode Limited.
+ * Copyright (c) 2010-2015 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,13 +7,13 @@
#include <Swiften/Network/Connector.h>
#include <boost/bind.hpp>
-#include <iostream>
+#include <Swiften/Base/Log.h>
#include <Swiften/Network/ConnectionFactory.h>
-#include <Swiften/Network/DomainNameResolver.h>
#include <Swiften/Network/DomainNameAddressQuery.h>
+#include <Swiften/Network/DomainNameResolver.h>
+#include <Swiften/Network/HostAddress.h>
#include <Swiften/Network/TimerFactory.h>
-#include <Swiften/Base/Log.h>
namespace Swift {
@@ -26,7 +26,6 @@ void Connector::setTimeoutMilliseconds(int milliseconds) {
void Connector::start() {
SWIFT_LOG(debug) << "Starting connector for " << hostname << std::endl;
- //std::cout << "Connector::start()" << std::endl;
assert(!currentConnection);
assert(!serviceQuery);
assert(!timer);
@@ -40,7 +39,12 @@ void Connector::start() {
serviceQuery->onResult.connect(boost::bind(&Connector::handleServiceQueryResult, shared_from_this(), _1));
serviceQuery->run();
}
- else {
+ else if (HostAddress(hostname).isValid()) {
+ // hostname is already a valid address; skip name lookup.
+ foundSomeDNS = true;
+ addressQueryResults.push_back(HostAddress(hostname));
+ tryNextAddress();
+ } else {
queryAddress(hostname);
}
}