From d321b10cb84b4ebb919b62de50c76aac6eb72a4d Mon Sep 17 00:00:00 2001 From: Tobias Markmann Date: Wed, 8 Apr 2015 21:37:51 +0200 Subject: 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 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 #include -#include +#include #include -#include #include +#include +#include #include -#include 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); } } -- cgit v0.10.2-6-g49f6