]> granicus.if.org Git - pdns/commitdiff
Add searchRecords and searchComments API call
authorAki Tuomi <cmouse@cmouse.fi>
Wed, 5 Aug 2015 15:49:07 +0000 (18:49 +0300)
committerAki Tuomi <cmouse@cmouse.fi>
Wed, 5 Aug 2015 16:09:21 +0000 (19:09 +0300)
pdns/dnsbackend.hh
pdns/ueberbackend.cc
pdns/ueberbackend.hh

index b4122b96e4bca16e76e12804a9dbf09c649b31f9..e43483fae95971dae8e728000b7a1b2977f45894 100644 (file)
@@ -381,6 +381,18 @@ public:
     return false;
   }
 
+  //! Search for records, returns true if search was done successfully.
+  virtual bool searchRecords(const string &pattern, int maxResults, vector<DNSResourceRecord>& result)
+  {
+    return false;
+  }
+
+  //! Search for comments, returns true if search was done successfully.
+  virtual bool searchComments(const string &pattern, int maxResults, vector<Comment>& result)
+  {
+    return false;
+  }
+
 protected:
   bool mustDo(const string &key);
   const string &getArg(const string &key);
index 0c48f691611629994ffa083dda0c7063ec71da44..ab3cefc9a6a43464716b5b352d540ff43f52f611 100644 (file)
@@ -618,6 +618,21 @@ bool UeberBackend::list(const string &target, int domain_id, bool include_disabl
   return false;
 }
 
+bool UeberBackend::searchRecords(const string& pattern, int maxResults, vector<DNSResourceRecord>& result)
+{
+  bool rc = false;
+  for ( vector< DNSBackend * >::iterator i = backends.begin(); result.size() < static_cast<vector<DNSResourceRecord>::size_type>(maxResults) && i != backends.end(); ++i )
+    if ((*i)->searchRecords(pattern, maxResults - result.size(), result)) rc = true;
+  return rc;
+}
+
+bool UeberBackend::searchComments(const string& pattern, int maxResults, vector<Comment>& result)
+{
+  bool rc = false;
+  for ( vector< DNSBackend * >::iterator i = backends.begin(); result.size() < static_cast<vector<Comment>::size_type>(maxResults) && i != backends.end(); ++i )
+    if ((*i)->searchComments(pattern, maxResults - result.size(), result)) rc = true;
+  return rc;
+}
 
 AtomicCounter UeberBackend::handle::instances(0);
 
index 6837ed1b72baf6eb83d63d0ae1a1bf61a6aa01e2..c9f1b264f45da06854a10f88d8e465598227cd2d 100644 (file)
@@ -153,6 +153,9 @@ public:
   void alsoNotifies(const string &domain, set<string> *ips); 
   void rediscover(string* status=0);
   void reload();
+
+  bool searchRecords(const string &pattern, int maxResults, vector<DNSResourceRecord>& result);
+  bool searchComments(const string &pattern, int maxResults, vector<Comment>& result);
 private:
   unsigned int d_cache_ttl, d_negcache_ttl;