]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
add hidettl flag to sdig 3577/head
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Tue, 15 Mar 2016 14:44:10 +0000 (15:44 +0100)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Tue, 15 Mar 2016 14:44:10 +0000 (15:44 +0100)
pdns/sdig.cc

index 4bb7a9ec9c37fab8130e089bb2083591b8a2980a..231a5c688410b28e97773917b1898d6615ba8a1d 100644 (file)
 #include "ednssubnet.hh"
 StatBag S;
 
+bool hidettl=false;
+
+string ttl(uint32_t ttl)
+{
+  if(hidettl)
+    return "[ttl]";
+  else
+    return std::to_string(ttl);
+}
+
 int main(int argc, char** argv)
 try
 {
@@ -24,7 +34,7 @@ try
   reportAllTypes();
 
   if(argc < 5) {
-    cerr<<"Syntax: sdig IP-address port question question-type [dnssec] [recurse] [showflags] [hidesoadetails] [tcp] [ednssubnet SUBNET]\n";
+    cerr<<"Syntax: sdig IP-address port question question-type [dnssec] [recurse] [showflags] [hidesoadetails] [hidettl] [tcp] [ednssubnet SUBNET]\n";
     exit(EXIT_FAILURE);
   }
 
@@ -38,6 +48,8 @@ try
         showflags=true;
       if (strcmp(argv[i], "hidesoadetails") == 0)
         hidesoadetails=true;
+      if (strcmp(argv[i], "hidettl") == 0)
+        hidettl=true;
       if (strcmp(argv[i], "tcp") == 0)
         tcp=true;
       if (strcmp(argv[i], "ednssubnet") == 0) {
@@ -127,14 +139,14 @@ try
       string zoneRep = i->first.d_content->getZoneRepresentation();
       vector<string> parts;
       stringtok(parts, zoneRep);
-      cout<<"\t"<<i->first.d_ttl<<"\t"<< parts[0]<<" "<<parts[1]<<" "<<parts[2]<<" "<<parts[3]<<" [expiry] [inception] [keytag] "<<parts[7]<<" ...\n";
+      cout<<"\t"<<ttl(i->first.d_ttl)<<"\t"<< parts[0]<<" "<<parts[1]<<" "<<parts[2]<<" "<<parts[3]<<" [expiry] [inception] [keytag] "<<parts[7]<<" ...\n";
     }
     else if(!showflags && i->first.d_type == QType::NSEC3)
     {
       string zoneRep = i->first.d_content->getZoneRepresentation();
       vector<string> parts;
       stringtok(parts, zoneRep);
-      cout<<"\t"<<i->first.d_ttl<<"\t"<< parts[0]<<" [flags] "<<parts[2]<<" "<<parts[3]<<" "<<parts[4];
+      cout<<"\t"<<ttl(i->first.d_ttl)<<"\t"<< parts[0]<<" [flags] "<<parts[2]<<" "<<parts[3]<<" "<<parts[4];
       for(vector<string>::iterator iter = parts.begin()+5; iter != parts.end(); ++iter)
         cout<<" "<<*iter;
       cout<<"\n";
@@ -144,18 +156,18 @@ try
       string zoneRep = i->first.d_content->getZoneRepresentation();
       vector<string> parts;
       stringtok(parts, zoneRep);
-      cout<<"\t"<<i->first.d_ttl<<"\t"<< parts[0]<<" "<<parts[1]<<" "<<parts[2]<<" ...\n";
+      cout<<"\t"<<ttl(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";
+      cout<<"\t"<<ttl(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";
+      cout<<"\t"<<ttl(i->first.d_ttl)<<"\t"<< i->first.d_content->getZoneRepresentation()<<"\n";
     }
 
   }