From: Dmitry Alenichev Date: Thu, 14 Feb 2019 15:02:49 +0000 (+0300) Subject: make passing empty response optional X-Git-Tag: auth-4.2.0-beta1~4^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0dffe9e319dcacc725ceb621f1dbc3a1903f31d0;p=thirdparty%2Fpdns.git make passing empty response optional --- diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index 49bdde30e4..5af04951c8 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -1761,6 +1761,8 @@ void setupLuaConfig(bool client) } #endif }); + + g_lua.writeFunction("setAllowEmptyResponse", [](bool allow) { g_allowEmptyResponse=allow; }); } vector> setupLua(bool client, const std::string& config) diff --git a/pdns/dnsdist-web.cc b/pdns/dnsdist-web.cc index 8cd977384f..82d441960f 100644 --- a/pdns/dnsdist-web.cc +++ b/pdns/dnsdist-web.cc @@ -697,6 +697,7 @@ static void connectionThread(int sock, ComboAddress remote) typedef boost::variant configentry_t; std::vector > configEntries { { "acl", g_ACL.getLocal()->toString() }, + { "allow-empty-response", g_allowEmptyResponse }, { "control-socket", g_serverControl.toStringWithPort() }, { "ecs-override", g_ECSOverride }, { "ecs-source-prefix-v4", (double) g_ECSSourcePrefixV4 }, diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index 49a0dc27a9..ecdace0b01 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -87,6 +87,7 @@ uint16_t g_maxOutstanding{10240}; bool g_verboseHealthChecks{false}; uint32_t g_staleCacheEntriesTTL{0}; bool g_syslog{true}; +bool g_allowEmptyResponse{false}; GlobalStateHolder g_ACL; string g_outputBuffer; @@ -222,7 +223,7 @@ bool responseContentMatches(const char* response, const uint16_t responseLen, co } if (dh->qdcount == 0) { - if (dh->rcode != RCode::NXDomain) { + if (dh->rcode != RCode::NXDomain && g_allowEmptyResponse) { return true; } else { diff --git a/pdns/dnsdist.hh b/pdns/dnsdist.hh index 8b36320f6c..612a96ec66 100644 --- a/pdns/dnsdist.hh +++ b/pdns/dnsdist.hh @@ -958,6 +958,7 @@ extern bool g_useTCPSinglePipe; extern std::atomic g_downstreamTCPCleanupInterval; extern size_t g_udpVectorSize; extern bool g_preserveTrailingData; +extern bool g_allowEmptyResponse; #ifdef HAVE_EBPF extern shared_ptr g_defaultBPFFilter;