]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Add searchRecords and searchComments API call
authorAki Tuomi <cmouse@desteem.org>
Thu, 30 Jul 2015 13:38:57 +0000 (16:38 +0300)
committerAki Tuomi <cmouse@cmouse.fi>
Tue, 4 Aug 2015 12:26:15 +0000 (15:26 +0300)
pdns/dnsbackend.hh
pdns/ueberbackend.cc
pdns/ueberbackend.hh

index 51b4f814f09e5de2c6e7aadca178a436eb008305..3b9b8ec754abae46b53edc75d6019b8112671e8c 100644 (file)
@@ -371,6 +371,18 @@ public:
     return "directBackendCmd not supported for this backend\n";
   }
 
+  //! 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;
+  }
+
   const string& getPrefix() { return d_prefix; };
 protected:
   bool mustDo(const string &key);
index a3e3f1de34d522788abc4b23efe81497a0888400..2126a81320797894d9dd523734a97740e4482cff 100644 (file)
@@ -607,6 +607,21 @@ bool UeberBackend::list(const DNSName &target, int domain_id, bool include_disab
   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 4df70b7331a5a5ad3c0d01f6fafde828c6d7dc41..c87b132c970d371e3e16eceda9a944711d61f3d3 100644 (file)
@@ -137,6 +137,8 @@ public:
   void alsoNotifies(const DNSName &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:
   pthread_t tid;
   handle d_handle;