From: Fred Morcos Date: Wed, 13 Dec 2023 13:52:02 +0000 (+0100) Subject: Some cleanups in dnsbulktest.cc and dnstcpbench.cc X-Git-Tag: auth-4.9.0-alpha1~24^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ba2b8a7ac4388364deccb1cb09661166d2359f3e;p=thirdparty%2Fpdns.git Some cleanups in dnsbulktest.cc and dnstcpbench.cc --- diff --git a/pdns/dnsbulktest.cc b/pdns/dnsbulktest.cc index 2f6d264fa6..fd1f6173f2 100644 --- a/pdns/dnsbulktest.cc +++ b/pdns/dnsbulktest.cc @@ -139,7 +139,7 @@ struct SendReceive return pw.getHeader()->id; } - bool receive(Identifier& id, DNSResult& dr) + bool receive(Identifier& iden, DNSResult& dnsResult) { if (waitForData(d_socket.getHandle(), 0, 500000) > 0) { // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init): no need to initialize the buffer @@ -154,30 +154,31 @@ struct SendReceive // parse packet, set 'id', fill out 'ip' MOADNSParser mdp(false, string(buf.data(), static_cast(len))); - if(!g_quiet) { - cout<<"Reply to question for qname='"<first.d_place == 1 && i->first.d_type == mdp.d_qtype) - dr.ips.push_back(ComboAddress(i->first.getContent()->getZoneRepresentation())); - if(i->first.d_place == 2 && i->first.d_type == QType::SOA) { - dr.seenauthsoa = true; + dnsResult.rcode = mdp.d_header.rcode; + for (auto i = mdp.d_answers.begin(); i != mdp.d_answers.end(); ++i) { + if (i->first.d_place == 1 && i->first.d_type == mdp.d_qtype) { + dnsResult.ips.emplace_back(i->first.getContent()->getZoneRepresentation()); } - if(!g_quiet) - { - cout<first.d_place-1<<"\t"<first.d_name<<"\tIN\t"<first.d_type); - cout<<"\t"<first.d_ttl<<"\t"<< i->first.getContent()->getZoneRepresentation()<<"\n"; + if (i->first.d_place == 2 && i->first.d_type == QType::SOA) { + dnsResult.seenauthsoa = true; + } + if (!g_quiet) { + cout << i->first.d_place - 1 << "\t" << i->first.d_name << "\tIN\t" << DNSRecordContent::NumberToType(i->first.d_type); + cout << "\t" << i->first.d_ttl << "\t" << i->first.getContent()->getZoneRepresentation() << "\n"; } } - id = mdp.d_header.id; - d_idqueue.push_back(id); + iden = mdp.d_header.id; + d_idqueue.push_back(iden); return true; } + return false; } @@ -189,30 +190,34 @@ struct SendReceive d_idqueue.push_back(id); } - void deliverAnswer(TypedQuery& domain, const DNSResult& dr, unsigned int usec) + void deliverAnswer(TypedQuery& domain, const DNSResult& dnsResult, unsigned int usec) { - (*d_acc)(usec/1000.0); -// if(usec > 1000000) - // cerr<<"Slow: "< 1000000) + // cerr<<"Slow: "<