From: Pieter Lexis Date: Thu, 2 Nov 2017 19:46:21 +0000 (+0100) Subject: auth: make outgoing-query-address{,6} behaviour equivalent X-Git-Tag: dnsdist-1.3.0~84^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9d36589a58be32063e15aad62ff0e0f45d31175c;p=thirdparty%2Fpdns.git auth: make outgoing-query-address{,6} behaviour equivalent If either is unset, don't send out notifications or AXFR requests using that address family. --- diff --git a/pdns/mastercommunicator.cc b/pdns/mastercommunicator.cc index 456957a80d..2b6e25047a 100644 --- a/pdns/mastercommunicator.cc +++ b/pdns/mastercommunicator.cc @@ -200,12 +200,15 @@ time_t CommunicatorClass::doNotifications() try { ComboAddress remote(ip, 53); // default to 53 if((d_nsock6 < 0 && remote.sin4.sin_family == AF_INET6) || - (d_nsock4 < 0 && remote.sin4.sin_family == AF_INET)) + (d_nsock4 < 0 && remote.sin4.sin_family == AF_INET)) { + L<=0) close(locals["default4"]); + if(locals["default6"]>=0) + close(locals["default6"]); throw; } } @@ -153,6 +156,11 @@ uint16_t Resolver::sendResolve(const ComboAddress& remote, const ComboAddress& l if (local.sin4.sin_family == 0) { // up to us. sock = remote.sin4.sin_family == AF_INET ? locals["default4"] : locals["default6"]; + if (sock == -1) { + string ipv = remote.sin4.sin_family == AF_INET ? "4" : "6"; + string qla = remote.sin4.sin_family == AF_INET ? "" : "6"; + throw ResolverException("No IPv" + ipv + " socket available, is query-local-address" + qla + " unset?"); + } } else { std::string lstr = local.toString(); std::map::iterator lptr; @@ -357,15 +365,14 @@ AXFRRetriever::AXFRRetriever(const ComboAddress& remote, : d_tsigVerifier(tt, remote, d_trc), d_receivedBytes(0), d_maxReceivedBytes(maxReceivedBytes) { ComboAddress local; - if (laddr != NULL) { - local = (ComboAddress) (*laddr); + if (laddr != nullptr) { + local = ComboAddress(*laddr); } else { - if(remote.sin4.sin_family == AF_INET) + if(remote.sin4.sin_family == AF_INET && !::arg()["query-local-address"].empty()) { local=ComboAddress(::arg()["query-local-address"]); - else if(!::arg()["query-local-address6"].empty()) + } else if(remote.sin4.sin_family == AF_INET6 && !::arg()["query-local-address6"].empty()) { local=ComboAddress(::arg()["query-local-address6"]); - else - local=ComboAddress("::"); + } } d_sock = -1; try { diff --git a/pdns/rfc2136handler.cc b/pdns/rfc2136handler.cc index d6a7d64637..072cb0779a 100644 --- a/pdns/rfc2136handler.cc +++ b/pdns/rfc2136handler.cc @@ -597,12 +597,13 @@ int PacketHandler::forwardPacket(const string &msgPrefix, DNSPacket *p, DomainIn } ComboAddress local; - if(remote.sin4.sin_family == AF_INET) + if (remote.sin4.sin_family == AF_INET && !::arg()["query-local-address"].empty()) { local = ComboAddress(::arg()["query-local-address"]); - else if(!::arg()["query-local-address6"].empty()) + } else if(remote.sin4.sin_family == AF_INET6 && !::arg()["query-local-address6"].empty()) { local = ComboAddress(::arg()["query-local-address6"]); - else - local = ComboAddress("::"); + } else { + continue; + } int sock = makeQuerySocket(local, false); // create TCP socket. RFC2136 section 6.2 seems to be ok with this. if(sock < 0) { L<