From: Bert Hubert Date: Fri, 3 May 2013 08:45:09 +0000 (+0200) Subject: make dnsbulktest able to do other queries than just 'A', plus prepare infrastructure... X-Git-Tag: auth-3.3-rc1~132 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=62921444be58d0a350c080b941d612dd0503deff;p=thirdparty%2Fpdns.git make dnsbulktest able to do other queries than just 'A', plus prepare infrastructure for simultaneous testing of different query types (should we want this) --- diff --git a/pdns/dnsbulktest.cc b/pdns/dnsbulktest.cc index cce1ffbb11..e66fc9fa2b 100644 --- a/pdns/dnsbulktest.cc +++ b/pdns/dnsbulktest.cc @@ -29,7 +29,12 @@ struct DNSResult bool seenauthsoa; }; -// = +struct TypedQuery +{ + TypedQuery(const string& name_, uint16_t type_) : name(name_), type(type_){} + string name; + uint16_t type; +}; struct SendReceive { @@ -37,8 +42,7 @@ struct SendReceive typedef DNSResult Answer; // ip int d_socket; deque d_idqueue; - - + typedef accumulator_set< double , stats packet; - DNSPacketWriter pw(packet, domain, QType::A); + DNSPacketWriter pw(packet, domain.name, domain.type); if(d_idqueue.empty()) { cerr<<"Exhausted ids!"<first.d_place == 1 && i->first.d_type == QType::A) + if(i->first.d_place == 1 && i->first.d_type == mdp.d_qtype) dr.ips.push_back(ComboAddress(i->first.d_content->getZoneRepresentation())); if(i->first.d_place == 2 && i->first.d_type == QType::SOA) { dr.seenauthsoa = 1; @@ -146,13 +150,13 @@ struct SendReceive d_idqueue.push_back(id); } - void deliverAnswer(string& domain, const DNSResult& dr, unsigned int usec) + void deliverAnswer(TypedQuery& domain, const DNSResult& dr, unsigned int usec) { (*d_acc)(usec/1000.0); // if(usec > 1000000) // cerr<<"Slow: "<()->default_value("A"), "What type to query for") ("envoutput,e", "write report in shell environment format") ; @@ -217,16 +220,24 @@ int main(int argc, char** argv) return EXIT_FAILURE; } - g_quiet = g_vm.count("quiet")>0; - g_envoutput = g_vm.count("envoutput")>0; + g_quiet = g_vm.count("quiet") > 0; + g_envoutput = g_vm.count("envoutput") > 0; + uint16_t qtype; + reportAllTypes(); + try { + qtype = DNSRecordContent::TypeToNumber(g_vm["type"].as()); + } + catch(std::exception& e) { + cerr << e.what() << endl; + return EXIT_FAILURE; + } SendReceive sr(g_vm["ip-address"].as(), g_vm["portnumber"].as()); unsigned int limit = g_vm["limit"].as(); - reportAllTypes(); - vector domains; + vector domains; - Inflighter, SendReceive> inflighter(domains, sr); + Inflighter, SendReceive> inflighter(domains, sr); inflighter.d_maxInFlight = 100; inflighter.d_timeoutSeconds = 3; string line; @@ -246,8 +257,8 @@ int main(int argc, char** argv) { continue; // this was an IP address } - domains.push_back(split.second); - domains.push_back("www."+split.second); + domains.push_back(TypedQuery(split.second, qtype)); + domains.push_back(TypedQuery("www."+split.second, qtype)); } cerr<<"Read "<