]> granicus.if.org Git - pdns/commitdiff
make tools compile
authorPeter van Dijk <peter.van.dijk@netherlabs.nl>
Mon, 1 Jun 2015 11:06:38 +0000 (13:06 +0200)
committermind04 <mind04@monshouwer.org>
Tue, 30 Jun 2015 06:12:43 +0000 (08:12 +0200)
pdns/nsec3dig.cc
pdns/saxfr.cc
pdns/sdig.cc

index d3bcdaa4f48eb34750ee2b2d30cfdb3e984e5abb..6860611e9f1c420b8d70a726068cdd92c8e929d8 100644 (file)
@@ -16,12 +16,12 @@ StatBag S;
 typedef std::pair<string,string> nsec3;
 typedef set<nsec3> nsec3set;
 
-string nsec3Hash(const string &qname, const string &salt, unsigned int iters)
+string nsec3Hash(const DNSName &qname, const string &salt, unsigned int iters)
 {
   return toBase32Hex(hashQNameWithSalt(iters, salt, qname));
 }
 
-void proveOrDeny(const nsec3set &nsec3s, const string &qname, const string &salt, unsigned int iters, set<string> &proven, set<string> &denied)
+void proveOrDeny(const nsec3set &nsec3s, const DNSName &qname, const string &salt, unsigned int iters, set<DNSName> &proven, set<DNSName> &denied)
 {
   string hashed = nsec3Hash(qname, salt, iters);
 
@@ -34,23 +34,23 @@ void proveOrDeny(const nsec3set &nsec3s, const string &qname, const string &salt
     if(hashed == base)
     {
       proven.insert(qname);
-      cout<<qname<<" ("<<hashed<<") proven by base of "<<base<<".."<<next<<endl;
+      cout<<qname.toString()<<" ("<<hashed<<") proven by base of "<<base<<".."<<next<<endl;
     }
     if(hashed == next)
     {
       proven.insert(qname);
-      cout<<qname<<" ("<<hashed<<") proven by next of "<<base<<".."<<next<<endl;
+      cout<<qname.toString()<<" ("<<hashed<<") proven by next of "<<base<<".."<<next<<endl;
     }
     if((hashed > base && hashed < next) ||
        (next < base && (hashed < next || hashed > base)))
     {
       denied.insert(qname);
-      cout<<qname<<" ("<<hashed<<") denied by "<<base<<".."<<next<<endl;
+      cout<<qname.toString()<<" ("<<hashed<<") denied by "<<base<<".."<<next<<endl;
     }
     if (base == next && base != hashed)
     {
       denied.insert(qname);
-      cout<<qname<<" ("<<hashed<<") denied by "<<base<<".."<<next<<endl;
+      cout<<qname.toString()<<" ("<<hashed<<") denied by "<<base<<".."<<next<<endl;
     }
   }
 }
@@ -115,13 +115,13 @@ try
   delete[] creply;
 
   MOADNSParser mdp(reply);
-  cout<<"Reply to question for qname='"<<mdp.d_qname<<"', qtype="<<DNSRecordContent::NumberToType(mdp.d_qtype)<<endl;
+  cout<<"Reply to question for qname='"<<mdp.d_qname.toString()<<"', qtype="<<DNSRecordContent::NumberToType(mdp.d_qtype)<<endl;
   cout<<"Rcode: "<<mdp.d_header.rcode<<", RD: "<<mdp.d_header.rd<<", QR: "<<mdp.d_header.qr;
   cout<<", TC: "<<mdp.d_header.tc<<", AA: "<<mdp.d_header.aa<<", opcode: "<<mdp.d_header.opcode<<endl;
 
-  set<string> names;
-  set<string> namesseen;
-  set<string> namestocheck;
+  set<DNSName> names;
+  set<DNSName> namesseen;
+  set<DNSName> namestocheck;
   nsec3set nsec3s;
   string nsec3salt;
   int nsec3iters = 0;
@@ -134,7 +134,8 @@ try
       // nsec3.insert(new nsec3()
       // cerr<<toBase32Hex(r.d_nexthash)<<endl;
       vector<string> parts;
-      boost::split(parts, i->first.d_label, boost::is_any_of("."));
+      string sname=i->first.d_label.toString();
+      boost::split(parts, sname /* FIXME */, boost::is_any_of("."));
       nsec3s.insert(make_pair(toLower(parts[0]), toBase32Hex(r.d_nexthash)));
       nsec3salt = r.d_salt;
       nsec3iters = r.d_iterations;
@@ -142,8 +143,8 @@ try
     else
     {
       // cerr<<"namesseen.insert('"<<i->first.d_label<<"')"<<endl;
-      names.insert(stripDot(i->first.d_label));
-      namesseen.insert(stripDot(i->first.d_label));
+      names.insert(i->first.d_label);
+      namesseen.insert(i->first.d_label);
     }
 
     if(i->first.d_type == QType::CNAME)
@@ -151,7 +152,7 @@ try
       namesseen.insert(stripDot(i->first.d_content->getZoneRepresentation()));
     }
 
-    cout<<i->first.d_place-1<<"\t"<<i->first.d_label<<"\tIN\t"<<DNSRecordContent::NumberToType(i->first.d_type);
+    cout<<i->first.d_place-1<<"\t"<<i->first.d_label.toString()<<"\tIN\t"<<DNSRecordContent::NumberToType(i->first.d_type);
     cout<<"\t"<<i->first.d_ttl<<"\t"<< i->first.d_content->getZoneRepresentation()<<"\n";
   }
 
@@ -167,17 +168,17 @@ try
 #endif
 
   cout<<"== nsec3 prove/deny report follows =="<<endl;
-  set<string> proven;
-  set<string> denied;
+  set<DNSName> proven;
+  set<DNSName> denied;
   namesseen.insert(stripDot(qname));
-  BOOST_FOREACH(string n, namesseen)
+  for(const auto &n: namesseen)
   {
-    string shorter(n);
+    DNSName shorter(n);
     do {
       namestocheck.insert(shorter);
-    } while(chopOff(shorter));
+    } while(shorter.chopOff());
   }
-  BOOST_FOREACH(string n, namestocheck)
+  for(const auto &n: namestocheck)
   {
     proveOrDeny(nsec3s, n, nsec3salt, nsec3iters, proven, denied);
     proveOrDeny(nsec3s, "*."+n, nsec3salt, nsec3iters, proven, denied);
@@ -194,43 +195,44 @@ try
     cout<<"qname found proven, NODATA response?"<<endl;
     exit(EXIT_SUCCESS);
   }
-  string shorter=qname;
-  string encloser;
-  string nextcloser;
-  string prev(qname);
-  while(chopOff(shorter))
+  DNSName shorter=qname;
+  DNSName encloser;
+  DNSName nextcloser;
+  DNSName prev(qname);
+  while(shorter.chopOff())
   {
     if(proven.count(shorter))
     {
       encloser=shorter;
       nextcloser=prev;
-      cout<<"found closest encloser at "<<encloser<<endl;
-      cout<<"next closer is "<<nextcloser<<endl;
+      cout<<"found closest encloser at "<<encloser.toString()<<endl;
+      cout<<"next closer is "<<nextcloser.toString()<<endl;
       break;
     }
     prev=shorter;
   }
-  if(encloser.size() && nextcloser.size())
+  if(encloser.countLabels() && nextcloser.countLabels())
   {
     if(denied.count(nextcloser))
     {
-      cout<<"next closer ("<<nextcloser<<") is denied correctly"<<endl;
+      cout<<"next closer ("<<nextcloser.toString()<<") is denied correctly"<<endl;
     }
     else
     {
-      cout<<"next closer ("<<nextcloser<<") NOT denied"<<endl;
+      cout<<"next closer ("<<nextcloser.toString()<<") NOT denied"<<endl;
     }
-    if(denied.count("*."+encloser))
+    DNSName wcplusencloser=DNSName("*")+encloser;
+    if(denied.count(wcplusencloser))
     {
-      cout<<"wildcard at encloser (*."<<encloser<<") is denied correctly"<<endl;
+      cout<<"wildcard at encloser ("<<wcplusencloser.toString()<<") is denied correctly"<<endl;
     }
-    else if(proven.count("*."+encloser))
+    else if(proven.count(wcplusencloser))
     {
-      cout<<"wildcard at encloser (*."<<encloser<<") is proven"<<endl;
+      cout<<"wildcard at encloser ("<<wcplusencloser.toString()<<") is proven"<<endl;
     }
     else
     {
-      cout<<"wildcard at encloser (*."<<encloser<<") is NOT denied or proven"<<endl;
+      cout<<"wildcard at encloser ("<<wcplusencloser.toString()<<") is NOT denied or proven"<<endl;
     }
   }
   exit(EXIT_SUCCESS);
index e572b0bcd6fc5fef0df99049258b7962283c78d1..d461921706dfcda5803527470673af6590cdf733 100644 (file)
@@ -205,9 +205,9 @@ try
 
   bool isNSEC3 = false;
   int soacount=0;
-  vector<pair<string,string> > records;
-  set<string> labels;
-  map<string,string> hashes;
+  vector<pair<DNSName,string> > records;
+  set<DNSName> labels;
+  map<string,DNSName> hashes;
   NSEC3PARAMRecordContent ns3pr;
 
   while(soacount<2) {
@@ -290,14 +290,14 @@ try
         o<<"\t"<<i->first.d_content->getZoneRepresentation();
       }
 
-      records.push_back(make_pair(stripDot(i->first.d_label),o.str()));
+      records.push_back(make_pair(i->first.d_label,o.str()));
 
-      string shorter(stripDot(i->first.d_label));
+      DNSName shorter(i->first.d_label);
       do {
         labels.insert(shorter);
         if (pdns_iequals(shorter, argv[3]))
           break;
-      }while(chopOff(shorter));
+      }while(shorter.chopOff());
 
     }
 
@@ -307,22 +307,21 @@ try
   if (isNSEC3 && unhash)
   {
     string hashed;
-    BOOST_FOREACH(const string &label, labels) {
+    for(const auto &label: labels) {
       hashed=toBase32Hex(hashQNameWithSalt(ns3pr.d_iterations, ns3pr.d_salt, label));
-      hashes.insert(pair<string,string>(hashed, label));
+      hashes.insert(pair<string,DNSName>(hashed, label));
     }
   }
 
-  pair<string,string> record;
-  BOOST_FOREACH(record, records) {
-    string label=record.first;
+  for(auto &record: records) {
+    DNSName label /* FIXME rename */=record.first;
     if (isNSEC3 && unhash)
     {
-      map<string,string>::iterator i = hashes.find(makeRelative(label, argv[3]));
+      auto i = hashes.find(makeRelative(label.toString(), argv[3]));
       if (i != hashes.end())
         label=i->second;
     }
-    cout<<label<<"."<<record.second<<endl;
+    cout<<label.toString()<<"."<<record.second<<endl;
   }
 
 }
index 5cc0d3134ea15fd5ed9029710517988809804efe..ea27919862a32532a46fab99aa41b0c40b9eb034 100644 (file)
@@ -123,12 +123,12 @@ try
     sock.recvFrom(reply, dest);
   }
   MOADNSParser mdp(reply);
-  cout<<"Reply to question for qname='"<<mdp.d_qname<<"', qtype="<<DNSRecordContent::NumberToType(mdp.d_qtype)<<endl;
+  cout<<"Reply to question for qname='"<<mdp.d_qname.toString()<<"', qtype="<<DNSRecordContent::NumberToType(mdp.d_qtype)<<endl;
   cout<<"Rcode: "<<mdp.d_header.rcode<<", RD: "<<mdp.d_header.rd<<", QR: "<<mdp.d_header.qr;
   cout<<", TC: "<<mdp.d_header.tc<<", AA: "<<mdp.d_header.aa<<", opcode: "<<mdp.d_header.opcode<<endl;
 
   for(MOADNSParser::answers_t::const_iterator i=mdp.d_answers.begin(); i!=mdp.d_answers.end(); ++i) {          
-    cout<<i->first.d_place-1<<"\t"<<i->first.d_label<<"\tIN\t"<<DNSRecordContent::NumberToType(i->first.d_type);
+    cout<<i->first.d_place-1<<"\t"<<i->first.d_label.toString()<<"\tIN\t"<<DNSRecordContent::NumberToType(i->first.d_type);
     if(i->first.d_type == QType::RRSIG) 
     {
       string zoneRep = i->first.d_content->getZoneRepresentation();