From: Pieter Lexis Date: Thu, 28 Sep 2017 10:15:00 +0000 (+0200) Subject: Make lowercase-outgoing actually lowercase all q's X-Git-Tag: rec-4.1.0-rc2~38^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c1c29961a5432e2fd07236de66ef3e25b5777676;p=thirdparty%2Fpdns.git Make lowercase-outgoing actually lowercase all q's Before, we would only lowercase the original qname before handing it to SyncRes. Now the asyncresolveWrapper lowercases if it has to behor handing the qname to asyncresolve. --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 01fc6e3415..6ea920f863 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -149,7 +149,6 @@ static std::atomic statsWanted; static std::atomic g_quiet; static bool g_logCommonErrors; static bool g_anyToTcp; -static bool g_lowercaseOutgoing; static bool g_weDistributeQueries; // if true, only 1 thread listens on the incoming query sockets static bool g_reusePort{false}; static bool g_useOneSocketPerThread; @@ -162,6 +161,7 @@ RecursorControlChannel s_rcc; // only active in thread 0 RecursorStats g_stats; string s_programname="pdns_recursor"; string s_pidfname; +bool g_lowercaseOutgoing; unsigned int g_numThreads; uint16_t g_outgoingEDNSBufsize; bool g_logRPZChanges{false}; @@ -761,10 +761,6 @@ static void startDoResolve(void *p) pw.getHeader()->rd=dc->d_mdp.d_header.rd; pw.getHeader()->cd=dc->d_mdp.d_header.cd; - // DO NOT MOVE THIS CODE UP - DNSPacketWriter needs to get the original-cased version - if (g_lowercaseOutgoing) - dc->d_mdp.d_qname = dc->d_mdp.d_qname.makeLowerCase(); - uint32_t minTTL=std::numeric_limits::max(); SyncRes sr(dc->d_now); diff --git a/pdns/recursordist/test-syncres_cc.cc b/pdns/recursordist/test-syncres_cc.cc index 5c82bb41de..bce93a4ebb 100644 --- a/pdns/recursordist/test-syncres_cc.cc +++ b/pdns/recursordist/test-syncres_cc.cc @@ -19,6 +19,7 @@ RecursorStats g_stats; GlobalStateHolder g_luaconfs; thread_local std::unique_ptr t_RC{nullptr}; unsigned int g_numThreads = 1; +bool g_lowercaseOutgoing = false; /* Fake some required functions we didn't want the trouble to link with */ diff --git a/pdns/syncres.cc b/pdns/syncres.cc index e964ffc833..7e0c9da5fd 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -451,11 +451,15 @@ int SyncRes::asyncresolveWrapper(const ComboAddress& ip, bool ednsMANDATORY, con else if(ednsMANDATORY || mode==EDNSStatus::UNKNOWN || mode==EDNSStatus::EDNSOK || mode==EDNSStatus::EDNSIGNORANT) EDNSLevel = 1; + DNSName sendQname(domain); + if (g_lowercaseOutgoing) + sendQname.makeUsLowerCase(); + if (d_asyncResolve) { - ret = d_asyncResolve(ip, domain, type, doTCP, sendRDQuery, EDNSLevel, now, srcmask, ctx, luaconfsLocal->outgoingProtobufServer, res); + ret = d_asyncResolve(ip, sendQname, type, doTCP, sendRDQuery, EDNSLevel, now, srcmask, ctx, luaconfsLocal->outgoingProtobufServer, res); } else { - ret=asyncresolve(ip, domain, type, doTCP, sendRDQuery, EDNSLevel, now, srcmask, ctx, luaconfsLocal->outgoingProtobufServer, res); + ret=asyncresolve(ip, sendQname, type, doTCP, sendRDQuery, EDNSLevel, now, srcmask, ctx, luaconfsLocal->outgoingProtobufServer, res); } if(ret < 0) { return ret; // transport error, nothing to learn here diff --git a/pdns/syncres.hh b/pdns/syncres.hh index bbce7ee6a6..844d5d6891 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -947,6 +947,7 @@ extern RecursorStats g_stats; extern unsigned int g_numThreads; extern uint16_t g_outgoingEDNSBufsize; extern std::atomic g_maxCacheEntries, g_maxPacketCacheEntries; +extern bool g_lowercaseOutgoing; std::string reloadAuthAndForwards();