#include "zoneparser-tng.hh"
#include "signingpipe.hh"
#include "dns_random.hh"
+#include <fstream>
#ifdef HAVE_SQLITE3
#include "ssqlite3.hh"
#include "bind-dnssec.schema.sqlite3.sql.h"
return true;
}
+void dbBench(const std::string& fname)
+{
+ ::arg().set("query-cache-ttl")="0";
+ ::arg().set("negquery-cache-ttl")="0";
+ UeberBackend B("default");
+
+ vector<string> domains;
+ if(!fname.empty()) {
+ ifstream ifs(fname.c_str());
+ if(!ifs) {
+ cerr<<"Could not open '"<<fname<<"' for reading domain names to query"<<endl;
+ }
+ string line;
+ while(getline(ifs,line)) {
+ trim(line);
+ domains.push_back(line);
+ }
+ }
+ if(domains.empty())
+ domains.push_back("powerdns.com");
+
+ int n=0;
+ DNSResourceRecord rr;
+ DTime dt;
+ dt.set();
+ unsigned int hits=0, misses=0;
+ for(; n < 10000; ++n) {
+ const string& domain = domains[random() % domains.size()];
+ B.lookup(QType(QType::NS), domain);
+ while(B.get(rr)) {
+ hits++;
+ }
+ B.lookup(QType(QType::A), boost::lexical_cast<string>(random())+"."+domain);
+ while(B.get(rr)) {
+ }
+ misses++;
+
+ }
+ cout<<0.001*dt.udiff()/n<<" millisecond/lookup"<<endl;
+ cout<<"Retrieved "<<hits<<" records, did "<<misses<<" queries which should have no match"<<endl;
+ cout<<"Packet cache reports: "<<S.read("query-cache-hit")<<" hits (should be 0) and "<<S.read("query-cache-miss") <<" misses"<<endl;
+}
+
void rectifyAllZones(DNSSECKeeper &dk)
{
UeberBackend B("default");
cerr<<"add-zone-key ZONE zsk|ksk [bits] [active|passive]"<<endl;
cerr<<" [rsasha1|rsasha256|rsasha512|gost|ecdsa256|ecdsa384]"<<endl;
cerr<<" Add a ZSK or KSK to zone and specify algo&bits"<<endl;
+ cerr<<"bench-db [filename] Bench database backend with queries, one domain per line"<<endl;
cerr<<"check-zone ZONE Check a zone for correctness"<<endl;
cerr<<"check-all-zones Check all zones for correctness"<<endl;
cerr<<"create-bind-db FNAME Create DNSSEC db for BIND backend (bind-dnssec-db)"<<endl;
UeberBackend B("default");
exit(checkZone(dk, B, cmds[1]));
}
+ else if(cmds[0] == "bench-db") {
+ dbBench(cmds.size() > 1 ? cmds[1] : "");
+ }
else if (cmds[0] == "check-all-zones") {
exit(checkAllZones(dk));
}