]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Simplified getClientPolicy()
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 4 Aug 2020 08:46:46 +0000 (10:46 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 24 Aug 2020 14:51:09 +0000 (16:51 +0200)
pdns/filterpo.cc

index 4e9ac6bc8ec0362ac5d9b8b86fab6533c427d14d..4b329734b93e0985161ea8ca8f49c27b21794c39 100644 (file)
@@ -200,41 +200,13 @@ bool DNSFilterEngine::getProcessingPolicy(const ComboAddress& address, const std
 
 bool DNSFilterEngine::getClientPolicy(const ComboAddress& ca, const std::unordered_map<std::string,bool>& discardedPolicies, Policy& pol) const
 {
-  // cout<<"Got question for "<<qname<<" from "<<ca.toString()<<endl;
-  std::vector<bool> zoneEnabled(d_zones.size());
-  size_t count = 0;
-  bool allEmpty = true;
+  // cout<<"Got question from "<<ca.toString()<<endl;
   for (const auto& z : d_zones) {
-    bool enabled = true;
     if (z->getPriority() >= pol.getPriority()) {
-      enabled = false;
-    } else {
-      const auto& zoneName = z->getName();
-      if (discardedPolicies.find(zoneName) != discardedPolicies.end()) {
-        enabled = false;
-      }
-      else {
-        if (z->hasClientPolicies()) {
-          allEmpty = false;
-        }
-        else {
-          enabled = false;
-        }
-      }
+      break;
     }
-
-    zoneEnabled[count] = enabled;
-    ++count;
-  }
-
-  if (allEmpty) {
-    return false;
-  }
-
-  count = 0;
-  for (const auto& z : d_zones) {
-    if (!zoneEnabled[count]) {
-      ++count;
+    const auto& zoneName = z->getName();
+    if (discardedPolicies.find(zoneName) != discardedPolicies.end()) {
       continue;
     }
 
@@ -242,10 +214,7 @@ bool DNSFilterEngine::getClientPolicy(const ComboAddress& ca, const std::unorder
       // cerr<<"Had a hit on the IP address ("<<ca.toString()<<") of the client"<<endl;
       return true;
     }
-
-    ++count;
   }
-
   return false;
 }