]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Catch an error in wipe-cache 3681/head
authorPieter Lexis <pieter.lexis@powerdns.com>
Fri, 8 Apr 2016 07:27:01 +0000 (09:27 +0200)
committerPieter Lexis <pieter.lexis@powerdns.com>
Fri, 8 Apr 2016 12:20:40 +0000 (14:20 +0200)
When an invalid DNSName is encountered, we do not wipe anything from the
cache.

Also update the manpage.

Closes #3645

docs/manpages/rec_control.1.md
pdns/rec_channel_rec.cc

index 2d2ce201a69038ffac06763211dcd409c2bd224c..b86ebaba0f4a9f8565731e18e4c74232b9c2474b 100644 (file)
@@ -113,20 +113,17 @@ version
 :    Report running version.
 
 wipe-cache *DOMAIN* [*DOMAIN*] [...]
-:    Wipe entries for *DOMAIN* from the cache. This is useful if, for example,
-     an important server has a new IP address, but the TTL has not yet
-     expired. Multiple domain names can be passed. Note that you must
-     terminate a domain with a .!  So to wipe powerdns.org, issue
-     'rec_control wipe-cache powerdns.org.'.
-     Versions beyond 3.1 don't need the trailing dot. Consider not only
-     wiping 'www.domain.com.' but also 'domain.com.', as the cached nameservers
-     or target of CNAME may continue to be undesired.
+:    Wipe entries for *DOMAIN* (exact name match) from the cache. This is useful
+     if, for example, an important server has a new IP address, but the TTL has
+     not yet expired. Multiple domain names can be passed. *DOMAIN* can be
+     suffixed with a '$' to delete the whole tree from the cache. i.e. 'powerdns.com$'
+     will remove all cached entries under and including the powerdns.com name.
 
 # BUGS
 None known. File new ones at https://github.com/PowerDNS/pdns/issues.
 
 # RESOURCES
-Website: http://wiki.powerdns.com, http://www.powerdns.com
+Website: https://docs.powerdns.com, https://www.powerdns.com
 
 # SEE ALSO
 pdns_recursor(1)
index 6e94c88d10b1d977683c36a9855abf677600ba4c..56b5ed8fff6624afc8cb0563e6240924d9a4bc00 100644 (file)
@@ -294,20 +294,29 @@ uint64_t* pleaseWipeAndCountNegCache(const DNSName& canon, bool subtree)
 template<typename T>
 string doWipeCache(T begin, T end)
 {
-  int count=0, pcount=0, countNeg=0;
+  vector<pair<DNSName, bool> > toWipe;
   for(T i=begin; i != end; ++i) {
     DNSName canon;
     bool subtree=false;
-    if(boost::ends_with(*i, "$")) {
-      canon=DNSName(i->substr(0, i->size()-1));
-      subtree=true;
+
+    try {
+      if(boost::ends_with(*i, "$")) {
+        canon=DNSName(i->substr(0, i->size()-1));
+        subtree=true;
+      } else {
+        canon=DNSName(*i);
+      }
+    } catch (std::exception &e) {
+      return "Error: " + std::string(e.what()) + ", nothing wiped\n";
     }
-    else 
-      canon=DNSName(*i);
-    
-    count+= broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeCache, canon, subtree));
-    pcount+= broadcastAccFunction<uint64_t>(boost::bind(pleaseWipePacketCache, canon, subtree));
-    countNeg+=broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeAndCountNegCache, canon, subtree));
+    toWipe.push_back({canon, subtree});
+  }
+
+  int count=0, pcount=0, countNeg=0;
+  for (auto wipe : toWipe) {
+    count+= broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeCache, wipe.first, wipe.second));
+    pcount+= broadcastAccFunction<uint64_t>(boost::bind(pleaseWipePacketCache, wipe.first, wipe.second));
+    countNeg+=broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeAndCountNegCache, wipe.first, wipe.second));
   }
 
   return "wiped "+std::to_string(count)+" records, "+std::to_string(countNeg)+" negative records, "+std::to_string(pcount)+" packets\n";