summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2014-10-21 21:36:09 (GMT)
committerTobias Markmann <tm@ayena.de>2014-10-21 21:46:41 (GMT)
commite96118247793fdf4b40dc61d7ebd2c19a64939a3 (patch)
tree8737469cdb11ddf4ad5dc333ff87055548778cc9 /Swiften/Network
parentddebccbd59dd9cbd0c61efe55a09d74df8ec83c8 (diff)
downloadswift-e96118247793fdf4b40dc61d7ebd2c19a64939a3.zip
swift-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
Diffstat (limited to 'Swiften/Network')
-rw-r--r--Swiften/Network/BoostNetworkFactories.cpp2
-rwxr-xr-xSwiften/Network/UnboundDomainNameResolver.cpp18
-rwxr-xr-xSwiften/Network/UnboundDomainNameResolver.h6
3 files changed, 17 insertions, 9 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
@@ -44,7 +44,7 @@ BoostNetworkFactories::BoostNetworkFactories(EventLoop* eventLoop) : eventLoop(e
idnConverter = PlatformIDNConverter::create();
#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);
#endif
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
@@ -14,6 +14,7 @@
#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>
#include <Swiften/Network/DomainNameServiceQuery.h>
@@ -173,7 +174,7 @@ class UnboundDomainNameAddressQuery : public DomainNameAddressQuery, public Unbo
std::string name;
};
-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) {
SWIFT_LOG(debug) << "could not create unbound context" << std::endl;
@@ -186,11 +187,11 @@ 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;
}
ubDescriptior.assign(ub_fd(ubContext));
@@ -230,12 +231,17 @@ 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
@@ -19,6 +19,7 @@ struct ub_result;
namespace Swift {
class EventLoop;
+ class IDNConverter;
class TimerFactory;
class UnboundDomainNameResolver;
@@ -26,10 +27,10 @@ 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);
static void unbound_callback_wrapper(void* data, int err, ub_result* result);
@@ -41,6 +42,7 @@ namespace Swift {
void processData();
private:
+ IDNConverter* idnConverter;
boost::shared_ptr<EventOwner> eventOwner;
boost::shared_ptr<boost::asio::io_service> ioService;
boost::asio::posix::stream_descriptor ubDescriptior;