]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Add hidesoaserial option to sdig
authorRuben d'Arco <cyclops@prof-x.net>
Mon, 3 Dec 2012 04:18:04 +0000 (05:18 +0100)
committermind04 <mind04@monshouwer.org>
Fri, 12 Jul 2013 15:08:00 +0000 (17:08 +0200)
This options removes the soa-serial from sdig output. This is used because dyndns updates the serial, resulting in failing tests if we include it.

pdns/sdig.cc

index f610d0036a8705df2fbebbb29c10836a571911a0..43ad0c68f024e4fbe05e61c58d08e9ffb90e5273 100644 (file)
@@ -14,29 +14,28 @@ try
   bool recurse=false;
   bool tcp=false;
   bool showflags=false;
+  bool hidesoadetails=false;
 
   reportAllTypes();
 
   if(argc < 5) {
-    cerr<<"Syntax: sdig IP-address port question question-type [dnssec|dnssec-tcp|recurse] [showflags]\n";
+    cerr<<"Syntax: sdig IP-address port question question-type [dnssec|dnssec-tcp|recurse|hidesoadetails] [showflags]\n";
     exit(EXIT_FAILURE);
   }
 
-  // FIXME: turn recurse and dnssec into proper flags or something
-  if(argc > 5 && strcmp(argv[5], "dnssec")==0)
-  {
-    dnssec=true;
-  }
-  
-  if(argc > 5 && strcmp(argv[5], "dnssec-tcp")==0)
-  {
-    dnssec=true;
-    tcp=true;
-  }
-
-  if(argc > 5 && strcmp(argv[5], "recurse")==0)
-  {
-    recurse=true;
+  if (argc > 5) {
+    for(int i=5; i<argc; i++) {
+      if (strcmp(argv[i], "dnssec") == 0)
+        dnssec=true;
+      if (strcmp(argv[i], "recurse") == 0)
+        recurse=true;
+      if (strcmp(argv[i], "hidesoadetails") == 0)
+        hidesoadetails=true;
+      if (strcmp(argv[i], "dnssec-tcp") == 0) {
+        dnssec=true;
+        tcp=true;
+      }
+    }
   }
 
   if((argc > 5 && strcmp(argv[5], "showflags")==0) || (argc > 6 && strcmp(argv[6], "showflags")==0))
@@ -155,6 +154,13 @@ try
       stringtok(parts, zoneRep);
       cout<<"\t"<<i->first.d_ttl<<"\t"<< parts[0]<<" "<<parts[1]<<" "<<parts[2]<<" ...\n";
     }
+    else if (i->first.d_type == QType::SOA && hidesoadetails)
+    {
+      string zoneRep = i->first.d_content->getZoneRepresentation();
+      vector<string> parts;
+      stringtok(parts, zoneRep);
+      cout<<"\t"<<i->first.d_ttl<<"\t"<<parts[0]<<" "<<parts[1]<<" [serial] "<<parts[3]<<" "<<parts[4]<<" "<<parts[5]<<" "<<parts[6]<<"\n";
+    }
     else
     {
       cout<<"\t"<<i->first.d_ttl<<"\t"<< i->first.d_content->getZoneRepresentation()<<"\n";