]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Reduce nesting in UDR check
authorEnsar Sarajčić <dev@ensarsarajcic.com>
Thu, 6 Jun 2024 07:42:19 +0000 (09:42 +0200)
committerEnsar Sarajčić <dev@ensarsarajcic.com>
Thu, 6 Jun 2024 07:42:19 +0000 (09:42 +0200)
pdns/recursordist/pdns_recursor.cc

index 511f46ca712d4148ca8acd38cf413c3680e3e4ab..de564d26ad591e9dd63a0771dfbcdd0356f399f9 100644 (file)
@@ -666,24 +666,25 @@ static bool udrCheckUniqueDNSRecord(Logr::log_t nodlogger, const DNSName& dname,
 {
   bool ret = false;
   // First check the (sub)domain isn't ignored for UDR purposes
-  if (!g_udrDomainWL.check(dname)) {
-    if (record.d_place == DNSResourceRecord::ANSWER || record.d_place == DNSResourceRecord::ADDITIONAL) {
-      // Create a string that represent a triplet of (qname, qtype and RR[type, name, content])
-      std::stringstream strStream;
-      strStream << dname.toDNSStringLC() << ":" << qtype << ":" << qtype << ":" << record.d_type << ":" << record.d_name.toDNSStringLC() << ":" << record.getContent()->getZoneRepresentation();
-      if (g_udrDBp && g_udrDBp->isUniqueResponse(strStream.str())) {
-        if (g_udrLog) {
-          // This should also probably log to a dedicated file.
-          SLOG(g_log << Logger::Notice << "Unique response observed: qname=" << dname << " qtype=" << QType(qtype) << " rrtype=" << QType(record.d_type) << " rrname=" << record.d_name << " rrcontent=" << record.getContent()->getZoneRepresentation() << endl,
-               nodlogger->info(Logr::Notice, "New response observed",
-                               "qtype", Logging::Loggable(QType(qtype)),
-                               "rrtype", Logging::Loggable(QType(record.d_type)),
-                               "rrname", Logging::Loggable(record.d_name),
-                               "rrcontent", Logging::Loggable(record.getContent()->getZoneRepresentation())););
-        }
-        t_Counters.at(rec::Counter::udrCount)++;
-        ret = true;
-      }
+  if (g_udrDomainWL.check(dname)) {
+    return ret;
+  }
+  if (record.d_place == DNSResourceRecord::ANSWER || record.d_place == DNSResourceRecord::ADDITIONAL) {
+    // Create a string that represent a triplet of (qname, qtype and RR[type, name, content])
+    std::stringstream strStream;
+    strStream << dname.toDNSStringLC() << ":" << qtype << ":" << qtype << ":" << record.d_type << ":" << record.d_name.toDNSStringLC() << ":" << record.getContent()->getZoneRepresentation();
+    if (g_udrDBp && g_udrDBp->isUniqueResponse(strStream.str())) {
+      if (g_udrLog) {
+        // This should also probably log to a dedicated file.
+        SLOG(g_log << Logger::Notice << "Unique response observed: qname=" << dname << " qtype=" << QType(qtype) << " rrtype=" << QType(record.d_type) << " rrname=" << record.d_name << " rrcontent=" << record.getContent()->getZoneRepresentation() << endl,
+             nodlogger->info(Logr::Notice, "New response observed",
+                             "qtype", Logging::Loggable(QType(qtype)),
+                             "rrtype", Logging::Loggable(QType(record.d_type)),
+                             "rrname", Logging::Loggable(record.d_name),
+                             "rrcontent", Logging::Loggable(record.getContent()->getZoneRepresentation())););
+      }
+      t_Counters.at(rec::Counter::udrCount)++;
+      ret = true;
     }
   }
   return ret;