Skip to content

Commit

Permalink
common: remove position from MOADNSParser::answers_t, it it used nowhere
Browse files Browse the repository at this point in the history
  • Loading branch information
omoerbeek committed Jul 22, 2024
1 parent b9c3883 commit 7123e83
Show file tree
Hide file tree
Showing 26 changed files with 201 additions and 201 deletions.
6 changes: 3 additions & 3 deletions pdns/axfr-retriever.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ int AXFRRetriever::getChunk(Resolver::res_t &res, vector<DNSRecord>* records, ui

if (!err) {
for(const auto& answer : mdp.d_answers)
if (answer.first.d_type == QType::SOA)
if (answer.d_type == QType::SOA)

Check warning on line 152 in pdns/axfr-retriever.cc

View workflow job for this annotation

GitHub Actions / Analyze (cpp, rec)

statement should be inside braces (readability-braces-around-statements - Level=Warning)
d_soacount++;
}
}
Expand All @@ -158,11 +158,11 @@ int AXFRRetriever::getChunk(Resolver::res_t &res, vector<DNSRecord>* records, ui
records->reserve(mdp.d_answers.size());

for(auto& r: mdp.d_answers) {
if (r.first.d_type == QType::SOA) {
if (r.d_type == QType::SOA) {
d_soacount++;
}

records->push_back(std::move(r.first));
records->push_back(std::move(r));
}
}

Expand Down
10 changes: 5 additions & 5 deletions pdns/dnsbulktest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,15 @@ struct SendReceive
}
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 (i->d_place == 1 && i->d_type == mdp.d_qtype) {
dnsResult.ips.emplace_back(i->getContent()->getZoneRepresentation());
}
if (i->first.d_place == 2 && i->first.d_type == QType::SOA) {
if (i->d_place == 2 && i->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";
cout << i->d_place - 1 << "\t" << i->d_name << "\tIN\t" << DNSRecordContent::NumberToType(i->d_type);
cout << "\t" << i->d_ttl << "\t" << i->getContent()->getZoneRepresentation() << "\n";
}
}

Expand Down
8 changes: 4 additions & 4 deletions pdns/dnsdistdist/dnsdist-tcp-downstream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,11 @@ static bool getSerialFromIXFRQuery(TCPQuery& query)
MOADNSParser parser(true, reinterpret_cast<const char*>(query.d_buffer.data() + sizeof(uint16_t) + proxyPayloadSize), payloadSize);

for (const auto& record : parser.d_answers) {
if (record.first.d_place != DNSResourceRecord::AUTHORITY || record.first.d_class != QClass::IN || record.first.d_type != QType::SOA) {
if (record.d_place != DNSResourceRecord::AUTHORITY || record.d_class != QClass::IN || record.d_type != QType::SOA) {
return false;
}

auto unknownContent = getRR<UnknownRecordContent>(record.first);
auto unknownContent = getRR<UnknownRecordContent>(record);
if (!unknownContent) {
return false;
}
Expand Down Expand Up @@ -815,11 +815,11 @@ bool TCPConnectionToBackend::isXFRFinished(const TCPResponse& response, TCPQuery
}
else {
for (const auto& record : parser.d_answers) {
if (record.first.d_class != QClass::IN || record.first.d_type != QType::SOA) {
if (record.d_class != QClass::IN || record.d_type != QType::SOA) {
continue;
}

auto unknownContent = getRR<UnknownRecordContent>(record.first);
auto unknownContent = getRR<UnknownRecordContent>(record);
if (!unknownContent) {
continue;
}
Expand Down
74 changes: 37 additions & 37 deletions pdns/dnsdistdist/test-dnsdist-dnsparser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ BOOST_AUTO_TEST_CASE(test_Response)
BOOST_CHECK_EQUAL(mdp.d_header.arcount, 2U);

BOOST_REQUIRE_EQUAL(mdp.d_answers.size(), 3U);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_type, static_cast<uint16_t>(QType::A));
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_class, QClass::IN);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_name, newTarget);
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).first.d_type, static_cast<uint16_t>(QType::AAAA));
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).first.d_class, QClass::IN);
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).first.d_name, newTarget);
BOOST_CHECK_EQUAL(mdp.d_answers.at(2).first.d_type, static_cast<uint16_t>(QType::OPT));
BOOST_CHECK_EQUAL(mdp.d_answers.at(2).first.d_name, g_rootdnsname);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_type, static_cast<uint16_t>(QType::A));
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_class, QClass::IN);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_name, newTarget);
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).d_type, static_cast<uint16_t>(QType::AAAA));
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).d_class, QClass::IN);
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).d_name, newTarget);
BOOST_CHECK_EQUAL(mdp.d_answers.at(2).d_type, static_cast<uint16_t>(QType::OPT));
BOOST_CHECK_EQUAL(mdp.d_answers.at(2).d_name, g_rootdnsname);
}

{
Expand Down Expand Up @@ -156,14 +156,14 @@ BOOST_AUTO_TEST_CASE(test_Response)
BOOST_CHECK_EQUAL(mdp.d_header.arcount, 2U);

BOOST_REQUIRE_EQUAL(mdp.d_answers.size(), 3U);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_type, static_cast<uint16_t>(QType::A));
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_class, QClass::IN);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_name, newTarget);
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).first.d_type, static_cast<uint16_t>(QType::AAAA));
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).first.d_class, QClass::IN);
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).first.d_name, notTheTarget);
BOOST_CHECK_EQUAL(mdp.d_answers.at(2).first.d_type, static_cast<uint16_t>(QType::OPT));
BOOST_CHECK_EQUAL(mdp.d_answers.at(2).first.d_name, g_rootdnsname);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_type, static_cast<uint16_t>(QType::A));
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_class, QClass::IN);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_name, newTarget);
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).d_type, static_cast<uint16_t>(QType::AAAA));
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).d_class, QClass::IN);
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).d_name, notTheTarget);
BOOST_CHECK_EQUAL(mdp.d_answers.at(2).d_type, static_cast<uint16_t>(QType::OPT));
BOOST_CHECK_EQUAL(mdp.d_answers.at(2).d_name, g_rootdnsname);
}

{
Expand Down Expand Up @@ -194,18 +194,18 @@ BOOST_AUTO_TEST_CASE(test_Response)
BOOST_CHECK_EQUAL(mdp.d_header.arcount, 1U);

BOOST_REQUIRE_EQUAL(mdp.d_answers.size(), 3U);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_type, static_cast<uint16_t>(QType::CNAME));
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_class, QClass::IN);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_name, newTarget);
auto content = getRR<UnknownRecordContent>(mdp.d_answers.at(0).first);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_type, static_cast<uint16_t>(QType::CNAME));
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_class, QClass::IN);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_name, newTarget);
auto content = getRR<UnknownRecordContent>(mdp.d_answers.at(0));
BOOST_REQUIRE(content != nullptr);
BOOST_CHECK_EQUAL(content->getRawContent().size(), notTheTarget.getStorage().size());

BOOST_CHECK_EQUAL(mdp.d_answers.at(1).first.d_type, static_cast<uint16_t>(QType::A));
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).first.d_class, QClass::IN);
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).first.d_name, notTheTarget);
BOOST_CHECK_EQUAL(mdp.d_answers.at(2).first.d_type, static_cast<uint16_t>(QType::OPT));
BOOST_CHECK_EQUAL(mdp.d_answers.at(2).first.d_name, g_rootdnsname);
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).d_type, static_cast<uint16_t>(QType::A));
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).d_class, QClass::IN);
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).d_name, notTheTarget);
BOOST_CHECK_EQUAL(mdp.d_answers.at(2).d_type, static_cast<uint16_t>(QType::OPT));
BOOST_CHECK_EQUAL(mdp.d_answers.at(2).d_name, g_rootdnsname);
}

{
Expand Down Expand Up @@ -259,11 +259,11 @@ BOOST_AUTO_TEST_CASE(test_Response)

BOOST_REQUIRE_EQUAL(mdp.d_answers.size(), 7U);
for (const auto& answer : mdp.d_answers) {
if (answer.first.d_type == QType::OPT) {
if (answer.d_type == QType::OPT) {
continue;
}
BOOST_CHECK_EQUAL(answer.first.d_class, QClass::IN);
BOOST_CHECK_EQUAL(answer.first.d_name, newTarget);
BOOST_CHECK_EQUAL(answer.d_class, QClass::IN);
BOOST_CHECK_EQUAL(answer.d_name, newTarget);
}
}

Expand Down Expand Up @@ -322,11 +322,11 @@ BOOST_AUTO_TEST_CASE(test_Response)

BOOST_REQUIRE_EQUAL(mdp.d_answers.size(), 8U);
for (const auto& answer : mdp.d_answers) {
if (answer.first.d_type == QType::OPT) {
if (answer.d_type == QType::OPT) {
continue;
}
BOOST_CHECK_EQUAL(answer.first.d_class, QClass::IN);
BOOST_CHECK_EQUAL(answer.first.d_name, target);
BOOST_CHECK_EQUAL(answer.d_class, QClass::IN);
BOOST_CHECK_EQUAL(answer.d_name, target);
}
}

Expand All @@ -344,11 +344,11 @@ BOOST_AUTO_TEST_CASE(test_Response)

BOOST_REQUIRE_EQUAL(mdp.d_answers.size(), 8U);
for (const auto& answer : mdp.d_answers) {
if (answer.first.d_type == QType::OPT) {
if (answer.d_type == QType::OPT) {
continue;
}
BOOST_CHECK_EQUAL(answer.first.d_class, QClass::IN);
BOOST_CHECK_EQUAL(answer.first.d_name, newTarget);
BOOST_CHECK_EQUAL(answer.d_class, QClass::IN);
BOOST_CHECK_EQUAL(answer.d_name, newTarget);
}
}
}
Expand Down Expand Up @@ -377,9 +377,9 @@ BOOST_AUTO_TEST_CASE(test_Response)
BOOST_CHECK_EQUAL(mdp.d_header.arcount, 1U);

BOOST_REQUIRE_EQUAL(mdp.d_answers.size(), 2U);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_type, static_cast<uint16_t>(QType::ALIAS));
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_class, QClass::IN);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_name, target);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_type, static_cast<uint16_t>(QType::ALIAS));
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_class, QClass::IN);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_name, target);
}
}

Expand Down
68 changes: 34 additions & 34 deletions pdns/dnsdistdist/test-dnsdist_cc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1987,9 +1987,9 @@ BOOST_AUTO_TEST_CASE(test_setNegativeAndAdditionalSOA)
BOOST_CHECK_EQUAL(mdp.d_header.nscount, 0U);
BOOST_CHECK_EQUAL(mdp.d_header.arcount, 1U);
BOOST_REQUIRE_EQUAL(mdp.d_answers.size(), 1U);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_type, static_cast<uint16_t>(QType::SOA));
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_class, QClass::IN);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_name, DNSName("zone."));
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_type, static_cast<uint16_t>(QType::SOA));
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_class, QClass::IN);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_name, DNSName("zone."));
}
{
/* now with incoming EDNS */
Expand All @@ -2010,11 +2010,11 @@ BOOST_AUTO_TEST_CASE(test_setNegativeAndAdditionalSOA)
BOOST_CHECK_EQUAL(mdp.d_header.nscount, 0U);
BOOST_CHECK_EQUAL(mdp.d_header.arcount, 2U);
BOOST_REQUIRE_EQUAL(mdp.d_answers.size(), 2U);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_type, static_cast<uint16_t>(QType::SOA));
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_class, QClass::IN);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_name, DNSName("zone."));
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).first.d_type, static_cast<uint16_t>(QType::OPT));
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).first.d_name, g_rootdnsname);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_type, static_cast<uint16_t>(QType::SOA));
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_class, QClass::IN);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_name, DNSName("zone."));
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).d_type, static_cast<uint16_t>(QType::OPT));
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).d_name, g_rootdnsname);
}

/* test No Data */
Expand All @@ -2037,9 +2037,9 @@ BOOST_AUTO_TEST_CASE(test_setNegativeAndAdditionalSOA)
BOOST_CHECK_EQUAL(mdp.d_header.nscount, 0U);
BOOST_CHECK_EQUAL(mdp.d_header.arcount, 1U);
BOOST_REQUIRE_EQUAL(mdp.d_answers.size(), 1U);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_type, static_cast<uint16_t>(QType::SOA));
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_class, QClass::IN);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_name, DNSName("zone."));
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_type, static_cast<uint16_t>(QType::SOA));
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_class, QClass::IN);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_name, DNSName("zone."));
}
{
/* now with incoming EDNS */
Expand All @@ -2060,11 +2060,11 @@ BOOST_AUTO_TEST_CASE(test_setNegativeAndAdditionalSOA)
BOOST_CHECK_EQUAL(mdp.d_header.nscount, 0U);
BOOST_CHECK_EQUAL(mdp.d_header.arcount, 2U);
BOOST_REQUIRE_EQUAL(mdp.d_answers.size(), 2U);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_type, static_cast<uint16_t>(QType::SOA));
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_class, QClass::IN);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_name, DNSName("zone."));
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).first.d_type, static_cast<uint16_t>(QType::OPT));
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).first.d_name, g_rootdnsname);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_type, static_cast<uint16_t>(QType::SOA));
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_class, QClass::IN);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_name, DNSName("zone."));
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).d_type, static_cast<uint16_t>(QType::OPT));
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).d_name, g_rootdnsname);
}

/* SOA in the authority section*/
Expand All @@ -2090,9 +2090,9 @@ BOOST_AUTO_TEST_CASE(test_setNegativeAndAdditionalSOA)
BOOST_CHECK_EQUAL(mdp.d_header.nscount, 1U);
BOOST_CHECK_EQUAL(mdp.d_header.arcount, 0U);
BOOST_REQUIRE_EQUAL(mdp.d_answers.size(), 1U);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_type, static_cast<uint16_t>(QType::SOA));
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_class, QClass::IN);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_name, DNSName("zone."));
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_type, static_cast<uint16_t>(QType::SOA));
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_class, QClass::IN);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_name, DNSName("zone."));
}
{
/* now with incoming EDNS */
Expand All @@ -2113,11 +2113,11 @@ BOOST_AUTO_TEST_CASE(test_setNegativeAndAdditionalSOA)
BOOST_CHECK_EQUAL(mdp.d_header.nscount, 1U);
BOOST_CHECK_EQUAL(mdp.d_header.arcount, 1U);
BOOST_REQUIRE_EQUAL(mdp.d_answers.size(), 2U);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_type, static_cast<uint16_t>(QType::SOA));
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_class, QClass::IN);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_name, DNSName("zone."));
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).first.d_type, static_cast<uint16_t>(QType::OPT));
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).first.d_name, g_rootdnsname);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_type, static_cast<uint16_t>(QType::SOA));
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_class, QClass::IN);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_name, DNSName("zone."));
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).d_type, static_cast<uint16_t>(QType::OPT));
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).d_name, g_rootdnsname);
}

/* test No Data */
Expand All @@ -2140,9 +2140,9 @@ BOOST_AUTO_TEST_CASE(test_setNegativeAndAdditionalSOA)
BOOST_CHECK_EQUAL(mdp.d_header.nscount, 1U);
BOOST_CHECK_EQUAL(mdp.d_header.arcount, 0U);
BOOST_REQUIRE_EQUAL(mdp.d_answers.size(), 1U);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_type, static_cast<uint16_t>(QType::SOA));
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_class, QClass::IN);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_name, DNSName("zone."));
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_type, static_cast<uint16_t>(QType::SOA));
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_class, QClass::IN);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_name, DNSName("zone."));
}
{
/* now with incoming EDNS */
Expand All @@ -2163,11 +2163,11 @@ BOOST_AUTO_TEST_CASE(test_setNegativeAndAdditionalSOA)
BOOST_CHECK_EQUAL(mdp.d_header.nscount, 1U);
BOOST_CHECK_EQUAL(mdp.d_header.arcount, 1U);
BOOST_REQUIRE_EQUAL(mdp.d_answers.size(), 2U);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_type, static_cast<uint16_t>(QType::SOA));
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_class, QClass::IN);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_name, DNSName("zone."));
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).first.d_type, static_cast<uint16_t>(QType::OPT));
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).first.d_name, g_rootdnsname);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_type, static_cast<uint16_t>(QType::SOA));
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_class, QClass::IN);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_name, DNSName("zone."));
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).d_type, static_cast<uint16_t>(QType::OPT));
BOOST_CHECK_EQUAL(mdp.d_answers.at(1).d_name, g_rootdnsname);
}
}

Expand Down Expand Up @@ -2282,8 +2282,8 @@ BOOST_AUTO_TEST_CASE(test_setEDNSOption)
BOOST_CHECK_EQUAL(mdp.d_header.ancount, 0U);
BOOST_CHECK_EQUAL(mdp.d_header.nscount, 0U);
BOOST_CHECK_EQUAL(mdp.d_header.arcount, 1U);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_type, static_cast<uint16_t>(QType::OPT));
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).first.d_name, g_rootdnsname);
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_type, static_cast<uint16_t>(QType::OPT));
BOOST_CHECK_EQUAL(mdp.d_answers.at(0).d_name, g_rootdnsname);

EDNS0Record edns0{};
BOOST_REQUIRE(getEDNS0Record(dnsQuestion.getData(), edns0));
Expand Down
12 changes: 6 additions & 6 deletions pdns/dnspacket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -513,15 +513,15 @@ bool DNSPacket::getTSIGDetails(TSIGRecordContent* trc, DNSName* keyname, uint16_

bool gotit=false;
for(const auto & answer : mdp.d_answers) {
if(answer.first.d_type == QType::TSIG && answer.first.d_class == QType::ANY) {
if(answer.d_type == QType::TSIG && answer.d_class == QType::ANY) {
// cast can fail, f.e. if d_content is an UnknownRecordContent.
auto content = getRR<TSIGRecordContent>(answer.first);
auto content = getRR<TSIGRecordContent>(answer);
if (!content) {
g_log<<Logger::Error<<"TSIG record has no or invalid content (invalid packet)"<<endl;
return false;
}
*trc = *content;
*keyname = answer.first.d_name;
*keyname = answer.d_name;
gotit=true;
}
}
Expand All @@ -546,15 +546,15 @@ bool DNSPacket::getTKEYRecord(TKEYRecordContent *tr, DNSName *keyname) const
return false;
}

if(answer.first.d_type == QType::TKEY) {
if(answer.d_type == QType::TKEY) {
// cast can fail, f.e. if d_content is an UnknownRecordContent.
auto content = getRR<TKEYRecordContent>(answer.first);
auto content = getRR<TKEYRecordContent>(answer);
if (!content) {
g_log<<Logger::Error<<"TKEY record has no or invalid content (invalid packet)"<<endl;
return false;
}
*tr = *content;
*keyname = answer.first.d_name;
*keyname = answer.d_name;
gotit=true;
}
}
Expand Down
4 changes: 2 additions & 2 deletions pdns/dnsparser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ void MOADNSParser::init(bool query, const std::string_view& packet)
d_tsigPos = recordStartPos;
}

d_answers.emplace_back(std::move(dr), pr.getPosition() - sizeof(dnsheader));
d_answers.emplace_back(std::move(dr));
}

#if 0
Expand Down Expand Up @@ -342,7 +342,7 @@ bool MOADNSParser::hasEDNS() const
}

for (const auto& record : d_answers) {
if (record.first.d_place == DNSResourceRecord::ADDITIONAL && record.first.d_type == QType::OPT) {
if (record.d_place == DNSResourceRecord::ADDITIONAL && record.d_type == QType::OPT) {
return true;
}
}
Expand Down
Loading

0 comments on commit 7123e83

Please sign in to comment.