#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
{
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);
}
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) {
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";
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";
}
}