diff --git a/src/net/dns.cc b/src/net/dns.cc index 79ee7ec7990..2a7fac90056 100644 --- a/src/net/dns.cc +++ b/src/net/dns.cc @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -595,7 +596,10 @@ dns_resolver::impl::get_host_by_addr(inet_address addr) { dns_call call(*this); - ares_gethostbyaddr(_channel, p->addr.data(), p->addr.size(), int(p->addr.in_family()), [](void* arg, int status, int timeouts, ::hostent* host) { + // c-ares 1.34.7 constified the hostent argument to ares_host_callback (upstream + // PR #1060), but 1.34.8 reverted it. Rather than key on the version, use a template + // that matches both variants. + ares_gethostbyaddr(_channel, p->addr.data(), p->addr.size(), int(p->addr.in_family()), [](void* arg, int status, int timeouts, std::convertible_to auto host) { // we do potentially allocating operations below, so wrap the pointer in a // unique here. std::unique_ptr p(reinterpret_cast(arg));