* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#pragma once
-#include <string>
-#include <vector>
#include "namespaces.hh"
/** The QType class is meant to deal easily with the different kind of resource types, like 'A', 'NS',
*/
-
-
class QType
{
public:
- QType(); //!< Naked constructor
- explicit QType(uint16_t); //!< convert from an integer to a QType
- QType(const QType& orig) : code(orig.code)
+ QType(uint16_t qtype = 0) : code(qtype) {}
+ QType(const QType& orig) : code(orig.code) {}
+ QType &operator=(uint16_t arg)
{
+ code = arg;
+ return *this;
}
- QType &operator=(uint16_t); //!< Assigns integers to us
- QType &operator=(const char *); //!< Assigns strings to us
- QType &operator=(const string &); //!< Assigns strings to us
- QType &operator=(const QType&rhs) //!< Assigns strings to us
+ QType &operator=(const char *);
+ QType &operator=(const string &);
+ QType &operator=(const QType& rhs)
{
- code=rhs.code;
+ code = rhs.code;
return *this;
}
-
- bool operator<(const QType& rhs) const
+ bool operator<(const QType rhs) const
{
return code < rhs.code;
}
- const string getName() const; //!< Get a string representation of this type
- uint16_t getCode() const; //!< Get the integer representation of this type
- bool isSupportedType();
- bool isMetadataType();
-
- static int chartocode(const char *p); //!< convert a character string to a code
- enum typeenum : uint16_t {
- ENT=0,
- A=1,
- NS=2,
- CNAME=5,
- SOA=6,
- MB=7,
- MG=8,
- MR=9,
- PTR=12,
- HINFO=13,
- MINFO=14,
- MX=15,
- TXT=16,
- RP=17,
- AFSDB=18,
- SIG=24,
- KEY=25,
- AAAA=28,
- LOC=29,
- SRV=33,
- NAPTR=35,
- KX=36,
- CERT=37,
- A6=38,
- DNAME=39,
- OPT=41,
- APL=42,
- DS=43,
- SSHFP=44,
- IPSECKEY=45,
- RRSIG=46,
- NSEC=47,
- DNSKEY=48,
- DHCID=49,
- NSEC3=50,
- NSEC3PARAM=51,
- TLSA=52,
- SMIMEA=53,
- RKEY=57,
- CDS=59,
- CDNSKEY=60,
- OPENPGPKEY=61,
- SVCB=64,
- HTTPS=65,
- SPF=99,
- EUI48=108,
- EUI64=109,
- TKEY=249,
- TSIG=250,
- IXFR=251,
- AXFR=252,
- MAILB=253,
- MAILA=254,
- ANY=255,
- URI=256,
- CAA=257,
- DLV=32769,
- ADDR=65400,
- ALIAS=65401,
- LUA=65402
- };
-
- QType(typeenum orig) : code(orig)
- {
- }
-
- typedef pair<string,uint16_t> namenum;
- static vector<namenum> names;
-
- inline bool operator==(const QType &comp) const {
- return(comp.code==code);
- }
-
- inline bool operator!=(const QType &comp) const {
- return(comp.code!=code);
+ operator uint16_t() const {
+ return code;
}
- inline bool operator==(QType::typeenum comp) const {
- return(comp==code);
- }
-
- inline bool operator!=(QType::typeenum comp) const {
- return(comp!=code);
+ const string getName() const;
+ uint16_t getCode() const
+ {
+ return code;
}
+ bool isSupportedType() const;
+ bool isMetadataType() const;
- inline bool operator==(uint16_t comp) const {
- return(comp==code);
- }
+ static uint16_t chartocode(const char* p);
+
+ enum typeenum : uint16_t {
+ ENT = 0,
+ A = 1,
+ NS = 2,
+ CNAME = 5,
+ SOA = 6,
+ MB = 7,
+ MG = 8,
+ MR = 9,
+ PTR = 12,
+ HINFO = 13,
+ MINFO = 14,
+ MX = 15,
+ TXT = 16,
+ RP = 17,
+ AFSDB = 18,
+ SIG = 24,
+ KEY = 25,
+ AAAA = 28,
+ LOC = 29,
+ SRV = 33,
+ NAPTR = 35,
+ KX = 36,
+ CERT = 37,
+ A6 = 38,
+ DNAME = 39,
+ OPT = 41,
+ APL = 42,
+ DS = 43,
+ SSHFP = 44,
+ IPSECKEY = 45,
+ RRSIG = 46,
+ NSEC = 47,
+ DNSKEY = 48,
+ DHCID = 49,
+ NSEC3 = 50,
+ NSEC3PARAM = 51,
+ TLSA = 52,
+ SMIMEA = 53,
+ RKEY = 57,
+ CDS = 59,
+ CDNSKEY = 60,
+ OPENPGPKEY = 61,
+ SVCB = 64,
+ HTTPS = 65,
+ SPF = 99,
+ EUI48 = 108,
+ EUI64 = 109,
+ TKEY = 249,
+ TSIG = 250,
+ IXFR = 251,
+ AXFR = 252,
+ MAILB = 253,
+ MAILA = 254,
+ ANY = 255,
+ URI = 256,
+ CAA = 257,
+ DLV = 32769,
+ ADDR = 65400,
+ ALIAS = 65401,
+ LUA = 65402
+ };
- inline bool operator!=(uint16_t comp) const {
- return(comp!=code);
- }
+ typedef pair<string, uint16_t> namenum;
+ const static vector<namenum> names;
private:
- static class init {
- public:
- void qtype_insert(const char* a, uint16_t num)
- {
- names.push_back(make_pair(string(a), num));
- }
-
- init()
- {
- qtype_insert("A", 1);
- qtype_insert("NS", 2);
- qtype_insert("CNAME", 5);
- qtype_insert("SOA", 6);
- qtype_insert("MB", 7);
- qtype_insert("MG", 8);
- qtype_insert("MR", 9);
- qtype_insert("PTR", 12);
- qtype_insert("HINFO", 13);
- qtype_insert("MINFO", 14);
- qtype_insert("MX", 15);
- qtype_insert("TXT", 16);
- qtype_insert("RP", 17);
- qtype_insert("AFSDB", 18);
- qtype_insert("SIG", 24);
- qtype_insert("KEY", 25);
- qtype_insert("AAAA", 28);
- qtype_insert("LOC", 29);
- qtype_insert("SRV", 33);
- qtype_insert("NAPTR", 35);
- qtype_insert("KX", 36);
- qtype_insert("CERT", 37);
- qtype_insert("A6", 38);
- qtype_insert("DNAME", 39);
- qtype_insert("OPT", 41);
- qtype_insert("APL", 42);
- qtype_insert("DS", 43);
- qtype_insert("SSHFP", 44);
- qtype_insert("IPSECKEY", 45);
- qtype_insert("RRSIG", 46);
- qtype_insert("NSEC", 47);
- qtype_insert("DNSKEY", 48);
- qtype_insert("DHCID", 49);
- qtype_insert("NSEC3", 50);
- qtype_insert("NSEC3PARAM", 51);
- qtype_insert("TLSA", 52);
- qtype_insert("SMIMEA", 53);
- qtype_insert("RKEY", 57);
- qtype_insert("CDS", 59);
- qtype_insert("CDNSKEY", 60);
- qtype_insert("OPENPGPKEY", 61);
- qtype_insert("SVCB", 64);
- qtype_insert("HTTPS", 65);
- qtype_insert("SPF", 99);
- qtype_insert("EUI48", 108);
- qtype_insert("EUI64", 109);
- qtype_insert("TKEY", 249);
-// qtype_insert("TSIG", 250);
- qtype_insert("IXFR", 251);
- qtype_insert("AXFR", 252);
- qtype_insert("MAILB", 253);
- qtype_insert("MAILA", 254);
- qtype_insert("ANY", 255);
- qtype_insert("URI", 256);
- qtype_insert("CAA", 257);
- qtype_insert("DLV", 32769);
- qtype_insert("ADDR", 65400);
- qtype_insert("ALIAS", 65401);
- qtype_insert("LUA", 65402);
- }
- } initializer;
uint16_t code;
};
+// Define hash function on QType. See https://en.cppreference.com/w/cpp/utility/hash
+namespace std {
+ template<> struct hash<QType> {
+ std::size_t operator()(QType qtype) const noexcept {
+ return std::hash<uint16_t>{}(qtype.getCode());
+ }
+ };
+}
+
struct QClass
{
- enum QClassEnum {IN=1, CHAOS=3, NONE=254, ANY=255};
+ enum QClassEnum { IN = 1, CHAOS = 3, NONE = 254, ANY = 255 };
};
EDNSSubnetOpts SyncRes::s_ecsScopeZero;
string SyncRes::s_serverID;
SyncRes::LogMode SyncRes::s_lm;
-const std::unordered_set<uint16_t> SyncRes::s_redirectionQTypes = {QType::CNAME, QType::DNAME};
+const std::unordered_set<QType> SyncRes::s_redirectionQTypes = {QType::CNAME, QType::DNAME};
unsigned int SyncRes::s_maxnegttl;
unsigned int SyncRes::s_maxbogusttl;
}
/** everything begins here - this is the entry point just after receiving a packet */
-int SyncRes::beginResolve(const DNSName &qname, const QType &qtype, uint16_t qclass, vector<DNSRecord>&ret, unsigned int depth)
+int SyncRes::beginResolve(const DNSName &qname, const QType qtype, uint16_t qclass, vector<DNSRecord>&ret, unsigned int depth)
{
vState state = vState::Indeterminate;
s_queries++;
* - trustanchor.server CH TXT
* - negativetrustanchor.server CH TXT
*/
-bool SyncRes::doSpecialNamesResolve(const DNSName &qname, const QType &qtype, const uint16_t qclass, vector<DNSRecord> &ret)
+bool SyncRes::doSpecialNamesResolve(const DNSName &qname, QType qtype, const uint16_t qclass, vector<DNSRecord> &ret)
{
static const DNSName arpa("1.0.0.127.in-addr.arpa."), ip6_arpa("1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa."),
localhost("localhost."), versionbind("version.bind."), idserver("id.server."), versionpdns("version.pdns."), trustanchorserver("trustanchor.server."),
}
}
-int SyncRes::AuthDomain::getRecords(const DNSName& qname, uint16_t qtype, std::vector<DNSRecord>& records) const
+int SyncRes::AuthDomain::getRecords(const DNSName& qname, QType qtype, std::vector<DNSRecord>& records) const
{
int result = RCode::NoError;
records.clear();
return result;
}
-bool SyncRes::doOOBResolve(const AuthDomain& domain, const DNSName &qname, const QType &qtype, vector<DNSRecord>&ret, int& res)
+bool SyncRes::doOOBResolve(const AuthDomain& domain, const DNSName &qname, QType qtype, vector<DNSRecord>&ret, int& res)
{
d_authzonequeries++;
s_authzonequeries++;
return true;
}
-bool SyncRes::doOOBResolve(const DNSName &qname, const QType &qtype, vector<DNSRecord>&ret, unsigned int depth, int& res)
+bool SyncRes::doOOBResolve(const DNSName &qname, QType qtype, vector<DNSRecord>&ret, unsigned int depth, int& res)
{
string prefix;
if(doLog()) {
#define QLOG(x) LOG(prefix << " child=" << child << ": " << x << endl)
-int SyncRes::doResolve(const DNSName &qname, const QType &qtype, vector<DNSRecord>&ret, unsigned int depth, set<GetBestNSAnswer>& beenthere, vState& state) {
+int SyncRes::doResolve(const DNSName &qname, QType qtype, vector<DNSRecord>&ret, unsigned int depth, set<GetBestNSAnswer>& beenthere, vState& state) {
string prefix = d_prefix;
prefix.append(depth, ' ');
* \param stopAtDelegation if non-nullptr and pointed-to value is Stop requests the callee to stop at a delegation, if so pointed-to value is set to Stopped
* \return DNS RCODE or -1 (Error)
*/
-int SyncRes::doResolveNoQNameMinimization(const DNSName &qname, const QType &qtype, vector<DNSRecord>&ret, unsigned int depth, set<GetBestNSAnswer>& beenthere, vState& state, bool *fromCache, StopAtDelegation *stopAtDelegation, bool considerforwards)
+int SyncRes::doResolveNoQNameMinimization(const DNSName &qname, QType qtype, vector<DNSRecord>&ret, unsigned int depth, set<GetBestNSAnswer>& beenthere, vState& state, bool *fromCache, StopAtDelegation *stopAtDelegation, bool considerforwards)
{
string prefix;
if(doLog()) {
// We have some IPv4 records, don't bother with going out to get IPv6, but do consult the cache
// Once IPv6 adoption matters, this needs to be revisited
res_t cset;
- if (g_recCache->get(d_now.tv_sec, qname, QType(QType::AAAA), false, &cset, d_cacheRemote, d_refresh, d_routingTag) > 0) {
+ if (g_recCache->get(d_now.tv_sec, qname, QType::AAAA, false, &cset, d_cacheRemote, d_refresh, d_routingTag) > 0) {
for (const auto &i : cset) {
if (i.d_ttl > (unsigned int)d_now.tv_sec ) {
if (auto rec = getRR<AAAARecordContent>(i)) {
return ret;
}
-void SyncRes::getBestNSFromCache(const DNSName &qname, const QType& qtype, vector<DNSRecord>& bestns, bool* flawedNSSet, unsigned int depth, set<GetBestNSAnswer>& beenthere, const boost::optional<DNSName>& cutOffDomain)
+void SyncRes::getBestNSFromCache(const DNSName &qname, QType qtype, vector<DNSRecord>& bestns, bool* flawedNSSet, unsigned int depth, set<GetBestNSAnswer>& beenthere, const boost::optional<DNSName>& cutOffDomain)
{
string prefix;
DNSName subdomain(qname);
vector<DNSRecord> ns;
*flawedNSSet = false;
- if(g_recCache->get(d_now.tv_sec, subdomain, QType(QType::NS), false, &ns, d_cacheRemote, d_refresh, d_routingTag) > 0) {
+ if(g_recCache->get(d_now.tv_sec, subdomain, QType::NS, false, &ns, d_cacheRemote, d_refresh, d_routingTag) > 0) {
bestns.reserve(ns.size());
for(auto k=ns.cbegin();k!=ns.cend(); ++k) {
}
/** doesn't actually do the work, leaves that to getBestNSFromCache */
-DNSName SyncRes::getBestNSNamesFromCache(const DNSName &qname, const QType& qtype, NsSet& nsset, bool* flawedNSSet, unsigned int depth, set<GetBestNSAnswer>&beenthere)
+DNSName SyncRes::getBestNSNamesFromCache(const DNSName &qname, QType qtype, NsSet& nsset, bool* flawedNSSet, unsigned int depth, set<GetBestNSAnswer>&beenthere)
{
string prefix;
if (doLog()) {
return false;
}
-bool SyncRes::doCNAMECacheCheck(const DNSName &qname, const QType &qtype, vector<DNSRecord>& ret, unsigned int depth, int &res, vState& state, bool wasAuthZone, bool wasForwardRecurse)
+bool SyncRes::doCNAMECacheCheck(const DNSName &qname, QType qtype, vector<DNSRecord>& ret, unsigned int depth, int &res, vState& state, bool wasAuthZone, bool wasForwardRecurse)
{
string prefix;
if(doLog()) {
uint32_t capTTL = std::numeric_limits<uint32_t>::max();
DNSName foundName;
DNSName authZone;
- QType foundQT = QType(0); // 0 == QTYPE::ENT
+ QType foundQT = QType::ENT;
LOG(prefix<<qname<<": Looking for CNAME cache hit of '"<<qname<<"|CNAME"<<"'"<<endl);
/* we don't require auth data for forward-recurse lookups */
- if (g_recCache->get(d_now.tv_sec, qname, QType(QType::CNAME), !wasForwardRecurse && d_requireAuthData, &cset, d_cacheRemote, d_refresh, d_routingTag, d_doDNSSEC ? &signatures : nullptr, d_doDNSSEC ? &authorityRecs : nullptr, &d_wasVariable, &state, &wasAuth, &authZone) > 0) {
+ if (g_recCache->get(d_now.tv_sec, qname, QType::CNAME, !wasForwardRecurse && d_requireAuthData, &cset, d_cacheRemote, d_refresh, d_routingTag, d_doDNSSEC ? &signatures : nullptr, d_doDNSSEC ? &authorityRecs : nullptr, &d_wasVariable, &state, &wasAuth, &authZone) > 0) {
foundName = qname;
- foundQT = QType(QType::CNAME);
+ foundQT = QType::CNAME;
}
if (foundName.empty() && qname != g_rootdnsname) {
if (dnameName == qname && qtype != QType::DNAME) { // The client does not want a DNAME, but we've reached the QNAME already. So there is no match
break;
}
- if (g_recCache->get(d_now.tv_sec, dnameName, QType(QType::DNAME), !wasForwardRecurse && d_requireAuthData, &cset, d_cacheRemote, d_refresh, d_routingTag, d_doDNSSEC ? &signatures : nullptr, d_doDNSSEC ? &authorityRecs : nullptr, &d_wasVariable, &state, &wasAuth, &authZone) > 0) {
+ if (g_recCache->get(d_now.tv_sec, dnameName, QType::DNAME, !wasForwardRecurse && d_requireAuthData, &cset, d_cacheRemote, d_refresh, d_routingTag, d_doDNSSEC ? &signatures : nullptr, d_doDNSSEC ? &authorityRecs : nullptr, &d_wasVariable, &state, &wasAuth, &authZone) > 0) {
foundName = dnameName;
- foundQT = QType(QType::DNAME);
+ foundQT = QType::DNAME;
break;
}
} while(!labels.empty());
struct CacheKey
{
DNSName name;
- uint16_t type;
+ QType type;
DNSResourceRecord::Place place;
bool operator<(const CacheKey& rhs) const {
return tie(type, place, name) < tie(rhs.type, rhs.place, rhs.name);
}
}
-static void reapRecordsForValidation(std::map<uint16_t, CacheEntry>& entries, const vector<DNSRecord>& records)
+static void reapRecordsForValidation(std::map<QType, CacheEntry>& entries, const vector<DNSRecord>& records)
{
for (const auto& rec : records) {
entries[rec.d_type].records.push_back(rec);
}
}
-static void reapSignaturesForValidation(std::map<uint16_t, CacheEntry>& entries, const vector<std::shared_ptr<RRSIGRecordContent>>& signatures)
+static void reapSignaturesForValidation(std::map<QType, CacheEntry>& entries, const vector<std::shared_ptr<RRSIGRecordContent>>& signatures)
{
for (const auto& sig : signatures) {
entries[sig->d_type].signatures.push_back(sig);
}
}
-bool SyncRes::doCacheCheck(const DNSName &qname, const DNSName& authname, bool wasForwardedOrAuthZone, bool wasAuthZone, bool wasForwardRecurse, const QType &qtype, vector<DNSRecord>&ret, unsigned int depth, int &res, vState& state)
+bool SyncRes::doCacheCheck(const DNSName &qname, const DNSName& authname, bool wasForwardedOrAuthZone, bool wasAuthZone, bool wasForwardRecurse, QType qtype, vector<DNSRecord>&ret, unsigned int depth, int &res, vState& state)
{
bool giveNegative=false;
negCacheName.prependRawLabel(labels.back());
labels.pop_back();
while(!labels.empty()) {
- if (g_negCache->get(negCacheName, QType(0), d_now, ne, true)) {
+ if (g_negCache->get(negCacheName, QType::ENT, d_now, ne, true)) {
if (ne.d_validationState == vState::Indeterminate && validationEnabled()) {
// LOG(prefix << negCacheName << " negatively cached and vState::Indeterminate, trying to validate NXDOMAIN" << endl);
// ...
}
else {
if (sqt == QType::ANY) {
- std::map<uint16_t, CacheEntry> types;
+ std::map<QType, CacheEntry> types;
reapRecordsForValidation(types, cset);
reapSignaturesForValidation(types, signatures);
cachedRecordState = validateDNSKeys(sqname, type.second.records, type.second.signatures, depth);
}
else {
- cachedRecordState = SyncRes::validateRecordsWithSigs(depth, qname, qtype, sqname, QType(type.first), type.second.records, type.second.signatures);
+ cachedRecordState = SyncRes::validateRecordsWithSigs(depth, qname, qtype, sqname, type.first, type.second.records, type.second.signatures);
}
updateDNSSECValidationState(cachedState, cachedRecordState);
}
return res;
}
-static const set<uint16_t> nsecTypes = {QType::NSEC, QType::NSEC3};
+static const set<QType> nsecTypes = {QType::NSEC, QType::NSEC3};
/* Fills the authoritySOA and DNSSECRecords fields from ne with those found in the records
*
return true;
}
-static void removeConflictingRecord(std::vector<DNSRecord>& records, const DNSName& name, uint16_t dtype)
+static void removeConflictingRecord(std::vector<DNSRecord>& records, const DNSName& name, QType dtype)
{
for (auto it = records.begin(); it != records.end(); ) {
bool remove = false;
vState state = vState::Indeterminate;
const bool oldCacheOnly = setCacheOnly(false);
- int rcode = doResolve(zone, QType(QType::DS), dsrecords, depth + 1, beenthere, state);
+ int rcode = doResolve(zone, QType::DS, dsrecords, depth + 1, beenthere, state);
setCacheOnly(oldCacheOnly);
if (rcode == RCode::ServFail) {
vState state = vState::Indeterminate;
const bool oldCacheOnly = setCacheOnly(false);
- int rcode = doResolve(signer, QType(QType::DNSKEY), records, depth + 1, beenthere, state);
+ int rcode = doResolve(signer, QType::DNSKEY, records, depth + 1, beenthere, state);
setCacheOnly(oldCacheOnly);
if (rcode == RCode::ServFail) {
rec.d_ttl = min(s_maxcachettl, rec.d_ttl);
- if(!isCNAMEAnswer && rec.d_place == DNSResourceRecord::ANSWER && rec.d_type == QType::CNAME && (!(qtype==QType(QType::CNAME))) && rec.d_name == qname && !isDNAMEAnswer) {
+ if(!isCNAMEAnswer && rec.d_place == DNSResourceRecord::ANSWER && rec.d_type == QType::CNAME && (!(qtype==QType::CNAME)) && rec.d_name == qname && !isDNAMEAnswer) {
isCNAMEAnswer = true;
}
- if(!isDNAMEAnswer && rec.d_place == DNSResourceRecord::ANSWER && rec.d_type == QType::DNAME && qtype != QType(QType::DNAME) && qname.isPartOf(rec.d_name)) {
+ if(!isDNAMEAnswer && rec.d_place == DNSResourceRecord::ANSWER && rec.d_type == QType::DNAME && qtype != QType::DNAME && qname.isPartOf(rec.d_name)) {
isDNAMEAnswer = true;
isCNAMEAnswer = false;
}
}
}
if (doCache) {
- g_recCache->replace(d_now.tv_sec, i->first.name, QType(i->first.type), i->second.records, i->second.signatures, authorityRecs, i->first.type == QType::DS ? true : isAA, auth, i->first.place == DNSResourceRecord::ANSWER ? ednsmask : boost::none, d_routingTag, recordState, remoteIP);
+ g_recCache->replace(d_now.tv_sec, i->first.name, i->first.type, i->second.records, i->second.signatures, authorityRecs, i->first.type == QType::DS ? true : isAA, auth, i->first.place == DNSResourceRecord::ANSWER ? ednsmask : boost::none, d_routingTag, recordState, remoteIP);
}
}
/* if we get an NXDomain answer with a CNAME, the name
does exist but the target does not */
ne.d_name = newtarget.empty() ? qname : newtarget;
- ne.d_qtype = QType(0); // this encodes 'whole record'
+ ne.d_qtype = QType::ENT; // this encodes 'whole record'
ne.d_auth = rec.d_name;
harvestNXRecords(lwr.d_records, ne, d_now.tv_sec, &lowestTTL);
// for ANY answers we *must* have an authoritative answer, unless we are forwarding recursively
else if(rec.d_place==DNSResourceRecord::ANSWER && rec.d_name == qname &&
(
- rec.d_type==qtype.getCode() || ((lwr.d_aabit || sendRDQuery) && qtype == QType(QType::ANY))
+ rec.d_type==qtype.getCode() || ((lwr.d_aabit || sendRDQuery) && qtype == QType::ANY)
)
)
{
uint32_t lowestTTL = rec.d_ttl;
ne.d_name = qname;
- ne.d_qtype = QType(0); // this encodes 'whole record'
+ ne.d_qtype = QType::ENT; // this encodes 'whole record'
harvestNXRecords(lwr.d_records, ne, d_now.tv_sec, &lowestTTL);
cspmap_t csp = harvestCSPFromNE(ne);
return true;
}
-void SyncRes::handleNewTarget(const std::string& prefix, const DNSName& qname, const DNSName& newtarget, uint16_t qtype, std::vector<DNSRecord>& ret, int& rcode, int depth, const std::vector<DNSRecord>& recordsFromAnswer, vState& state)
+void SyncRes::handleNewTarget(const std::string& prefix, const DNSName& qname, const DNSName& newtarget, QType qtype, std::vector<DNSRecord>& ret, int& rcode, int depth, const std::vector<DNSRecord>& recordsFromAnswer, vState& state)
{
if (newtarget == qname) {
LOG(prefix<<qname<<": status=got a CNAME referral to self, returning SERVFAIL"<<endl);
set<GetBestNSAnswer> beenthere;
vState cnameState = vState::Indeterminate;
- rcode = doResolve(newtarget, QType(qtype), ret, depth + 1, beenthere, cnameState);
+ rcode = doResolve(newtarget, qtype, ret, depth + 1, beenthere, cnameState);
LOG(prefix<<qname<<": updating validation state for response to "<<qname<<" from "<<state<<" with the state from the CNAME quest: "<<cnameState<<endl);
updateValidationState(state, cnameState);
}
* -1 in case of no results
* rcode otherwise
*/
-int SyncRes::doResolveAt(NsSet &nameservers, DNSName auth, bool flawedNSSet, const DNSName &qname, const QType &qtype,
+int SyncRes::doResolveAt(NsSet &nameservers, DNSName auth, bool flawedNSSet, const DNSName &qname, QType qtype,
vector<DNSRecord>&ret,
unsigned int depth, set<GetBestNSAnswer>&beenthere, vState& state, StopAtDelegation* stopAtDelegation)
{
SyncRes sr(now);
int res = -1;
try {
- res = sr.beginResolve(qname, QType(qtype), qclass, ret, 0);
+ res = sr.beginResolve(qname, qtype, qclass, ret, 0);
}
catch(const PDNSException& e) {
g_log<<Logger::Error<<"Failed to resolve "<<qname<<", got pdns exception: "<<e.reason<<endl;
vector<DNSRecord> ret;
int res=-1;
try {
- res=sr.beginResolve(g_rootdnsname, QType(QType::NS), 1, ret, depth + 1);
+ res=sr.beginResolve(g_rootdnsname, QType::NS, 1, ret, depth + 1);
if (g_dnssecmode != DNSSECMode::Off && g_dnssecmode != DNSSECMode::ProcessNoValidate) {
auto state = sr.getValidationState();
if (vStateIsBogus(state)) {
DNSName d_name;
bool d_rdForward{false};
- int getRecords(const DNSName& qname, uint16_t qtype, std::vector<DNSRecord>& records) const;
+ int getRecords(const DNSName& qname, QType qtype, std::vector<DNSRecord>& records) const;
bool isAuth() const
{
return d_servers.empty();
explicit SyncRes(const struct timeval& now);
- int beginResolve(const DNSName &qname, const QType &qtype, uint16_t qclass, vector<DNSRecord>&ret, unsigned int depth = 0);
+ int beginResolve(const DNSName &qname, QType qtype, uint16_t qclass, vector<DNSRecord>&ret, unsigned int depth = 0);
void setId(int id)
{
static EDNSSubnetOpts s_ecsScopeZero;
static LogMode s_lm;
static std::unique_ptr<NetmaskGroup> s_dontQuery;
- const static std::unordered_set<uint16_t> s_redirectionQTypes;
+ const static std::unordered_set<QType> s_redirectionQTypes;
struct GetBestNSAnswer
{
typedef std::map<DNSName,vState> zonesStates_t;
enum StopAtDelegation { DontStop, Stop, Stopped };
- int doResolveAt(NsSet &nameservers, DNSName auth, bool flawedNSSet, const DNSName &qname, const QType &qtype, vector<DNSRecord>&ret,
+ int doResolveAt(NsSet &nameservers, DNSName auth, bool flawedNSSet, const DNSName &qname, QType qtype, vector<DNSRecord>&ret,
unsigned int depth, set<GetBestNSAnswer>&beenthere, vState& state, StopAtDelegation* stopAtDelegation);
bool doResolveAtThisIP(const std::string& prefix, const DNSName& qname, const QType& qtype, LWResult& lwr, boost::optional<Netmask>& ednsmask, const DNSName& auth, bool const sendRDQuery, const bool wasForwarded, const DNSName& nsName, const ComboAddress& remoteIP, bool doTCP, bool& truncated, bool& spoofed);
bool processAnswer(unsigned int depth, LWResult& lwr, const DNSName& qname, const QType& qtype, DNSName& auth, bool wasForwarded, const boost::optional<Netmask> ednsmask, bool sendRDQuery, NsSet &nameservers, std::vector<DNSRecord>& ret, const DNSFilterEngine& dfe, bool* gotNewServers, int* rcode, vState& state, const ComboAddress& remoteIP);
- int doResolve(const DNSName &qname, const QType &qtype, vector<DNSRecord>&ret, unsigned int depth, set<GetBestNSAnswer>& beenthere, vState& state);
- int doResolveNoQNameMinimization(const DNSName &qname, const QType &qtype, vector<DNSRecord>&ret, unsigned int depth, set<GetBestNSAnswer>& beenthere, vState& state, bool* fromCache = NULL, StopAtDelegation* stopAtDelegation = NULL, bool considerforwards = true);
- bool doOOBResolve(const AuthDomain& domain, const DNSName &qname, const QType &qtype, vector<DNSRecord>&ret, int& res);
- bool doOOBResolve(const DNSName &qname, const QType &qtype, vector<DNSRecord>&ret, unsigned int depth, int &res);
+ int doResolve(const DNSName &qname, QType qtype, vector<DNSRecord>&ret, unsigned int depth, set<GetBestNSAnswer>& beenthere, vState& state);
+ int doResolveNoQNameMinimization(const DNSName &qname, QType qtype, vector<DNSRecord>&ret, unsigned int depth, set<GetBestNSAnswer>& beenthere, vState& state, bool* fromCache = NULL, StopAtDelegation* stopAtDelegation = NULL, bool considerforwards = true);
+ bool doOOBResolve(const AuthDomain& domain, const DNSName &qname, QType qtype, vector<DNSRecord>&ret, int& res);
+ bool doOOBResolve(const DNSName &qname, QType qtype, vector<DNSRecord>&ret, unsigned int depth, int &res);
bool isRecursiveForwardOrAuth(const DNSName &qname) const;
domainmap_t::const_iterator getBestAuthZone(DNSName* qname) const;
- bool doCNAMECacheCheck(const DNSName &qname, const QType &qtype, vector<DNSRecord>&ret, unsigned int depth, int &res, vState& state, bool wasAuthZone, bool wasForwardRecurse);
- bool doCacheCheck(const DNSName &qname, const DNSName& authname, bool wasForwardedOrAuthZone, bool wasAuthZone, bool wasForwardRecurse, const QType &qtype, vector<DNSRecord>&ret, unsigned int depth, int &res, vState& state);
- void getBestNSFromCache(const DNSName &qname, const QType &qtype, vector<DNSRecord>&bestns, bool* flawedNSSet, unsigned int depth, set<GetBestNSAnswer>& beenthere, const boost::optional<DNSName>& cutOffDomain = boost::none);
- DNSName getBestNSNamesFromCache(const DNSName &qname, const QType &qtype, NsSet& nsset, bool* flawedNSSet, unsigned int depth, set<GetBestNSAnswer>&beenthere);
+ bool doCNAMECacheCheck(const DNSName &qname, QType qtype, vector<DNSRecord>&ret, unsigned int depth, int &res, vState& state, bool wasAuthZone, bool wasForwardRecurse);
+ bool doCacheCheck(const DNSName &qname, const DNSName& authname, bool wasForwardedOrAuthZone, bool wasAuthZone, bool wasForwardRecurse, QType qtype, vector<DNSRecord>&ret, unsigned int depth, int &res, vState& state);
+ void getBestNSFromCache(const DNSName &qname, QType qtype, vector<DNSRecord>&bestns, bool* flawedNSSet, unsigned int depth, set<GetBestNSAnswer>& beenthere, const boost::optional<DNSName>& cutOffDomain = boost::none);
+ DNSName getBestNSNamesFromCache(const DNSName &qname, QType qtype, NsSet& nsset, bool* flawedNSSet, unsigned int depth, set<GetBestNSAnswer>&beenthere);
inline vector<std::pair<DNSName, float>> shuffleInSpeedOrder(NsSet &nameservers, const string &prefix);
inline vector<ComboAddress> shuffleForwardSpeed(const vector<ComboAddress> &rnameservers, const string &prefix, const bool wasRd);
RCode::rcodes_ updateCacheFromRecords(unsigned int depth, LWResult& lwr, const DNSName& qname, const QType& qtype, const DNSName& auth, bool wasForwarded, const boost::optional<Netmask>, vState& state, bool& needWildcardProof, bool& gatherWildcardProof, unsigned int& wildcardLabelsCount, bool sendRDQuery, const ComboAddress& remoteIP);
bool processRecords(const std::string& prefix, const DNSName& qname, const QType& qtype, const DNSName& auth, LWResult& lwr, const bool sendRDQuery, vector<DNSRecord>& ret, set<DNSName>& nsset, DNSName& newtarget, DNSName& newauth, bool& realreferral, bool& negindic, vState& state, const bool needWildcardProof, const bool gatherwildcardProof, const unsigned int wildcardLabelsCount, int& rcode, unsigned int depth);
- bool doSpecialNamesResolve(const DNSName &qname, const QType &qtype, const uint16_t qclass, vector<DNSRecord> &ret);
+ bool doSpecialNamesResolve(const DNSName &qname, QType qtype, const uint16_t qclass, vector<DNSRecord> &ret);
LWResult::Result asyncresolveWrapper(const ComboAddress& ip, bool ednsMANDATORY, const DNSName& domain, const DNSName& auth, int type, bool doTCP, bool sendRDQuery, struct timeval* now, boost::optional<Netmask>& srcmask, LWResult* res, bool* chained) const;
bool lookForCut(const DNSName& qname, unsigned int depth, const vState existingState, vState& newState);
void computeZoneCuts(const DNSName& begin, const DNSName& end, unsigned int depth);
- void handleNewTarget(const std::string& prefix, const DNSName& qname, const DNSName& newtarget, uint16_t qtype, std::vector<DNSRecord>& ret, int& rcode, int depth, const std::vector<DNSRecord>& recordsFromAnswer, vState& state);
+ void handleNewTarget(const std::string& prefix, const DNSName& qname, const DNSName& newtarget, QType qtype, std::vector<DNSRecord>& ret, int& rcode, int depth, const std::vector<DNSRecord>& recordsFromAnswer, vState& state);
void handlePolicyHit(const std::string& prefix, const DNSName& qname, const QType& qtype, vector<DNSRecord>& ret, bool& done, int& rcode, unsigned int depth);