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/UnboundDomainNameResolver.cpp
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/UnboundDomainNameResolver.cpp')
-rwxr-xr-xSwiften/Network/UnboundDomainNameResolver.cpp18
1 files changed, 12 insertions, 6 deletions
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(""));
}
}