]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Display non-zero opcodes in grepq()
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 4 Jul 2019 11:41:01 +0000 (13:41 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 4 Jul 2019 11:41:02 +0000 (13:41 +0200)
pdns/dns.cc
pdns/dns.hh
pdns/dnsdist-lua-inspection.cc

index 5d40735649236b038c5c53b38812d0d94d6b5363..420db9247b57556bf1936df4a0a14517b98f51a1 100644 (file)
@@ -69,6 +69,16 @@ std::string ERCode::to_s(uint8_t rcode) {
   return RCode::rcodes_s[rcode];
 }
 
+std::string Opcode::to_s(uint8_t opcode) {
+  static std::vector<std::string> s_opcodes = { "Query", "IQuery", "Status", "3", "Notify", "Update" };
+
+  if (opcode >= s_opcodes.size()) {
+    return std::to_string(opcode);
+  }
+
+  return s_opcodes.at(opcode);
+}
+
 class BoundsCheckingPointer
 {
 public:
index 53554ee509070e64ae7d134f6725cdb0583f9194..adc8536dbe247d06d1ee76082017675887c30bfc 100644 (file)
@@ -71,6 +71,7 @@ class Opcode
 {
 public:
   enum { Query=0, IQuery=1, Status=2, Notify=4, Update=5 };
+  static std::string to_s(uint8_t opcode);
 };
 
 // enum for policy decisions, used by both auth and recursor. Not all values supported everywhere.
index 25d9a187d3acd45da71d1dea8e67a797e44bfe26..3bed0722e99159fc166ea965a40a4b6157277277 100644 (file)
@@ -439,7 +439,7 @@ void setupLuaInspection()
 
       std::multimap<struct timespec, string> out;
 
-      boost::format      fmt("%-7.1f %-47s %-12s %-5d %-25s %-5s %-6.1f %-2s %-2s %-2s %s\n");
+      boost::format      fmt("%-7.1f %-47s %-12s %-5d %-25s %-5s %-6.1f %-2s %-2s %-2s %-s\n");
       g_outputBuffer+= (fmt % "Time" % "Client" % "Server" % "ID" % "Name" % "Type" % "Lat." % "TC" % "RD" % "AA" % "Rcode").str();
 
       if(msec==-1) {
@@ -451,7 +451,11 @@ void setupLuaInspection()
             dnmatch = c.name.isPartOf(*dn);
           if(nmmatch && dnmatch) {
             QType qt(c.qtype);
-            out.insert(make_pair(c.when, (fmt % DiffTime(now, c.when) % c.requestor.toStringWithPort() % "" % htons(c.dh.id) % c.name.toString() % qt.getName()  % "" % (c.dh.tc ? "TC" : "") % (c.dh.rd? "RD" : "") % (c.dh.aa? "AA" : "") %  "Question").str() )) ;
+            std::string extra;
+            if (c.dh.opcode != 0) {
+              extra = " (" + Opcode::to_s(c.dh.opcode) + ")";
+            }
+            out.insert(make_pair(c.when, (fmt % DiffTime(now, c.when) % c.requestor.toStringWithPort() % "" % htons(c.dh.id) % c.name.toString() % qt.getName()  % "" % (c.dh.tc ? "TC" : "") % (c.dh.rd? "RD" : "") % (c.dh.aa? "AA" : "") % ("Question" + extra)).str() )) ;
 
             if(limit && *limit==++num)
               break;