diff options
| author | Tobias Markmann <tm@ayena.de> | 2014-10-21 21:36:09 (GMT) | 
|---|---|---|
| committer | Tobias Markmann <tm@ayena.de> | 2014-10-21 21:46:41 (GMT) | 
| commit | e96118247793fdf4b40dc61d7ebd2c19a64939a3 (patch) | |
| tree | 8737469cdb11ddf4ad5dc333ff87055548778cc9 | |
| parent | ddebccbd59dd9cbd0c61efe55a09d74df8ec83c8 (diff) | |
| download | swift-contrib-e96118247793fdf4b40dc61d7ebd2c19a64939a3.zip swift-contrib-e96118247793fdf4b40dc61d7ebd2c19a64939a3.tar.bz2 | |
Fix libunbound support in Swiften which was broken since API change in 8ec22a9.
Test-Information:
Build for Android 4.3 (arm) and successfully ran checker in emulator VM.
Change-Id: Iedaae5df367ee86bfe2375879b0e0981deef9b0a
| -rw-r--r-- | Swiften/Network/BoostNetworkFactories.cpp | 2 | ||||
| -rwxr-xr-x | Swiften/Network/UnboundDomainNameResolver.cpp | 18 | ||||
| -rwxr-xr-x | Swiften/Network/UnboundDomainNameResolver.h | 6 | ||||
| -rw-r--r-- | Swiften/QA/NetworkTest/DomainNameResolverTest.cpp | 4 | 
4 files changed, 19 insertions, 11 deletions
| diff --git a/Swiften/Network/BoostNetworkFactories.cpp b/Swiften/Network/BoostNetworkFactories.cpp index 72e826a..870ae97 100644 --- a/Swiften/Network/BoostNetworkFactories.cpp +++ b/Swiften/Network/BoostNetworkFactories.cpp @@ -45,5 +45,5 @@ BoostNetworkFactories::BoostNetworkFactories(EventLoop* eventLoop) : eventLoop(e  #ifdef USE_UNBOUND  	// TODO: What to do about idnConverter. -	domainNameResolver = new UnboundDomainNameResolver(ioServiceThread.getIOService(), eventLoop); +	domainNameResolver = new UnboundDomainNameResolver(idnConverter, ioServiceThread.getIOService(), eventLoop);  #else  	domainNameResolver = new PlatformDomainNameResolver(idnConverter, eventLoop); diff --git a/Swiften/Network/UnboundDomainNameResolver.cpp b/Swiften/Network/UnboundDomainNameResolver.cpp index d986385..bc280eb 100755 --- a/Swiften/Network/UnboundDomainNameResolver.cpp +++ b/Swiften/Network/UnboundDomainNameResolver.cpp @@ -15,4 +15,5 @@  #include <Swiften/Base/Log.h>  #include <Swiften/EventLoop/EventLoop.h> +#include <Swiften/IDN/IDNConverter.h>  #include <Swiften/Network/DomainNameAddressQuery.h>  #include <Swiften/Network/DomainNameResolveError.h> @@ -174,5 +175,5 @@ class UnboundDomainNameAddressQuery : public DomainNameAddressQuery, public Unbo  }; -UnboundDomainNameResolver::UnboundDomainNameResolver(boost::shared_ptr<boost::asio::io_service> ioService, EventLoop* eventLoop) : ioService(ioService), ubDescriptior(*ioService), eventLoop(eventLoop) { +UnboundDomainNameResolver::UnboundDomainNameResolver(IDNConverter* idnConverter, boost::shared_ptr<boost::asio::io_service> ioService, EventLoop* eventLoop) : idnConverter(idnConverter), ioService(ioService), ubDescriptior(*ioService), eventLoop(eventLoop) {  	ubContext = ub_ctx_create();  	if(!ubContext) { @@ -187,9 +188,9 @@ UnboundDomainNameResolver::UnboundDomainNameResolver(boost::shared_ptr<boost::as  	/* read /etc/resolv.conf for DNS proxy settings (from DHCP) */  	if( (ret=ub_ctx_resolvconf(ubContext, const_cast<char*>("/etc/resolv.conf"))) != 0) { -		SWIFT_LOG(debug) << "error reading resolv.conf: " << ub_strerror(ret) << ". errno says: " << strerror(errno) << std::endl; +		SWIFT_LOG(error) << "error reading resolv.conf: " << ub_strerror(ret) << ". errno says: " << strerror(errno) << std::endl;  	}  	/* read /etc/hosts for locally supplied host addresses */  	if( (ret=ub_ctx_hosts(ubContext, const_cast<char*>("/etc/hosts"))) != 0) { -		SWIFT_LOG(debug) << "error reading hosts: " << ub_strerror(ret) << ". errno says: " << strerror(errno) << std::endl; +		SWIFT_LOG(error) << "error reading hosts: " << ub_strerror(ret) << ". errno says: " << strerror(errno) << std::endl;  	} @@ -231,10 +232,15 @@ void UnboundDomainNameResolver::processData() {  } -boost::shared_ptr<DomainNameServiceQuery> UnboundDomainNameResolver::createServiceQuery(const std::string& name) { -	return boost::make_shared<UnboundDomainNameServiceQuery>(this, ubContext, name); +boost::shared_ptr<DomainNameServiceQuery> UnboundDomainNameResolver::createServiceQuery(const std::string& serviceLookupPrefix, const std::string& domain) { +	boost::optional<std::string> encodedDomain = idnConverter->getIDNAEncoded(domain); +	std::string result; +	if (encodedDomain) { +		result = serviceLookupPrefix + *encodedDomain; +	} +	return boost::make_shared<UnboundDomainNameServiceQuery>(this, ubContext, result);  }  boost::shared_ptr<DomainNameAddressQuery> UnboundDomainNameResolver::createAddressQuery(const std::string& name) { -	return boost::make_shared<UnboundDomainNameAddressQuery>(this, ubContext, name); +	return boost::make_shared<UnboundDomainNameAddressQuery>(this, ubContext, idnConverter->getIDNAEncoded(name).get_value_or(""));  } diff --git a/Swiften/Network/UnboundDomainNameResolver.h b/Swiften/Network/UnboundDomainNameResolver.h index 0db8a66..6b78cf3 100755 --- a/Swiften/Network/UnboundDomainNameResolver.h +++ b/Swiften/Network/UnboundDomainNameResolver.h @@ -20,4 +20,5 @@ struct ub_result;  namespace Swift {  	class EventLoop; +	class IDNConverter;	  	class TimerFactory; @@ -27,8 +28,8 @@ namespace Swift {  	class UnboundDomainNameResolver : public DomainNameResolver, public EventOwner, public boost::enable_shared_from_this<UnboundDomainNameResolver> {  		public: -			UnboundDomainNameResolver(boost::shared_ptr<boost::asio::io_service> ioService, EventLoop* eventLoop); +			UnboundDomainNameResolver(IDNConverter* idnConverter, boost::shared_ptr<boost::asio::io_service> ioService, EventLoop* eventLoop);  			virtual ~UnboundDomainNameResolver(); -			virtual boost::shared_ptr<DomainNameServiceQuery> createServiceQuery(const std::string& name); +			virtual boost::shared_ptr<DomainNameServiceQuery> createServiceQuery(const std::string& serviceLookupPrefix, const std::string& domain);  			virtual boost::shared_ptr<DomainNameAddressQuery> createAddressQuery(const std::string& name); @@ -42,4 +43,5 @@ namespace Swift {  		private: +			IDNConverter* idnConverter;  			boost::shared_ptr<EventOwner> eventOwner;  			boost::shared_ptr<boost::asio::io_service> ioService; diff --git a/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp b/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp index 6d25f49..dcd2be8 100644 --- a/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp +++ b/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp @@ -56,8 +56,8 @@ class DomainNameResolverTest : public CppUnit::TestFixture {  			ioServiceThread = new BoostIOServiceThread();  			eventLoop = new DummyEventLoop(); +			idnConverter = boost::shared_ptr<IDNConverter>(PlatformIDNConverter::create());  #ifdef USE_UNBOUND -			resolver = new UnboundDomainNameResolver(ioServiceThread->getIOService(), eventLoop); +			resolver = new UnboundDomainNameResolver(idnConverter.get(), ioServiceThread->getIOService(), eventLoop);  #else -			idnConverter = boost::shared_ptr<IDNConverter>(PlatformIDNConverter::create());  			resolver = new PlatformDomainNameResolver(idnConverter.get(), eventLoop);  #endif | 
 Swift
 Swift