if (!err) {
for(const auto& answer : mdp.d_answers)
- if (answer.first.d_type == QType::SOA)
+ if (answer.d_type == QType::SOA)
d_soacount++;
}
}
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));
}
}
}
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";
}
}
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;
}
}
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;
}
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);
}
{
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);
}
{
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);
}
{
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);
}
}
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);
}
}
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);
}
}
}
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);
}
}
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 */
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 */
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 */
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*/
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 */
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 */
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 */
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);
}
}
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));
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;
}
}
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;
}
}
d_tsigPos = recordStartPos;
}
- d_answers.emplace_back(std::move(dr), pr.getPosition() - sizeof(dnsheader));
+ d_answers.emplace_back(std::move(dr));
}
#if 0
}
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;
}
}
DNSName d_qname;
uint16_t d_qclass, d_qtype;
- //uint8_t d_rcode;
dnsheader d_header;
- typedef vector<pair<DNSRecord, uint16_t > > answers_t;
+ using answers_t = vector<DNSRecord>;
//! All answers contained in this packet (everything *but* the question section)
answers_t d_answers;
if (mdp.d_header.rcode == RCode::NoError) {
for (const auto& answer : mdp.d_answers) {
- if (answer.first.d_place == DNSResourceRecord::ANSWER || (answer.first.d_place == DNSResourceRecord::AUTHORITY && answer.first.d_type == QType::SOA)) {
+ if (answer.d_place == DNSResourceRecord::ANSWER || (answer.d_place == DNSResourceRecord::AUTHORITY && answer.d_type == QType::SOA)) {
- if (answer.first.d_type == iter->second.qtype || (iter->second.qtype == QType::ANY && (answer.first.d_type == QType::A || answer.first.d_type == QType::AAAA))) {
+ if (answer.d_type == iter->second.qtype || (iter->second.qtype == QType::ANY && (answer.d_type == QType::A || answer.d_type == QType::AAAA))) {
DNSZoneRecord dzr;
dzr.dr.d_name = iter->second.aname;
- dzr.dr.d_type = answer.first.d_type;
- dzr.dr.d_ttl = answer.first.d_ttl;
- dzr.dr.d_place = answer.first.d_place;
- dzr.dr.setContent(answer.first.getContent());
+ dzr.dr.d_type = answer.d_type;
+ dzr.dr.d_ttl = answer.d_ttl;
+ dzr.dr.d_place = answer.d_place;
+ dzr.dr.setContent(answer.getContent());
iter->second.complete->addRecord(std::move(dzr));
}
}
eo->d_extFlags=0;
if(mdp.d_header.arcount && !mdp.d_answers.empty()) {
for(const MOADNSParser::answers_t::value_type& val : mdp.d_answers) {
- if(val.first.d_place == DNSResourceRecord::ADDITIONAL && val.first.d_type == QType::OPT) {
- eo->d_packetsize=val.first.d_class;
+ if(val.d_place == DNSResourceRecord::ADDITIONAL && val.d_type == QType::OPT) {
+ eo->d_packetsize=val.d_class;
EDNS0Record stuff;
- uint32_t ttl=ntohl(val.first.d_ttl);
+ uint32_t ttl=ntohl(val.d_ttl);
static_assert(sizeof(EDNS0Record) == sizeof(uint32_t), "sizeof(EDNS0Record) must match sizeof(uint32_t)");
memcpy(&stuff, &ttl, sizeof(stuff));
eo->d_extRCode=stuff.extRCode;
eo->d_version=stuff.version;
eo->d_extFlags = ntohs(stuff.extFlags);
- auto orc = getRR<OPTRecordContent>(val.first);
+ auto orc = getRR<OPTRecordContent>(val);
if(orc == nullptr)
return false;
orc->getData(eo->d_options);
static void compactAnswerSet(MOADNSParser::answers_t orig, set<DNSRecord>& compacted)
{
for(MOADNSParser::answers_t::const_iterator i=orig.begin(); i != orig.end(); ++i)
- if(i->first.d_place==DNSResourceRecord::ANSWER)
- compacted.insert(i->first);
+ if(i->d_place==DNSResourceRecord::ANSWER)
+ compacted.insert(*i);
}
static bool isRcodeOk(int rcode)
bool ok=true;
for(MOADNSParser::answers_t::const_iterator iter = answers.begin(); iter != answers.end(); ++iter) {
- // cerr<<(int)iter->first.d_place<<", "<<iter->first.d_name<<" "<<iter->first.d_type<<", # "<<answers.size()<<endl;
- if(iter->first.d_place!=2)
+ // cerr<<(int)iter->d_place<<", "<<iter->d_name<<" "<<iter->d_type<<", # "<<answers.size()<<endl;
+ if(iter->d_place!=2)
ok=false;
- if(!iter->first.d_name.isRoot() || iter->first.d_type!=QType::NS)
+ if(!iter->d_name.isRoot() || iter->d_type!=QType::NS)
ok=false;
}
return ok;
for (auto& r: mdp.d_answers) {
if(!primarySOA) {
// we have not seen the first SOA record yet
- if (r.first.d_type != QType::SOA) {
- throw std::runtime_error("The first record of the IXFR answer for zone '"+zone.toLogString()+"' from primary '"+primary.toStringWithPort()+"' is not a SOA ("+QType(r.first.d_type).toString()+")");
+ if (r.d_type != QType::SOA) {
+ throw std::runtime_error("The first record of the IXFR answer for zone '"+zone.toLogString()+"' from primary '"+primary.toStringWithPort()+"' is not a SOA ("+QType(r.d_type).toString()+")");
}
- auto sr = getRR<SOARecordContent>(r.first);
+ auto sr = getRR<SOARecordContent>(r);
if (!sr) {
throw std::runtime_error("Error getting the content of the first SOA record of the IXFR answer for zone '"+zone.toLogString()+"' from primary '"+primary.toStringWithPort()+"'");
}
}
primarySOA = std::move(sr);
++primarySOACount;
- } else if (r.first.d_type == QType::SOA) {
- auto sr = getRR<SOARecordContent>(r.first);
+ } else if (r.d_type == QType::SOA) {
+ auto sr = getRR<SOARecordContent>(r);
if (!sr) {
throw std::runtime_error("Error getting the content of SOA record of IXFR answer for zone '"+zone.toLogString()+"' from primary '"+primary.toStringWithPort()+"'");
}
}
// When we see the 2nd record, we can decide what the style is
if (records.size() == 1 && style == Unknown) {
- if (r.first.d_type != QType::SOA) {
+ if (r.d_type != QType::SOA) {
// Non-empty AXFR style has a non-SOA record following the first SOA
style = AXFR;
}
}
}
- if(r.first.d_place != DNSResourceRecord::ANSWER) {
- if(r.first.d_type == QType::TSIG)
+ if(r.d_place != DNSResourceRecord::ANSWER) {
+ if(r.d_type == QType::TSIG)
continue;
- if(r.first.d_type == QType::OPT)
+ if(r.d_type == QType::OPT)
continue;
- throw std::runtime_error("Unexpected record (" +QType(r.first.d_type).toString()+") in non-answer section ("+std::to_string(r.first.d_place)+") in IXFR response for zone '"+zone.toLogString()+"' from primary '"+primary.toStringWithPort());
+ throw std::runtime_error("Unexpected record (" +QType(r.d_type).toString()+") in non-answer section ("+std::to_string(r.d_place)+") in IXFR response for zone '"+zone.toLogString()+"' from primary '"+primary.toStringWithPort());
}
- r.first.d_name.makeUsRelative(zone);
- records.push_back(r.first);
+ r.d_name.makeUsRelative(zone);
+ records.push_back(r);
}
}
throw std::runtime_error("RCODE from response is not NoError but " + RCode::to_s(mdp.d_header.rcode));
}
for(const auto& r: mdp.d_answers) {
- if(r.first.d_type == QType::SOA) {
- sr = getRR<SOARecordContent>(r.first);
+ if(r.d_type == QType::SOA) {
+ sr = getRR<SOARecordContent>(r);
if(sr != nullptr) {
return sr->d_st.serial;
}
string nsec3salt;
int nsec3iters = 0;
for(MOADNSParser::answers_t::const_iterator i=mdp.d_answers.begin(); i!=mdp.d_answers.end(); ++i) {
- if(i->first.d_type == QType::NSEC3)
+ if(i->d_type == QType::NSEC3)
{
// cerr<<"got nsec3 ["<<i->first.d_name<<"]"<<endl;
// cerr<<i->first.d_content->getZoneRepresentation()<<endl;
- const auto r = getRR<NSEC3RecordContent>(i->first);
+ const auto r = getRR<NSEC3RecordContent>(*i);
if (!r) {
continue;
}
// nsec3.insert(new nsec3()
// cerr<<toBase32Hex(r.d_nexthash)<<endl;
- nsec3s.emplace(toLower(i->first.d_name.getRawLabel(0)), toBase32Hex(r->d_nexthash));
+ nsec3s.emplace(toLower(i->d_name.getRawLabel(0)), toBase32Hex(r->d_nexthash));
nsec3salt = r->d_salt;
nsec3iters = r->d_iterations;
- nsec3t.emplace(toLower(i->first.d_name.getRawLabel(0)), r->numberOfTypesSet());
+ nsec3t.emplace(toLower(i->d_name.getRawLabel(0)), r->numberOfTypesSet());
}
else
{
- // cerr<<"namesseen.insert('"<<i->first.d_name<<"')"<<endl;
- names.insert(i->first.d_name);
- namesseen.insert(i->first.d_name);
+ // cerr<<"namesseen.insert('"<<i->d_name<<"')"<<endl;
+ names.insert(i->d_name);
+ namesseen.insert(i->d_name);
}
- if(i->first.d_type == QType::CNAME)
+ if(i->d_type == QType::CNAME)
{
- namesseen.insert(DNSName(i->first.getContent()->getZoneRepresentation()));
+ namesseen.insert(DNSName(i->getContent()->getZoneRepresentation()));
}
- cout << i->first.d_place - 1 << "\t" << i->first.d_name.toString() << "\t" << i->first.d_ttl << "\tIN\t" << DNSRecordContent::NumberToType(i->first.d_type);
- cout << "\t" << i->first.getContent()->getZoneRepresentation() << "\n";
+ cout << i->d_place - 1 << "\t" << i->d_name.toString() << "\t" << i->d_ttl << "\tIN\t" << DNSRecordContent::NumberToType(i->d_type);
+ cout << "\t" << i->getContent()->getZoneRepresentation() << "\n";
}
#if 0
}
lwr->d_records.reserve(mdp.d_answers.size());
- for (const auto& a : mdp.d_answers)
- lwr->d_records.push_back(a.first);
+ for (const auto& answer : mdp.d_answers) {
+ lwr->d_records.push_back(answer);
+ }
EDNSOpts edo;
if (EDNS0Level > 0 && getEDNSOpts(mdp, &edo)) {
if (parser.d_header.rcode != RCode::NoError || parser.d_answers.size() != 1) {
return {};
}
- const auto& dnsrecord = parser.d_answers.at(0).first;
+ const auto& dnsrecord = parser.d_answers.at(0);
if (dnsrecord.d_type == QType::TXT) {
if (auto txt = getRR<TXTRecordContent>(dnsrecord); txt != nullptr) {
const auto& text = txt->d_text;
result->reserve(mdp.d_answers.size());
for (const auto& i: mdp.d_answers) {
- rr.qname = i.first.d_name;
- rr.qtype = i.first.d_type;
- rr.ttl = i.first.d_ttl;
- rr.content = i.first.getContent()->getZoneRepresentation(true);
+ rr.qname = i.d_name;
+ rr.qtype = i.d_type;
+ rr.ttl = i.d_ttl;
+ rr.content = i.getContent()->getZoneRepresentation(true);
result->push_back(rr);
}
*theirInception = *theirExpire = 0;
bool gotSOA=false;
for(const MOADNSParser::answers_t::value_type& drc : mdp.d_answers) {
- if(drc.first.d_type == QType::SOA && drc.first.d_name == *domain) {
- auto src = getRR<SOARecordContent>(drc.first);
+ if(drc.d_type == QType::SOA && drc.d_name == *domain) {
+ auto src = getRR<SOARecordContent>(drc);
if (src) {
*theirSerial = src->d_st.serial;
gotSOA = true;
}
}
- if(drc.first.d_type == QType::RRSIG && drc.first.d_name == *domain) {
- auto rrc = getRR<RRSIGRecordContent>(drc.first);
+ if(drc.d_type == QType::RRSIG && drc.d_name == *domain) {
+ auto rrc = getRR<RRSIGRecordContent>(drc);
if(rrc && rrc->d_type == QType::SOA) {
*theirInception= std::max(*theirInception, rrc->d_siginception);
*theirExpire = std::max(*theirExpire, rrc->d_sigexpire);
// Check if all the records provided are within the zone
for(const auto & answer : mdp.d_answers) {
- const DNSRecord *rr = &answer.first;
+ const DNSRecord *rr = &answer;
// Skip this check for other field types (like the TSIG - which is in the additional section)
// For a TSIG, the label is the dnskey, so it does not pass the endOn validation.
if (! (rr->d_place == DNSResourceRecord::ANSWER || rr->d_place == DNSResourceRecord::AUTHORITY))
// 3.2.1 and 3.2.2 - Prerequisite check
for(const auto & answer : mdp.d_answers) {
- const DNSRecord *rr = &answer.first;
+ const DNSRecord *rr = &answer;
if (rr->d_place == DNSResourceRecord::ANSWER) {
int res = checkUpdatePrerequisites(rr, &di);
if (res>0) {
typedef std::map<rrSetKey_t, rrVector_t> RRsetMap_t;
RRsetMap_t preReqRRsets;
for(const auto& i: mdp.d_answers) {
- const DNSRecord* rr = &i.first;
+ const DNSRecord* rr = &i;
if (rr->d_place == DNSResourceRecord::ANSWER) {
// Last line of 3.2.3
if (rr->d_class != QClass::IN && rr->d_class != QClass::NONE && rr->d_class != QClass::ANY)
uint changedRecords = 0;
// 3.4.1 - Prescan section
for(const auto & answer : mdp.d_answers) {
- const DNSRecord *rr = &answer.first;
+ const DNSRecord *rr = &answer;
if (rr->d_place == DNSResourceRecord::AUTHORITY) {
int res = checkUpdatePrescan(rr);
if (res>0) {
// Another special case is the addition of both a CNAME and a non-CNAME for the same name (#6270)
set<DNSName> cn, nocn;
for (const auto &rr : mdp.d_answers) {
- if (rr.first.d_place == DNSResourceRecord::AUTHORITY && rr.first.d_class == QClass::IN && rr.first.d_ttl > 0) {
+ if (rr.d_place == DNSResourceRecord::AUTHORITY && rr.d_class == QClass::IN && rr.d_ttl > 0) {
// Addition
- if (rr.first.d_type == QType::CNAME) {
- cn.insert(rr.first.d_name);
- } else if (rr.first.d_type != QType::RRSIG) {
- nocn.insert(rr.first.d_name);
+ if (rr.d_type == QType::CNAME) {
+ cn.insert(rr.d_name);
+ } else if (rr.d_type != QType::RRSIG) {
+ nocn.insert(rr.d_name);
}
}
}
vector<const DNSRecord *> cnamesToAdd, nonCnamesToAdd;
for(const auto & answer : mdp.d_answers) {
- const DNSRecord *rr = &answer.first;
+ const DNSRecord *rr = &answer;
if (rr->d_place == DNSResourceRecord::AUTHORITY) {
/* see if it's permitted by policy */
if (this->d_update_policy_lua != nullptr) {
throw PDNSException(string("Remote server refused: ") + std::to_string(mdp.d_header.rcode));
}
for(MOADNSParser::answers_t::const_iterator i=mdp.d_answers.begin(); i!=mdp.d_answers.end(); ++i) {
- if (i->first.d_type == QType::TSIG) {
+ if (i->d_type == QType::TSIG) {
string message;
if (!tsig) {
std::cerr<<"Unexpected TSIG signature in data"<<endl;
}
- trc = TSIGRecordContent(i->first.getContent()->getZoneRepresentation());
+ trc = TSIGRecordContent(i->getContent()->getZoneRepresentation());
continue;
}
- if(i->first.d_type == QType::SOA)
+ if(i->d_type == QType::SOA)
{
++soacount;
}
- else if (i->first.d_type == QType::NSEC3PARAM) {
- ns3pr = NSEC3PARAMRecordContent(i->first.getContent()->getZoneRepresentation());
+ else if (i->d_type == QType::NSEC3PARAM) {
+ ns3pr = NSEC3PARAMRecordContent(i->getContent()->getZoneRepresentation());
isNSEC3 = true;
}
ostringstream o;
- o<<"\t"<<i->first.d_ttl<<"\tIN\t"<<DNSRecordContent::NumberToType(i->first.d_type);
+ o<<"\t"<<i->d_ttl<<"\tIN\t"<<DNSRecordContent::NumberToType(i->d_type);
if(showdetails)
{
- o<<"\t"<<i->first.getContent()->getZoneRepresentation();
+ o<<"\t"<<i->getContent()->getZoneRepresentation();
}
- else if(i->first.d_type == QType::RRSIG)
+ else if(i->d_type == QType::RRSIG)
{
- string zoneRep = i->first.getContent()->getZoneRepresentation();
+ string zoneRep = i->getContent()->getZoneRepresentation();
vector<string> parts;
stringtok(parts, zoneRep);
o<<"\t"<<parts[0]<<" "<<parts[1]<<" "<<parts[2]<<" "<<parts[3]<<" [expiry] [inception] [keytag] "<<parts[7]<<" ...";
}
- else if(i->first.d_type == QType::NSEC3)
+ else if(i->d_type == QType::NSEC3)
{
- string zoneRep = i->first.getContent()->getZoneRepresentation();
+ string zoneRep = i->getContent()->getZoneRepresentation();
vector<string> parts;
stringtok(parts, zoneRep);
o<<"\t"<<parts[0]<<" ";
for(vector<string>::iterator iter = parts.begin()+5; iter != parts.end(); ++iter)
o<<" "<<*iter;
}
- else if(i->first.d_type == QType::DNSKEY)
+ else if(i->d_type == QType::DNSKEY)
{
- string zoneRep = i->first.getContent()->getZoneRepresentation();
+ string zoneRep = i->getContent()->getZoneRepresentation();
vector<string> parts;
stringtok(parts, zoneRep);
o<<"\t"<<parts[0]<<" "<<parts[1]<<" "<<parts[2]<<" ...";
}
else
{
- o<<"\t"<<i->first.getContent()->getZoneRepresentation();
+ o<<"\t"<<i->getContent()->getZoneRepresentation();
}
- records.emplace_back(i->first.d_name, o.str());
+ records.emplace_back(i->d_name, o.str());
- DNSName shorter(i->first.d_name);
+ DNSName shorter(i->d_name);
do {
labels.insert(shorter);
if (shorter == DNSName(argv[3]))
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_name.toString() << "\t"
- << ttl(i->first.d_ttl) << "\t" << nameForClass(i->first.d_class, i->first.d_type) << "\t"
- << DNSRecordContent::NumberToType(i->first.d_type);
+ cout << i->d_place - 1 << "\t" << i->d_name.toString() << "\t"
+ << ttl(i->d_ttl) << "\t" << nameForClass(i->d_class, i->d_type) << "\t"
+ << DNSRecordContent::NumberToType(i->d_type);
if (dumpluaraw) {
- cout<<"\t"<< makeLuaString(i->first.getContent()->serialize(DNSName(), true))<<endl;
+ cout<<"\t"<< makeLuaString(i->getContent()->serialize(DNSName(), true))<<endl;
continue;
}
- if (i->first.d_class == QClass::IN) {
- if (i->first.d_type == QType::RRSIG) {
- string zoneRep = i->first.getContent()->getZoneRepresentation();
+ if (i->d_class == QClass::IN) {
+ if (i->d_type == QType::RRSIG) {
+ string zoneRep = i->getContent()->getZoneRepresentation();
vector<string> parts;
stringtok(parts, zoneRep);
cout << "\t" << parts[0] << " "
<< " [expiry] [inception] [keytag] " << parts[7] << " ...\n";
continue;
}
- if (!showflags && i->first.d_type == QType::NSEC3) {
- string zoneRep = i->first.getContent()->getZoneRepresentation();
+ if (!showflags && i->d_type == QType::NSEC3) {
+ string zoneRep = i->getContent()->getZoneRepresentation();
vector<string> parts;
stringtok(parts, zoneRep);
cout << "\t" << parts[0] << " [flags] "
cout << "\n";
continue;
}
- if (i->first.d_type == QType::DNSKEY) {
- string zoneRep = i->first.getContent()->getZoneRepresentation();
+ if (i->d_type == QType::DNSKEY) {
+ string zoneRep = i->getContent()->getZoneRepresentation();
vector<string> parts;
stringtok(parts, zoneRep);
cout << "\t" << parts[0] << " "
<< parts[1] << " " << parts[2] << " ...\n";
continue;
}
- if (i->first.d_type == QType::SOA && hidesoadetails) {
- string zoneRep = i->first.getContent()->getZoneRepresentation();
+ if (i->d_type == QType::SOA && hidesoadetails) {
+ string zoneRep = i->getContent()->getZoneRepresentation();
vector<string> parts;
stringtok(parts, zoneRep);
cout << "\t" << parts[0] << " "
continue;
}
}
- cout << "\t" << i->first.getContent()->getZoneRepresentation() << "\n";
+ cout << "\t" << i->getContent()->getZoneRepresentation() << "\n";
}
EDNSOpts edo;
} lwr;
for(MOADNSParser::answers_t::const_iterator i=mdp.d_answers.begin(); i!=mdp.d_answers.end(); ++i) {
DNSResourceRecord rr;
- rr.qtype=i->first.d_type;
- rr.qname=i->first.d_name;
+ rr.qtype=i->d_type;
+ rr.qname=i->d_name;
- rr.ttl=i->first.d_ttl;
- rr.content=i->first.getContent()->getZoneRepresentation(); // this should be the serialised form
+ rr.ttl=i->d_ttl;
+ rr.content=i->getContent()->getZoneRepresentation(); // this should be the serialised form
lwr.d_result.push_back(rr);
}
}
for (const auto& answer : mdp.d_answers) {
- if (answer.first.d_place == 1 && answer.first.d_type == qtype) {
+ if (answer.d_place == 1 && answer.d_type == qtype) {
DNSZoneRecord zrr;
- zrr.dr = answer.first;
+ zrr.dr = answer;
zrr.auth = true;
ret.push_back(zrr);
}
uint32_t serial = 0;
MOADNSParser mdp(false, q->getString());
for(const auto & answer : mdp.d_answers) {
- const DNSRecord *rr = &answer.first;
+ const DNSRecord *rr = &answer;
if (rr->d_type == QType::SOA && rr->d_place == DNSResourceRecord::AUTHORITY) {
vector<string>parts;
stringtok(parts, rr->getContent()->getZoneRepresentation());
MOADNSParser parser(false, reinterpret_cast<const char*>(packet.data()), packet.size());
BOOST_REQUIRE_EQUAL(parser.d_answers.size(), 1U);
- const auto& record = parser.d_answers.at(0).first;
+ const auto& record = parser.d_answers.at(0);
BOOST_REQUIRE(record.d_type == QType::NSEC3);
BOOST_REQUIRE(record.d_class == QClass::IN);
auto content = getRR<NSEC3RecordContent>(record);
TSIGRecordContent trc;
for(const auto& answer: mdp.d_answers) {
- if(answer.first.d_type == QType::TSIG) {
- BOOST_CHECK_EQUAL(answer.first.d_place, DNSResourceRecord::ADDITIONAL);
- BOOST_CHECK_EQUAL(answer.first.d_class, QClass::ANY);
- BOOST_CHECK_EQUAL(answer.first.d_ttl, 0U);
+ if(answer.d_type == QType::TSIG) {
+ BOOST_CHECK_EQUAL(answer.d_place, DNSResourceRecord::ADDITIONAL);
+ BOOST_CHECK_EQUAL(answer.d_class, QClass::ANY);
+ BOOST_CHECK_EQUAL(answer.d_ttl, 0U);
BOOST_CHECK_EQUAL(tsigFound, false);
- auto rectrc = getRR<TSIGRecordContent>(answer.first);
+ auto rectrc = getRR<TSIGRecordContent>(answer);
if (rectrc) {
trc = *rectrc;
theirMac = rectrc->d_mac;
- keyName = answer.first.d_name;
+ keyName = answer.d_name;
tsigFound = true;
}
}
}
for(const auto& answer : mdp.d_answers) {
- if (answer.first.d_type == QType::SOA) {
+ if (answer.d_type == QType::SOA) {
// A SOA is either the first or the last record. We need to check TSIG if that's the case.
checkTSIG = true;
}
- if(answer.first.d_type == QType::TSIG) {
- auto trc = getRR<TSIGRecordContent>(answer.first);
+ if(answer.d_type == QType::TSIG) {
+ auto trc = getRR<TSIGRecordContent>(answer);
if(trc) {
theirMac = trc->d_mac;
d_trc.d_time = trc->d_time;