From: Aki Tuomi Date: Thu, 30 Jul 2015 13:38:57 +0000 (+0300) Subject: Add searchRecords and searchComments API call X-Git-Tag: dnsdist-1.0.0-alpha1~248^2~58^2~2^2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9f8e226e242a6f9e04a0f1341e12487539e7bc81;p=thirdparty%2Fpdns.git Add searchRecords and searchComments API call --- diff --git a/pdns/dnsbackend.hh b/pdns/dnsbackend.hh index 51b4f814f0..3b9b8ec754 100644 --- a/pdns/dnsbackend.hh +++ b/pdns/dnsbackend.hh @@ -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& result) + { + return false; + } + + //! Search for comments, returns true if search was done successfully. + virtual bool searchComments(const string &pattern, int maxResults, vector& result) + { + return false; + } + const string& getPrefix() { return d_prefix; }; protected: bool mustDo(const string &key); diff --git a/pdns/ueberbackend.cc b/pdns/ueberbackend.cc index a3e3f1de34..2126a81320 100644 --- a/pdns/ueberbackend.cc +++ b/pdns/ueberbackend.cc @@ -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& result) +{ + bool rc = false; + for ( vector< DNSBackend * >::iterator i = backends.begin(); result.size() < static_cast::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& result) +{ + bool rc = false; + for ( vector< DNSBackend * >::iterator i = backends.begin(); result.size() < static_cast::size_type>(maxResults) && i != backends.end(); ++i ) + if ((*i)->searchComments(pattern, maxResults - result.size(), result)) rc = true; + return rc; +} AtomicCounter UeberBackend::handle::instances(0); diff --git a/pdns/ueberbackend.hh b/pdns/ueberbackend.hh index 4df70b7331..c87b132c97 100644 --- a/pdns/ueberbackend.hh +++ b/pdns/ueberbackend.hh @@ -137,6 +137,8 @@ public: void alsoNotifies(const DNSName &domain, set *ips); void rediscover(string* status=0); void reload(); + bool searchRecords(const string &pattern, int maxResults, vector& result); + bool searchComments(const string &pattern, int maxResults, vector& result); private: pthread_t tid; handle d_handle;