summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Swiften/Client/CoreClient.cpp9
-rw-r--r--Swiften/Network/BOSHConnectionPool.cpp2
-rw-r--r--Swiften/Network/ChainedConnector.cpp6
-rw-r--r--Swiften/Network/ChainedConnector.h5
-rw-r--r--Swiften/Network/Connector.cpp6
-rw-r--r--Swiften/Network/Connector.h10
-rw-r--r--Swiften/Network/ProxiedConnection.cpp2
-rw-r--r--Swiften/Network/UnitTest/BOSHConnectionTest.cpp2
-rw-r--r--Swiften/Network/UnitTest/ChainedConnectorTest.cpp2
-rw-r--r--Swiften/Network/UnitTest/ConnectorTest.cpp10
10 files changed, 30 insertions, 24 deletions
diff --git a/Swiften/Client/CoreClient.cpp b/Swiften/Client/CoreClient.cpp
index 4438135..f6a3bb8 100644
--- a/Swiften/Client/CoreClient.cpp
+++ b/Swiften/Client/CoreClient.cpp
@@ -1,3 +1,3 @@
/*
- * Copyright (c) 2010-2011 Remko Tronçon
+ * Copyright (c) 2010-2014 Remko Tronçon
* Licensed under the GNU General Public License v3.
@@ -9,2 +9,3 @@
#include <boost/bind.hpp>
+#include <boost/optional.hpp>
#include <boost/smart_ptr/make_shared.hpp>
@@ -110,5 +111,9 @@ void CoreClient::connect(const ClientOptions& o) {
int port = o.manualPort;
+ boost::optional<std::string> serviceLookupPrefix;
+ if (o.manualHostname.empty()) {
+ serviceLookupPrefix = "_xmpp-client._tcp.";
+ }
assert(!connector_);
if (options.boshURL.isEmpty()) {
- connector_ = boost::make_shared<ChainedConnector>(host, port, o.manualHostname.empty(), networkFactories->getDomainNameResolver(), connectionFactories, networkFactories->getTimerFactory());
+ connector_ = boost::make_shared<ChainedConnector>(host, port, serviceLookupPrefix, networkFactories->getDomainNameResolver(), connectionFactories, networkFactories->getTimerFactory());
connector_->onConnectFinished.connect(boost::bind(&CoreClient::handleConnectorFinished, this, _1, _2));
diff --git a/Swiften/Network/BOSHConnectionPool.cpp b/Swiften/Network/BOSHConnectionPool.cpp
index 4517ffb..fdfe420 100644
--- a/Swiften/Network/BOSHConnectionPool.cpp
+++ b/Swiften/Network/BOSHConnectionPool.cpp
@@ -227,3 +227,3 @@ void BOSHConnectionPool::handleConnectionDisconnected(bool/* error*/, BOSHConnec
boost::shared_ptr<BOSHConnection> BOSHConnectionPool::createConnection() {
- Connector::ref connector = Connector::create(boshURL.getHost(), URL::getPortOrDefaultPort(boshURL), false, resolver, connectionFactory, timerFactory);
+ Connector::ref connector = Connector::create(boshURL.getHost(), URL::getPortOrDefaultPort(boshURL), boost::optional<std::string>(), resolver, connectionFactory, timerFactory);
BOSHConnection::ref connection = BOSHConnection::create(boshURL, connector, xmlParserFactory);
diff --git a/Swiften/Network/ChainedConnector.cpp b/Swiften/Network/ChainedConnector.cpp
index 8c7c04b..14d66ae 100644
--- a/Swiften/Network/ChainedConnector.cpp
+++ b/Swiften/Network/ChainedConnector.cpp
@@ -21,3 +21,3 @@ ChainedConnector::ChainedConnector(
int port,
- bool doServiceLookups,
+ const boost::optional<std::string>& serviceLookupPrefix,
DomainNameResolver* resolver,
@@ -27,3 +27,3 @@ ChainedConnector::ChainedConnector(
port(port),
- doServiceLookups(doServiceLookups),
+ serviceLookupPrefix(serviceLookupPrefix),
resolver(resolver),
@@ -64,3 +64,3 @@ void ChainedConnector::tryNextConnectionFactory() {
connectionFactoryQueue.pop_front();
- currentConnector = Connector::create(hostname, port, doServiceLookups, resolver, connectionFactory, timerFactory);
+ currentConnector = Connector::create(hostname, port, serviceLookupPrefix, resolver, connectionFactory, timerFactory);
currentConnector->setTimeoutMilliseconds(timeoutMilliseconds);
diff --git a/Swiften/Network/ChainedConnector.h b/Swiften/Network/ChainedConnector.h
index 03462bc..0a1cca9 100644
--- a/Swiften/Network/ChainedConnector.h
+++ b/Swiften/Network/ChainedConnector.h
@@ -12,2 +12,3 @@
#include <boost/shared_ptr.hpp>
+#include <boost/optional.hpp>
@@ -26,3 +27,3 @@ namespace Swift {
public:
- ChainedConnector(const std::string& hostname, int port, bool doServiceLookups, DomainNameResolver*, const std::vector<ConnectionFactory*>&, TimerFactory*);
+ ChainedConnector(const std::string& hostname, int port, const boost::optional<std::string>& serviceLookupPrefix, DomainNameResolver*, const std::vector<ConnectionFactory*>&, TimerFactory*);
@@ -42,3 +43,3 @@ namespace Swift {
int port;
- bool doServiceLookups;
+ boost::optional<std::string> serviceLookupPrefix;
DomainNameResolver* resolver;
diff --git a/Swiften/Network/Connector.cpp b/Swiften/Network/Connector.cpp
index a0155cf..a58efbc 100644
--- a/Swiften/Network/Connector.cpp
+++ b/Swiften/Network/Connector.cpp
@@ -19,3 +19,3 @@ namespace Swift {
-Connector::Connector(const std::string& hostname, int port, bool doServiceLookups, DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory) : hostname(hostname), port(port), doServiceLookups(doServiceLookups), resolver(resolver), connectionFactory(connectionFactory), timerFactory(timerFactory), timeoutMilliseconds(0), queriedAllServices(true), foundSomeDNS(false) {
+Connector::Connector(const std::string& hostname, int port, const boost::optional<std::string>& serviceLookupPrefix, DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory) : hostname(hostname), port(port), serviceLookupPrefix(serviceLookupPrefix), resolver(resolver), connectionFactory(connectionFactory), timerFactory(timerFactory), timeoutMilliseconds(0), queriedAllServices(true), foundSomeDNS(false) {
}
@@ -33,4 +33,4 @@ void Connector::start() {
queriedAllServices = false;
- if (doServiceLookups) {
- serviceQuery = resolver->createServiceQuery("_xmpp-client._tcp." + hostname);
+ if (serviceLookupPrefix) {
+ serviceQuery = resolver->createServiceQuery((*serviceLookupPrefix) + hostname);
serviceQuery->onResult.connect(boost::bind(&Connector::handleServiceQueryResult, shared_from_this(), _1));
diff --git a/Swiften/Network/Connector.h b/Swiften/Network/Connector.h
index 49ac271..16f8539 100644
--- a/Swiften/Network/Connector.h
+++ b/Swiften/Network/Connector.h
@@ -11,3 +11,3 @@
#include <boost/shared_ptr.hpp>
-
+#include <boost/optional.hpp>
#include <Swiften/Base/API.h>
@@ -30,4 +30,4 @@ namespace Swift {
- static Connector::ref create(const std::string& hostname, int port, bool doServiceLookups, DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory) {
- return ref(new Connector(hostname, port, doServiceLookups, resolver, connectionFactory, timerFactory));
+ static Connector::ref create(const std::string& hostname, int port, const boost::optional<std::string>& serviceLookupPrefix, DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory) {
+ return ref(new Connector(hostname, port, serviceLookupPrefix, resolver, connectionFactory, timerFactory));
}
@@ -41,3 +41,3 @@ namespace Swift {
private:
- Connector(const std::string& hostname, int port, bool doServiceLookups, DomainNameResolver*, ConnectionFactory*, TimerFactory*);
+ Connector(const std::string& hostname, int port, const boost::optional<std::string>& serviceLookupPrefix, DomainNameResolver*, ConnectionFactory*, TimerFactory*);
@@ -59,3 +59,3 @@ namespace Swift {
int port;
- bool doServiceLookups;
+ boost::optional<std::string> serviceLookupPrefix;
DomainNameResolver* resolver;
diff --git a/Swiften/Network/ProxiedConnection.cpp b/Swiften/Network/ProxiedConnection.cpp
index 8bf12d3..0061820 100644
--- a/Swiften/Network/ProxiedConnection.cpp
+++ b/Swiften/Network/ProxiedConnection.cpp
@@ -55,3 +55,3 @@ void ProxiedConnection::connect(const HostAddressPort& server) {
- connector_ = Connector::create(proxyHost_, proxyPort_, false, resolver_, connectionFactory_, timerFactory_);
+ connector_ = Connector::create(proxyHost_, proxyPort_, boost::optional<std::string>(), resolver_, connectionFactory_, timerFactory_);
connector_->onConnectFinished.connect(boost::bind(&ProxiedConnection::handleConnectFinished, shared_from_this(), _1));
diff --git a/Swiften/Network/UnitTest/BOSHConnectionTest.cpp b/Swiften/Network/UnitTest/BOSHConnectionTest.cpp
index 9c4bc27..0d06420 100644
--- a/Swiften/Network/UnitTest/BOSHConnectionTest.cpp
+++ b/Swiften/Network/UnitTest/BOSHConnectionTest.cpp
@@ -194,3 +194,3 @@ class BOSHConnectionTest : public CppUnit::TestFixture {
resolver->addAddress("wonderland.lit", HostAddress("127.0.0.1"));
- Connector::ref connector = Connector::create("wonderland.lit", 5280, false, resolver, connectionFactory, timerFactory);
+ Connector::ref connector = Connector::create("wonderland.lit", 5280, boost::optional<std::string>(), resolver, connectionFactory, timerFactory);
BOSHConnection::ref c = BOSHConnection::create(URL("http", "wonderland.lit", 5280, "/http-bind"), connector, &parserFactory);
diff --git a/Swiften/Network/UnitTest/ChainedConnectorTest.cpp b/Swiften/Network/UnitTest/ChainedConnectorTest.cpp
index 9abed57..9176fe7 100644
--- a/Swiften/Network/UnitTest/ChainedConnectorTest.cpp
+++ b/Swiften/Network/UnitTest/ChainedConnectorTest.cpp
@@ -128,3 +128,3 @@ class ChainedConnectorTest : public CppUnit::TestFixture {
factories.push_back(connectionFactory2);
- boost::shared_ptr<ChainedConnector> connector = boost::make_shared<ChainedConnector>("foo.com", -1, true, resolver, factories, timerFactory);
+ boost::shared_ptr<ChainedConnector> connector = boost::make_shared<ChainedConnector>("foo.com", -1, boost::optional<std::string>("_xmpp-client._tcp."), resolver, factories, timerFactory);
connector->onConnectFinished.connect(boost::bind(&ChainedConnectorTest::handleConnectorFinished, this, _1, _2));
diff --git a/Swiften/Network/UnitTest/ConnectorTest.cpp b/Swiften/Network/UnitTest/ConnectorTest.cpp
index fe18340..3b1d4e4 100644
--- a/Swiften/Network/UnitTest/ConnectorTest.cpp
+++ b/Swiften/Network/UnitTest/ConnectorTest.cpp
@@ -1,3 +1,3 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2014 Remko Tronçon
* Licensed under the GNU General Public License v3.
@@ -77,3 +77,3 @@ class ConnectorTest : public CppUnit::TestFixture {
void testConnect_NoServiceLookups() {
- Connector::ref testling(createConnector(4321, false));
+ Connector::ref testling(createConnector(4321, boost::optional<std::string>()));
resolver->addXMPPClientService("foo.com", host1);
@@ -93,3 +93,3 @@ class ConnectorTest : public CppUnit::TestFixture {
void testConnect_NoServiceLookups_DefaultPort() {
- Connector::ref testling(createConnector(-1, false));
+ Connector::ref testling(createConnector(-1, boost::optional<std::string>()));
resolver->addXMPPClientService("foo.com", host1);
@@ -314,4 +314,4 @@ class ConnectorTest : public CppUnit::TestFixture {
private:
- Connector::ref createConnector(int port = -1, bool doServiceLookups = true) {
- Connector::ref connector = Connector::create("foo.com", port, doServiceLookups, resolver, connectionFactory, timerFactory);
+ Connector::ref createConnector(int port = -1, boost::optional<std::string> serviceLookupPrefix = boost::optional<std::string>("_xmpp-client._tcp.")) {
+ Connector::ref connector = Connector::create("foo.com", port, serviceLookupPrefix, resolver, connectionFactory, timerFactory);
connector->onConnectFinished.connect(boost::bind(&ConnectorTest::handleConnectorFinished, this, _1, _2));