From: Aki Tuomi Date: Tue, 30 Jun 2015 05:54:46 +0000 (+0300) Subject: Implement directBackendCmd in pipe backend X-Git-Tag: dnsdist-1.0.0-alpha1~248^2~77^2~3^2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=54d8fe1f2f1d65d49b5611f33e26cae3561ee0f5;p=pdns Implement directBackendCmd in pipe backend --- diff --git a/modules/pipebackend/pipebackend.cc b/modules/pipebackend/pipebackend.cc index 2d6e9b78f..974c588e5 100644 --- a/modules/pipebackend/pipebackend.cc +++ b/modules/pipebackend/pipebackend.cc @@ -173,6 +173,33 @@ bool PipeBackend::list(const string &target, int inZoneId, bool include_disabled return true; } +string PipeBackend::directBackendCmd(const string &query) { + if (d_abiVersion < 5) + return "not supported on ABI version " + boost::lexical_cast(d_abiVersion) + "(use ABI version 5 or later)\n"; + + ostringstream oss; + + try { + ostringstream oss; + oss<<"CMD\t"<send(oss.str()); + } + catch(PDNSException &ae) { + L<receive(line); + if (line == "END") break; + oss << line << std::endl; + }; + + return oss.str(); +} + //! For the dynamic loader DNSBackend *PipeBackend::maker() { diff --git a/modules/pipebackend/pipebackend.hh b/modules/pipebackend/pipebackend.hh index fe51bfc35..e1b1edf31 100644 --- a/modules/pipebackend/pipebackend.hh +++ b/modules/pipebackend/pipebackend.hh @@ -40,7 +40,7 @@ public: void lookup(const QType &, const string &qdomain, DNSPacket *p=0, int zoneId=-1); bool list(const string &target, int domain_id, bool include_disabled=false); bool get(DNSResourceRecord &r); - + string directBackendCmd(const string &query); static DNSBackend *maker(); private: