]> granicus.if.org Git - pdns/commitdiff
implement 'pdns.nproxy' TXT query for health checks
authorBert Hubert <bert.hubert@netherlabs.nl>
Wed, 5 Dec 2007 17:37:28 +0000 (17:37 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Wed, 5 Dec 2007 17:37:28 +0000 (17:37 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1109 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/nproxy.cc

index 00a9db3e5cdd6c76ced9f671d2c787a363c6dc1f..351a88f29a53f2771ec4f91999d97b11de733868 100644 (file)
@@ -13,7 +13,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-
+#include "dnsrecords.hh"
 #include "mplexer.hh"
 
 using namespace boost;
@@ -67,6 +67,20 @@ try
   nif.origID = mdp.d_header.id;
 
 
+  if(mdp.d_header.opcode == Opcode::Query && !mdp.d_header.qr && mdp.d_answers.empty() && mdp.d_qname == "pdns.nproxy." && mdp.d_qtype == QType::TXT) {
+    vector<uint8_t> packet;
+    DNSPacketWriter pw(packet, mdp.d_qname, mdp.d_qtype);
+    pw.getHeader()->id = mdp.d_header.id;
+    pw.getHeader()->rd = mdp.d_header.rd;
+    pw.getHeader()->qr = 1;
+
+    pw.startRecord(mdp.d_qname, QType::TXT);
+    TXTRecordContent trc("\"OK\"");
+    trc.toPacket(pw);
+    pw.commit();
+    sendto(fd, &packet[0], packet.size(), 0, (struct sockaddr*)&nif.source, sizeof(nif.source));
+    return;
+  }
 
   if(mdp.d_header.opcode != Opcode::Notify || mdp.d_qtype != QType::SOA) {
     syslogFmt(boost::format("Received non-notification packet for domain '%s' from external nameserver %s") % nif.domain % nif.source.toStringWithPort());
@@ -158,6 +172,7 @@ void daemonize();
 int main(int argc, char** argv)
 try
 {
+  reportAllTypes();
   openlog("nproxy", LOG_NDELAY | LOG_PID, LOG_DAEMON);
 
   po::options_description desc("Allowed options");