]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Refactor UeberBackend::getAuth: foundTarget
authorFred Morcos <fred.morcos@open-xchange.com>
Thu, 26 Oct 2023 12:50:20 +0000 (14:50 +0200)
committerFred Morcos <fred.morcos@open-xchange.com>
Sun, 29 Oct 2023 14:35:50 +0000 (15:35 +0100)
pdns/ueberbackend.cc

index 58dda6cf68cd1eb53b4917f04e2e11b81e5d20ab..17d81786138c49d7129ff9ad6cb51d4156cc4937 100644 (file)
@@ -433,6 +433,19 @@ static std::vector<DNSBackend*>::iterator findBestMatchingBackend(std::vector<DN
   return backend;
 }
 
+static bool foundTarget(const DNSName& target, const DNSName& shorter, const QType& qtype, SOAData* soaData, const bool found)
+{
+  auto name = soaData->qname;
+
+  if (found == (qtype == QType::DS) || target != shorter) {
+    DLOG(g_log << Logger::Error << "found: " << name << endl);
+    return true;
+  }
+
+  DLOG(g_log << Logger::Error << "chasing next: " << name << endl);
+  return false;
+}
+
 bool UeberBackend::getAuth(const DNSName& target, const QType& qtype, SOAData* soaData, bool cachedOk)
 {
   // A backend can respond to our authority request with the 'best' match it
@@ -511,14 +524,11 @@ bool UeberBackend::getAuth(const DNSName& target, const QType& qtype, SOAData* s
     }
 
   found:
-    if (found == (qtype == QType::DS) || target != shorter) {
-      DLOG(g_log << Logger::Error << "found: " << soaData->qname << endl);
+    if (foundTarget(target, shorter, qtype, soaData, found)) {
       return true;
     }
-    else {
-      DLOG(g_log << Logger::Error << "chasing next: " << soaData->qname << endl);
-      found = true;
-    }
+
+    found = true;
   } while (shorter.chopOff());
 
   return found;