From 8fc68f601b92dc4d0fa378c1d9fa2114e379f7ce Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Wed, 7 Apr 2010 20:52:52 +0200
Subject: Add support for multiple A entries to StaticDomainNameResolver.


diff --git a/Swiften/Network/StaticDomainNameResolver.cpp b/Swiften/Network/StaticDomainNameResolver.cpp
index a751fdd..196176f 100644
--- a/Swiften/Network/StaticDomainNameResolver.cpp
+++ b/Swiften/Network/StaticDomainNameResolver.cpp
@@ -38,10 +38,8 @@ namespace {
 			}
 			StaticDomainNameResolver::AddressesMap::const_iterator i = resolver->getAddresses().find(host);
 			if (i != resolver->getAddresses().end()) {
-				std::vector<HostAddress> result;
-				result.push_back(i->second);
 				MainEventLoop::postEvent(
-						boost::bind(boost::ref(onResult), result, boost::optional<DomainNameResolveError>()));
+						boost::bind(boost::ref(onResult), i->second, boost::optional<DomainNameResolveError>()));
 			}
 			else {
 				MainEventLoop::postEvent(boost::bind(boost::ref(onResult), std::vector<HostAddress>(), boost::optional<DomainNameResolveError>(DomainNameResolveError())));
@@ -60,7 +58,7 @@ StaticDomainNameResolver::StaticDomainNameResolver() : isResponsive(true) {
 }
 
 void StaticDomainNameResolver::addAddress(const String& domain, const HostAddress& address) {
-	addresses[domain] = address;
+	addresses[domain].push_back(address);
 }
 
 void StaticDomainNameResolver::addService(const String& service, const DomainNameServiceQuery::Result& result) {
@@ -76,6 +74,10 @@ void StaticDomainNameResolver::addXMPPClientService(const String& domain, const
 	addAddress(hostname, address.getAddress());
 }
 
+void StaticDomainNameResolver::addXMPPClientService(const String& domain, const String& hostname, int port) {
+	addService("_xmpp-client._tcp." + domain, ServiceQuery::Result(hostname, port, 0, 0));
+}
+
 boost::shared_ptr<DomainNameServiceQuery> StaticDomainNameResolver::createServiceQuery(const String& name) {
 	return boost::shared_ptr<DomainNameServiceQuery>(new ServiceQuery(name, this));
 }
diff --git a/Swiften/Network/StaticDomainNameResolver.h b/Swiften/Network/StaticDomainNameResolver.h
index d7e7ba4..2428d29 100644
--- a/Swiften/Network/StaticDomainNameResolver.h
+++ b/Swiften/Network/StaticDomainNameResolver.h
@@ -15,7 +15,7 @@ namespace Swift {
 
 	class StaticDomainNameResolver : public DomainNameResolver {
 		public:
-			typedef std::map<String, HostAddress> AddressesMap;
+			typedef std::map<String, std::vector<HostAddress> > AddressesMap;
 			typedef std::vector< std::pair<String, DomainNameServiceQuery::Result> > ServicesCollection;
 
 		public:
@@ -24,6 +24,7 @@ namespace Swift {
 			void addAddress(const String& domain, const HostAddress& address);
 			void addService(const String& service, const DomainNameServiceQuery::Result& result);
 			void addXMPPClientService(const String& domain, const HostAddressPort&);
+			void addXMPPClientService(const String& domain, const String& host, int port);
 
 			const AddressesMap& getAddresses() const {
 				return addresses;
-- 
cgit v0.10.2-6-g49f6