]> granicus.if.org Git - pdns/commitdiff
make passing empty response optional
authorDmitry Alenichev <mitya@vk.com>
Thu, 14 Feb 2019 15:02:49 +0000 (18:02 +0300)
committerDmitry Alenichev <mitya@vk.com>
Thu, 14 Feb 2019 15:02:49 +0000 (18:02 +0300)
pdns/dnsdist-lua.cc
pdns/dnsdist-web.cc
pdns/dnsdist.cc
pdns/dnsdist.hh

index 49bdde30e4a987fbcd39ad9348df2e760ba6d6a8..5af04951c8d6cd15a3c3cd97df13eb6edf24d506 100644 (file)
@@ -1761,6 +1761,8 @@ void setupLuaConfig(bool client)
         }
 #endif
       });
+
+  g_lua.writeFunction("setAllowEmptyResponse", [](bool allow) { g_allowEmptyResponse=allow; });
 }
 
 vector<std::function<void(void)>> setupLua(bool client, const std::string& config)
index 8cd977384f867510b2c38eeaed5b98d1bc786c93..82d441960fc6c2af4d35d0cbaa085992054c4920 100644 (file)
@@ -697,6 +697,7 @@ static void connectionThread(int sock, ComboAddress remote)
       typedef boost::variant<bool, double, std::string> configentry_t;
       std::vector<std::pair<std::string, configentry_t> > 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 },
index 49a0dc27a996d0eb471c7d4a312c6c2ebe10e95d..ecdace0b01ac99f641123e15cc320054ed5ba631 100644 (file)
@@ -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<NetmaskGroup> 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 {
index 8b36320f6c43ab063710875b14f913399294def5..612a96ec6603498f538c2d9ab4f6a3fe85a4e620 100644 (file)
@@ -958,6 +958,7 @@ extern bool g_useTCPSinglePipe;
 extern std::atomic<uint16_t> g_downstreamTCPCleanupInterval;
 extern size_t g_udpVectorSize;
 extern bool g_preserveTrailingData;
+extern bool g_allowEmptyResponse;
 
 #ifdef HAVE_EBPF
 extern shared_ptr<BPFFilter> g_defaultBPFFilter;