From: Miod Vallat Date: Fri, 11 Apr 2025 07:29:05 +0000 (+0200) Subject: Introduce ZoneName. X-Git-Tag: dnsdist-2.0.0-alpha2~80^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6d86539827b7ab45a50dadbd609f31315ed1b79c;p=thirdparty%2Fpdns.git Introduce ZoneName. This is currently equivalent to DNSName and is intended to be used for, well, zone names. This will allow specific processing later, and currently make the areas where such names are used more visible. This commit is mostly mechanical and introduces type changes in various API and data fields. --- diff --git a/modules/bindbackend/bindbackend2.cc b/modules/bindbackend/bindbackend2.cc index 3c9b5409d7..7caf87b500 100644 --- a/modules/bindbackend/bindbackend2.cc +++ b/modules/bindbackend/bindbackend2.cc @@ -142,7 +142,7 @@ bool Bind2Backend::safeGetBBDomainInfo(int id, BB2DomainInfo* bbd) return true; } -bool Bind2Backend::safeGetBBDomainInfo(const DNSName& name, BB2DomainInfo* bbd) +bool Bind2Backend::safeGetBBDomainInfo(const ZoneName& name, BB2DomainInfo* bbd) { auto state = s_state.read_lock(); const auto& nameindex = boost::multi_index::get(*state); @@ -154,7 +154,7 @@ bool Bind2Backend::safeGetBBDomainInfo(const DNSName& name, BB2DomainInfo* bbd) return true; } -bool Bind2Backend::safeRemoveBBDomainInfo(const DNSName& name) +bool Bind2Backend::safeRemoveBBDomainInfo(const ZoneName& name) { auto state = s_state.write_lock(); using nameindex_t = state_t::index::type; @@ -202,7 +202,7 @@ void Bind2Backend::setFresh(uint32_t domain_id) setLastCheck(domain_id, time(nullptr)); } -bool Bind2Backend::startTransaction(const DNSName& qname, int id) +bool Bind2Backend::startTransaction(const ZoneName& qname, int id) { if (id < 0) { d_transaction_tmpname.clear(); @@ -436,7 +436,7 @@ void Bind2Backend::getUnfreshSecondaryInfos(vector* unfreshDomains) } } -bool Bind2Backend::getDomainInfo(const DNSName& domain, DomainInfo& di, bool getSerial) +bool Bind2Backend::getDomainInfo(const ZoneName& domain, DomainInfo& di, bool getSerial) { BB2DomainInfo bbd; if (!safeGetBBDomainInfo(domain, &bbd)) @@ -464,7 +464,7 @@ bool Bind2Backend::getDomainInfo(const DNSName& domain, DomainInfo& di, bool get return true; } -void Bind2Backend::alsoNotifies(const DNSName& domain, set* ips) +void Bind2Backend::alsoNotifies(const ZoneName& domain, set* ips) { // combine global list with local list for (const auto& i : this->alsoNotify) { @@ -525,7 +525,7 @@ void Bind2Backend::parseZoneFile(BB2DomainInfo* bbd) /** THIS IS AN INTERNAL FUNCTION! It does moadnsparser prio impedance matching Much of the complication is due to the efforts to benefit from std::string reference counting copy on write semantics */ -void Bind2Backend::insertRecord(std::shared_ptr& records, const DNSName& zoneName, const DNSName& qname, const QType& qtype, const string& content, int ttl, const std::string& hashed, bool* auth) +void Bind2Backend::insertRecord(std::shared_ptr& records, const ZoneName& zoneName, const DNSName& qname, const QType& qtype, const string& content, int ttl, const std::string& hashed, bool* auth) { Bind2DNSRecord bdr; bdr.qname = qname; @@ -569,7 +569,7 @@ string Bind2Backend::DLReloadNowHandler(const vector& parts, Utility::pi for (auto i = parts.begin() + 1; i < parts.end(); ++i) { BB2DomainInfo bbd; - DNSName zone(*i); + ZoneName zone(*i); if (safeGetBBDomainInfo(zone, &bbd)) { Bind2Backend bb2; bb2.queueReloadAndStore(bbd.d_id); @@ -595,7 +595,7 @@ string Bind2Backend::DLDomStatusHandler(const vector& parts, Utility::pi if (parts.size() > 1) { for (auto i = parts.begin() + 1; i < parts.end(); ++i) { BB2DomainInfo bbd; - if (safeGetBBDomainInfo(DNSName(*i), &bbd)) { + if (safeGetBBDomainInfo(ZoneName(*i), &bbd)) { ret << *i << ": " << (bbd.d_loaded ? "" : "[rejected]") << "\t" << bbd.d_status << "\n"; } else { @@ -657,7 +657,7 @@ string Bind2Backend::DLDomExtendedStatusHandler(const vector& parts, Uti if (parts.size() > 1) { for (auto i = parts.begin() + 1; i < parts.end(); ++i) { BB2DomainInfo bbd; - if (safeGetBBDomainInfo(DNSName(*i), &bbd)) { + if (safeGetBBDomainInfo(ZoneName(*i), &bbd)) { printDomainExtendedStatus(ret, bbd); } else { @@ -695,7 +695,7 @@ string Bind2Backend::DLAddDomainHandler(const vector& parts, Utility::pi if (parts.size() < 3) return "ERROR: Domain name and zone filename are required"; - DNSName domainname(parts[1]); + ZoneName domainname(parts[1]); const string& filename = parts[2]; BB2DomainInfo bbd; if (safeGetBBDomainInfo(domainname, &bbd)) @@ -793,7 +793,7 @@ void Bind2Backend::reload() } } -void Bind2Backend::fixupOrderAndAuth(std::shared_ptr& records, const DNSName& zoneName, bool nsec3zone, const NSEC3PARAMRecordContent& ns3pr) +void Bind2Backend::fixupOrderAndAuth(std::shared_ptr& records, const ZoneName& zoneName, bool nsec3zone, const NSEC3PARAMRecordContent& ns3pr) { bool skip; DNSName shorter; @@ -831,7 +831,7 @@ void Bind2Backend::fixupOrderAndAuth(std::shared_ptr& records, } } -void Bind2Backend::doEmptyNonTerminals(std::shared_ptr& records, const DNSName& zoneName, bool nsec3zone, const NSEC3PARAMRecordContent& ns3pr) +void Bind2Backend::doEmptyNonTerminals(std::shared_ptr& records, const ZoneName& zoneName, bool nsec3zone, const NSEC3PARAMRecordContent& ns3pr) { bool auth = false; DNSName shorter; @@ -905,7 +905,8 @@ void Bind2Backend::loadConfig(string* status) // NOLINT(readability-function-cog g_log << Logger::Warning << d_logprefix << " Parsing " << domains.size() << " domain(s), will report when done" << endl; - set oldnames, newnames; + set oldnames; + set newnames; { auto state = s_state.read_lock(); for (const BB2DomainInfo& bbd : *state) { @@ -1019,12 +1020,12 @@ void Bind2Backend::loadConfig(string* status) // NOLINT(readability-function-cog safePutBBDomainInfo(bbd); } } - vector diff; + vector diff; set_difference(oldnames.begin(), oldnames.end(), newnames.begin(), newnames.end(), back_inserter(diff)); unsigned int remdomains = diff.size(); - for (const DNSName& name : diff) { + for (const ZoneName& name : diff) { safeRemoveBBDomainInfo(name); } @@ -1155,7 +1156,7 @@ void Bind2Backend::lookup(const QType& qtype, const DNSName& qname, int zoneId, static bool mustlog = ::arg().mustDo("query-logging"); bool found = false; - DNSName domain; + ZoneName domain; BB2DomainInfo bbd; if (mustlog) @@ -1290,7 +1291,7 @@ bool Bind2Backend::handle::get_normal(DNSResourceRecord& r) return true; } -bool Bind2Backend::list(const DNSName& /* target */, int id, bool /* include_disabled */) +bool Bind2Backend::list(const ZoneName& /* target */, int id, bool /* include_disabled */) { BB2DomainInfo bbd; @@ -1354,7 +1355,7 @@ bool Bind2Backend::autoPrimariesList(std::vector& primaries) return true; } -bool Bind2Backend::autoPrimaryBackend(const string& ip, const DNSName& /* domain */, const vector& /* nsset */, string* /* nameserver */, string* account, DNSBackend** db) +bool Bind2Backend::autoPrimaryBackend(const string& ip, const ZoneName& /* domain */, const vector& /* nsset */, string* /* nameserver */, string* account, DNSBackend** db) { // Check whether we have a configfile available. if (getArg("autoprimary-config").empty()) @@ -1390,7 +1391,7 @@ bool Bind2Backend::autoPrimaryBackend(const string& ip, const DNSName& /* domain return true; } -BB2DomainInfo Bind2Backend::createDomainEntry(const DNSName& domain, const string& filename) +BB2DomainInfo Bind2Backend::createDomainEntry(const ZoneName& domain, const string& filename) { int newid = 1; { // Find a free zone id nr. @@ -1413,7 +1414,7 @@ BB2DomainInfo Bind2Backend::createDomainEntry(const DNSName& domain, const strin return bbd; } -bool Bind2Backend::createSecondaryDomain(const string& ip, const DNSName& domain, const string& /* nameserver */, const string& account) +bool Bind2Backend::createSecondaryDomain(const string& ip, const ZoneName& domain, const string& /* nameserver */, const string& account) { string filename = getArg("autoprimary-destdir") + '/' + domain.toStringNoDot(); diff --git a/modules/bindbackend/bindbackend2.hh b/modules/bindbackend/bindbackend2.hh index 9fee224004..8b0adb2d8c 100644 --- a/modules/bindbackend/bindbackend2.hh +++ b/modules/bindbackend/bindbackend2.hh @@ -147,7 +147,7 @@ public: return d_checkinterval; } - DNSName d_name; //!< actual name of the domain + ZoneName d_name; //!< actual name of the domain DomainInfo::DomainKind d_kind{DomainInfo::Native}; //!< the kind of domain string d_filename; //!< full absolute filename of the zone on disk string d_status; //!< message describing status of a domain, for human consumption @@ -184,12 +184,12 @@ public: unsigned int getCapabilities() override; void getUnfreshSecondaryInfos(vector* unfreshDomains) override; void getUpdatedPrimaries(vector& changedDomains, std::unordered_set& catalogs, CatalogHashMap& catalogHashes) override; - bool getDomainInfo(const DNSName& domain, DomainInfo& di, bool getSerial = true) override; + bool getDomainInfo(const ZoneName& domain, DomainInfo& di, bool getSerial = true) override; time_t getCtime(const string& fname); // DNSSEC bool getBeforeAndAfterNamesAbsolute(uint32_t id, const DNSName& qname, DNSName& unhashed, DNSName& before, DNSName& after) override; void lookup(const QType&, const DNSName& qdomain, int zoneId, DNSPacket* p = nullptr) override; - bool list(const DNSName& target, int id, bool include_disabled = false) override; + bool list(const ZoneName& target, int id, bool include_disabled = false) override; bool get(DNSResourceRecord&) override; void getAllDomains(vector* domains, bool getSerial, bool include_disabled = false) override; @@ -199,24 +199,24 @@ public: void setStale(uint32_t domain_id) override; void setFresh(uint32_t domain_id) override; void setNotified(uint32_t id, uint32_t serial) override; - bool startTransaction(const DNSName& qname, int id) override; + bool startTransaction(const ZoneName& qname, int id) override; bool feedRecord(const DNSResourceRecord& rr, const DNSName& ordername, bool ordernameIsNSEC3 = false) override; bool commitTransaction() override; bool abortTransaction() override; - void alsoNotifies(const DNSName& domain, set* ips) override; + void alsoNotifies(const ZoneName& domain, set* ips) override; bool searchRecords(const string& pattern, size_t maxResults, vector& result) override; // the DNSSEC related (getDomainMetadata has broader uses too) - bool getAllDomainMetadata(const DNSName& name, std::map>& meta) override; - bool getDomainMetadata(const DNSName& name, const std::string& kind, std::vector& meta) override; - bool setDomainMetadata(const DNSName& name, const std::string& kind, const std::vector& meta) override; - bool getDomainKeys(const DNSName& name, std::vector& keys) override; - bool removeDomainKey(const DNSName& name, unsigned int id) override; - bool addDomainKey(const DNSName& name, const KeyData& key, int64_t& id) override; - bool activateDomainKey(const DNSName& name, unsigned int id) override; - bool deactivateDomainKey(const DNSName& name, unsigned int id) override; - bool publishDomainKey(const DNSName& name, unsigned int id) override; - bool unpublishDomainKey(const DNSName& name, unsigned int id) override; + bool getAllDomainMetadata(const ZoneName& name, std::map>& meta) override; + bool getDomainMetadata(const ZoneName& name, const std::string& kind, std::vector& meta) override; + bool setDomainMetadata(const ZoneName& name, const std::string& kind, const std::vector& meta) override; + bool getDomainKeys(const ZoneName& name, std::vector& keys) override; + bool removeDomainKey(const ZoneName& name, unsigned int id) override; + bool addDomainKey(const ZoneName& name, const KeyData& key, int64_t& id) override; + bool activateDomainKey(const ZoneName& name, unsigned int id) override; + bool deactivateDomainKey(const ZoneName& name, unsigned int id) override; + bool publishDomainKey(const ZoneName& name, unsigned int id) override; + bool unpublishDomainKey(const ZoneName& name, unsigned int id) override; bool getTSIGKey(const DNSName& name, DNSName& algorithm, string& content) override; bool setTSIGKey(const DNSName& name, const DNSName& algorithm, const string& content) override; bool deleteTSIGKey(const DNSName& name) override; @@ -225,7 +225,7 @@ public: typedef multi_index_container>, - ordered_unique, member>>> + ordered_unique, member>>> state_t; static SharedLockGuarded s_state; @@ -234,9 +234,9 @@ public: // for autoprimary support bool autoPrimariesList(std::vector& primaries) override; - bool autoPrimaryBackend(const string& ip, const DNSName& domain, const vector& nsset, string* nameserver, string* account, DNSBackend** db) override; + bool autoPrimaryBackend(const string& ip, const ZoneName& domain, const vector& nsset, string* nameserver, string* account, DNSBackend** db) override; static std::mutex s_autosecondary_config_lock; - bool createSecondaryDomain(const string& ip, const DNSName& domain, const string& nameserver, const string& account) override; + bool createSecondaryDomain(const string& ip, const ZoneName& domain, const string& nameserver, const string& account) override; private: void setupDNSSEC(); @@ -244,12 +244,12 @@ private: void freeStatements(); static bool safeGetBBDomainInfo(int id, BB2DomainInfo* bbd); static void safePutBBDomainInfo(const BB2DomainInfo& bbd); - static bool safeGetBBDomainInfo(const DNSName& name, BB2DomainInfo* bbd); - static bool safeRemoveBBDomainInfo(const DNSName& name); + static bool safeGetBBDomainInfo(const ZoneName& name, BB2DomainInfo* bbd); + static bool safeRemoveBBDomainInfo(const ZoneName& name); shared_ptr d_dnssecdb; - bool getNSEC3PARAM(const DNSName& name, NSEC3PARAMRecordContent* ns3p); + bool getNSEC3PARAM(const ZoneName& name, NSEC3PARAMRecordContent* ns3p); void setLastCheck(uint32_t domain_id, time_t lastcheck); - bool getNSEC3PARAMuncached(const DNSName& name, NSEC3PARAMRecordContent* ns3p); + bool getNSEC3PARAMuncached(const ZoneName& name, NSEC3PARAMRecordContent* ns3p); class handle { public: @@ -267,7 +267,7 @@ private: recordstorage_t::const_iterator d_qname_iter, d_qname_end; DNSName qname; - DNSName domain; + ZoneName domain; int id{-1}; QType qtype; @@ -296,7 +296,7 @@ private: unique_ptr d_deleteTSIGKeyQuery_stmt; unique_ptr d_getTSIGKeysQuery_stmt; - DNSName d_transaction_qname; + ZoneName d_transaction_qname; string d_transaction_tmpname; string d_logprefix; set alsoNotify; //!< this is used to store the also-notify list of interested peers. @@ -309,18 +309,18 @@ private: bool d_hybrid; bool d_upgradeContent; - BB2DomainInfo createDomainEntry(const DNSName& domain, const string& filename); //!< does not insert in s_state + BB2DomainInfo createDomainEntry(const ZoneName& domain, const string& filename); //!< does not insert in s_state void queueReloadAndStore(unsigned int id); static bool findBeforeAndAfterUnhashed(std::shared_ptr& records, const DNSName& qname, DNSName& unhashed, DNSName& before, DNSName& after); - static void insertRecord(std::shared_ptr& records, const DNSName& zoneName, const DNSName& qname, const QType& qtype, const string& content, int ttl, const std::string& hashed = string(), bool* auth = nullptr); + static void insertRecord(std::shared_ptr& records, const ZoneName& zoneName, const DNSName& qname, const QType& qtype, const string& content, int ttl, const std::string& hashed = string(), bool* auth = nullptr); void reload() override; static string DLDomStatusHandler(const vector& parts, Utility::pid_t ppid); static string DLDomExtendedStatusHandler(const vector& parts, Utility::pid_t ppid); static string DLListRejectsHandler(const vector& parts, Utility::pid_t ppid); static string DLReloadNowHandler(const vector& parts, Utility::pid_t ppid); static string DLAddDomainHandler(const vector& parts, Utility::pid_t ppid); - static void fixupOrderAndAuth(std::shared_ptr& records, const DNSName& zoneName, bool nsec3zone, const NSEC3PARAMRecordContent& ns3pr); - static void doEmptyNonTerminals(std::shared_ptr& records, const DNSName& zoneName, bool nsec3zone, const NSEC3PARAMRecordContent& ns3pr); + static void fixupOrderAndAuth(std::shared_ptr& records, const ZoneName& zoneName, bool nsec3zone, const NSEC3PARAMRecordContent& ns3pr); + static void doEmptyNonTerminals(std::shared_ptr& records, const ZoneName& zoneName, bool nsec3zone, const NSEC3PARAMRecordContent& ns3pr); void loadConfig(string* status = nullptr); }; diff --git a/modules/bindbackend/binddnssec.cc b/modules/bindbackend/binddnssec.cc index 8bd46b5f8b..4e3ce26072 100644 --- a/modules/bindbackend/binddnssec.cc +++ b/modules/bindbackend/binddnssec.cc @@ -45,62 +45,62 @@ unsigned int Bind2Backend::getCapabilities() return caps; } -bool Bind2Backend::getNSEC3PARAM(const DNSName& /* name */, NSEC3PARAMRecordContent* /* ns3p */) +bool Bind2Backend::getNSEC3PARAM(const ZoneName& /* name */, NSEC3PARAMRecordContent* /* ns3p */) { return false; } -bool Bind2Backend::getNSEC3PARAMuncached(const DNSName& /* name */, NSEC3PARAMRecordContent* /* ns3p */) +bool Bind2Backend::getNSEC3PARAMuncached(const ZoneName& /* name */, NSEC3PARAMRecordContent* /* ns3p */) { return false; } -bool Bind2Backend::getAllDomainMetadata(const DNSName& /* name */, std::map>& /* meta */) +bool Bind2Backend::getAllDomainMetadata(const ZoneName& /* name */, std::map>& /* meta */) { return false; } -bool Bind2Backend::getDomainMetadata(const DNSName& /* name */, const std::string& /* kind */, std::vector& /* meta */) +bool Bind2Backend::getDomainMetadata(const ZoneName& /* name */, const std::string& /* kind */, std::vector& /* meta */) { return false; } -bool Bind2Backend::setDomainMetadata(const DNSName& /* name */, const std::string& /* kind */, const std::vector& /* meta */) +bool Bind2Backend::setDomainMetadata(const ZoneName& /* name */, const std::string& /* kind */, const std::vector& /* meta */) { return false; } -bool Bind2Backend::getDomainKeys(const DNSName& /* name */, std::vector& /* keys */) +bool Bind2Backend::getDomainKeys(const ZoneName& /* name */, std::vector& /* keys */) { return false; } -bool Bind2Backend::removeDomainKey(const DNSName& /* name */, unsigned int /* id */) +bool Bind2Backend::removeDomainKey(const ZoneName& /* name */, unsigned int /* id */) { return false; } -bool Bind2Backend::addDomainKey(const DNSName& /* name */, const KeyData& /* key */, int64_t& /* id */) +bool Bind2Backend::addDomainKey(const ZoneName& /* name */, const KeyData& /* key */, int64_t& /* id */) { return false; } -bool Bind2Backend::activateDomainKey(const DNSName& /* name */, unsigned int /* id */) +bool Bind2Backend::activateDomainKey(const ZoneName& /* name */, unsigned int /* id */) { return false; } -bool Bind2Backend::deactivateDomainKey(const DNSName& /* name */, unsigned int /* id */) +bool Bind2Backend::deactivateDomainKey(const ZoneName& /* name */, unsigned int /* id */) { return false; } -bool Bind2Backend::publishDomainKey(const DNSName& /* name */, unsigned int /* id */) +bool Bind2Backend::publishDomainKey(const ZoneName& /* name */, unsigned int /* id */) { return false; } -bool Bind2Backend::unpublishDomainKey(const DNSName& /* name */, unsigned int /* id */) +bool Bind2Backend::unpublishDomainKey(const ZoneName& /* name */, unsigned int /* id */) { return false; } @@ -210,7 +210,7 @@ unsigned int Bind2Backend::getCapabilities() return caps; } -bool Bind2Backend::getNSEC3PARAM(const DNSName& name, NSEC3PARAMRecordContent* ns3p) +bool Bind2Backend::getNSEC3PARAM(const ZoneName& name, NSEC3PARAMRecordContent* ns3p) { BB2DomainInfo bbd; if (!safeGetBBDomainInfo(name, &bbd)) @@ -223,7 +223,7 @@ bool Bind2Backend::getNSEC3PARAM(const DNSName& name, NSEC3PARAMRecordContent* n return bbd.d_nsec3zone; } -bool Bind2Backend::getNSEC3PARAMuncached(const DNSName& name, NSEC3PARAMRecordContent* ns3p) +bool Bind2Backend::getNSEC3PARAMuncached(const ZoneName& name, NSEC3PARAMRecordContent* ns3p) { if (!d_dnssecdb || d_hybrid) return false; @@ -255,7 +255,7 @@ bool Bind2Backend::getNSEC3PARAMuncached(const DNSName& name, NSEC3PARAMRecordCo return true; } -bool Bind2Backend::getAllDomainMetadata(const DNSName& name, std::map>& meta) +bool Bind2Backend::getAllDomainMetadata(const ZoneName& name, std::map>& meta) { if (!d_dnssecdb || d_hybrid) return false; @@ -277,7 +277,7 @@ bool Bind2Backend::getAllDomainMetadata(const DNSName& name, std::map& meta) +bool Bind2Backend::getDomainMetadata(const ZoneName& name, const std::string& kind, std::vector& meta) { if (!d_dnssecdb || d_hybrid) return false; @@ -299,7 +299,7 @@ bool Bind2Backend::getDomainMetadata(const DNSName& name, const std::string& kin return true; } -bool Bind2Backend::setDomainMetadata(const DNSName& name, const std::string& kind, const std::vector& meta) +bool Bind2Backend::setDomainMetadata(const ZoneName& name, const std::string& kind, const std::vector& meta) { if (!d_dnssecdb || d_hybrid) return false; @@ -318,7 +318,7 @@ bool Bind2Backend::setDomainMetadata(const DNSName& name, const std::string& kin return true; } -bool Bind2Backend::getDomainKeys(const DNSName& name, std::vector& keys) +bool Bind2Backend::getDomainKeys(const ZoneName& name, std::vector& keys) { if (!d_dnssecdb || d_hybrid) return false; @@ -346,7 +346,7 @@ bool Bind2Backend::getDomainKeys(const DNSName& name, std::vector& keys return true; } -bool Bind2Backend::removeDomainKey(const DNSName& name, unsigned int id) +bool Bind2Backend::removeDomainKey(const ZoneName& name, unsigned int id) { if (!d_dnssecdb || d_hybrid) return false; @@ -360,7 +360,7 @@ bool Bind2Backend::removeDomainKey(const DNSName& name, unsigned int id) return true; } -bool Bind2Backend::addDomainKey(const DNSName& name, const KeyData& key, int64_t& id) +bool Bind2Backend::addDomainKey(const ZoneName& name, const KeyData& key, int64_t& id) { if (!d_dnssecdb || d_hybrid) return false; @@ -395,7 +395,7 @@ bool Bind2Backend::addDomainKey(const DNSName& name, const KeyData& key, int64_t } } -bool Bind2Backend::activateDomainKey(const DNSName& name, unsigned int id) +bool Bind2Backend::activateDomainKey(const ZoneName& name, unsigned int id) { if (!d_dnssecdb || d_hybrid) return false; @@ -409,7 +409,7 @@ bool Bind2Backend::activateDomainKey(const DNSName& name, unsigned int id) return true; } -bool Bind2Backend::deactivateDomainKey(const DNSName& name, unsigned int id) +bool Bind2Backend::deactivateDomainKey(const ZoneName& name, unsigned int id) { if (!d_dnssecdb || d_hybrid) return false; @@ -423,7 +423,7 @@ bool Bind2Backend::deactivateDomainKey(const DNSName& name, unsigned int id) return true; } -bool Bind2Backend::publishDomainKey(const DNSName& name, unsigned int id) +bool Bind2Backend::publishDomainKey(const ZoneName& name, unsigned int id) { if (!d_dnssecdb || d_hybrid) return false; @@ -437,7 +437,7 @@ bool Bind2Backend::publishDomainKey(const DNSName& name, unsigned int id) return true; } -bool Bind2Backend::unpublishDomainKey(const DNSName& name, unsigned int id) +bool Bind2Backend::unpublishDomainKey(const ZoneName& name, unsigned int id) { if (!d_dnssecdb || d_hybrid) return false; diff --git a/modules/geoipbackend/geoipbackend.cc b/modules/geoipbackend/geoipbackend.cc index f8781e2811..60e9b23611 100644 --- a/modules/geoipbackend/geoipbackend.cc +++ b/modules/geoipbackend/geoipbackend.cc @@ -57,7 +57,7 @@ struct GeoIPService struct GeoIPDomain { std::uint32_t id{}; - DNSName domain; + ZoneName domain; int ttl{}; map services; map> records; @@ -903,7 +903,7 @@ void GeoIPBackend::rediscover(string* /* status */) reload(); } -bool GeoIPBackend::getDomainInfo(const DNSName& domain, DomainInfo& di, bool /* getSerial */) +bool GeoIPBackend::getDomainInfo(const ZoneName& domain, DomainInfo& di, bool /* getSerial */) { ReadLock rl(&s_state_lock); @@ -939,7 +939,7 @@ void GeoIPBackend::getAllDomains(vector* domains, bool /* getSerial } } -bool GeoIPBackend::getAllDomainMetadata(const DNSName& name, std::map>& meta) +bool GeoIPBackend::getAllDomainMetadata(const ZoneName& name, std::map>& meta) { if (!d_dnssec) return false; @@ -957,7 +957,7 @@ bool GeoIPBackend::getAllDomainMetadata(const DNSName& name, std::map& meta) +bool GeoIPBackend::getDomainMetadata(const ZoneName& name, const std::string& kind, std::vector& meta) { if (!d_dnssec) return false; @@ -977,7 +977,7 @@ bool GeoIPBackend::getDomainMetadata(const DNSName& name, const std::string& kin return false; } -bool GeoIPBackend::getDomainKeys(const DNSName& name, std::vector& keys) +bool GeoIPBackend::getDomainKeys(const ZoneName& name, std::vector& keys) { if (!d_dnssec) return false; @@ -1021,7 +1021,7 @@ bool GeoIPBackend::getDomainKeys(const DNSName& name, std::vector* domains, bool getSerial, bool include_disabled) override; // dnssec support - bool getAllDomainMetadata(const DNSName& name, std::map>& meta) override; - bool getDomainMetadata(const DNSName& name, const std::string& kind, std::vector& meta) override; - bool getDomainKeys(const DNSName& name, std::vector& keys) override; - bool removeDomainKey(const DNSName& name, unsigned int id) override; - bool addDomainKey(const DNSName& name, const KeyData& key, int64_t& id) override; - bool activateDomainKey(const DNSName& name, unsigned int id) override; - bool deactivateDomainKey(const DNSName& name, unsigned int id) override; - bool publishDomainKey(const DNSName& name, unsigned int id) override; - bool unpublishDomainKey(const DNSName& name, unsigned int id) override; + bool getAllDomainMetadata(const ZoneName& name, std::map>& meta) override; + bool getDomainMetadata(const ZoneName& name, const std::string& kind, std::vector& meta) override; + bool getDomainKeys(const ZoneName& name, std::vector& keys) override; + bool removeDomainKey(const ZoneName& name, unsigned int id) override; + bool addDomainKey(const ZoneName& name, const KeyData& key, int64_t& id) override; + bool activateDomainKey(const ZoneName& name, unsigned int id) override; + bool deactivateDomainKey(const ZoneName& name, unsigned int id) override; + bool publishDomainKey(const ZoneName& name, unsigned int id) override; + bool unpublishDomainKey(const ZoneName& name, unsigned int id) override; private: static ReadWriteLock s_state_lock; @@ -89,7 +89,7 @@ private: void initialize(); string format2str(string format, const Netmask& addr, GeoIPNetmask& gl, const GeoIPDomain& dom); bool d_dnssec{}; - bool hasDNSSECkey(const DNSName& name); + bool hasDNSSECkey(const ZoneName& name); bool lookup_static(const GeoIPDomain& dom, const DNSName& search, const QType& qtype, const DNSName& qdomain, const Netmask& addr, GeoIPNetmask& gl); void setupNetmasks(const YAML::Node& domain, GeoIPDomain& dom); bool loadDomain(const YAML::Node& domain, std::uint32_t domainID, GeoIPDomain& dom); diff --git a/modules/ldapbackend/ldapbackend.hh b/modules/ldapbackend/ldapbackend.hh index 77cab28fc2..b6209b2496 100644 --- a/modules/ldapbackend/ldapbackend.hh +++ b/modules/ldapbackend/ldapbackend.hh @@ -142,11 +142,11 @@ class LdapBackend : public DNSBackend PowerLDAP* d_pldap; LdapAuthenticator* d_authenticator; - bool (LdapBackend::*d_list_fcnt)(const DNSName&, int); + bool (LdapBackend::*d_list_fcnt)(const ZoneName&, int); void (LdapBackend::*d_lookup_fcnt)(const QType&, const DNSName&, DNSPacket*, int); - bool list_simple(const DNSName& target, int domain_id); - bool list_strict(const DNSName& target, int domain_id); + bool list_simple(const ZoneName& target, int domain_id); + bool list_strict(const ZoneName& target, int domain_id); void lookup_simple(const QType& qtype, const DNSName& qdomain, DNSPacket* p, int zoneid); void lookup_strict(const QType& qtype, const DNSName& qdomain, DNSPacket* p, int zoneid); @@ -171,11 +171,11 @@ public: // Native backend unsigned int getCapabilities() override { return CAP_LIST; } - bool list(const DNSName& target, int domain_id, bool include_disabled = false) override; + bool list(const ZoneName& target, int domain_id, bool include_disabled = false) override; void lookup(const QType& qtype, const DNSName& qdomain, int zoneid, DNSPacket* p = nullptr) override; bool get(DNSResourceRecord& rr) override; - bool getDomainInfo(const DNSName& domain, DomainInfo& di, bool getSerial = true) override; + bool getDomainInfo(const ZoneName& domain, DomainInfo& di, bool getSerial = true) override; // Primary backend void getUpdatedPrimaries(vector& domains, std::unordered_set& catalogs, CatalogHashMap& catalogHashes) override; diff --git a/modules/ldapbackend/native.cc b/modules/ldapbackend/native.cc index 48421ea99c..6373b7c64b 100644 --- a/modules/ldapbackend/native.cc +++ b/modules/ldapbackend/native.cc @@ -24,7 +24,7 @@ #include "ldapbackend.hh" #include -bool LdapBackend::list(const DNSName& target, int domain_id, bool /* include_disabled */) +bool LdapBackend::list(const ZoneName& target, int domain_id, bool /* include_disabled */) { try { d_in_list = true; @@ -57,7 +57,7 @@ bool LdapBackend::list(const DNSName& target, int domain_id, bool /* include_dis return false; } -bool LdapBackend::list_simple(const DNSName& target, int /* domain_id */) +bool LdapBackend::list_simple(const ZoneName& target, int /* domain_id */) { string dn; string filter; @@ -92,7 +92,7 @@ bool LdapBackend::list_simple(const DNSName& target, int /* domain_id */) return true; } -bool LdapBackend::list_strict(const DNSName& target, int domain_id) +bool LdapBackend::list_strict(const ZoneName& target, int domain_id) { if (target.isPartOf(DNSName("in-addr.arpa")) || target.isPartOf(DNSName("ip6.arpa"))) { g_log << Logger::Warning << d_myname << " Request for reverse zone AXFR, but this is not supported in strict mode" << endl; @@ -318,7 +318,7 @@ bool LdapBackend::get(DNSResourceRecord& rr) return true; } -bool LdapBackend::getDomainInfo(const DNSName& domain, DomainInfo& di, bool /* getSerial */) +bool LdapBackend::getDomainInfo(const ZoneName& domain, DomainInfo& di, bool /* getSerial */) { string filter; SOAData sd; @@ -369,7 +369,7 @@ bool LdapBackend::getDomainInfo(const DNSName& domain, DomainInfo& di, bool /* g di.id = 0; di.serial = sd.serial; - di.zone = DNSName(domain); + di.zone = domain; if (result.count("PdnsDomainLastCheck") && !result["PdnsDomainLastCheck"].empty()) pdns::checked_stoi_into(di.last_check, result["PdnsDomainLastCheck"][0]); diff --git a/modules/ldapbackend/primary.cc b/modules/ldapbackend/primary.cc index 13c112d14f..ddee33b611 100644 --- a/modules/ldapbackend/primary.cc +++ b/modules/ldapbackend/primary.cc @@ -62,7 +62,7 @@ void LdapBackend::getUpdatedPrimaries(vector& domains, std::unordere continue; DomainInfo di; - if (!getDomainInfo(DNSName(result["associatedDomain"][0]), di)) + if (!getDomainInfo(ZoneName(result["associatedDomain"][0]), di)) continue; if (di.notified_serial < di.serial) diff --git a/modules/lmdbbackend/lmdbbackend.cc b/modules/lmdbbackend/lmdbbackend.cc index e67ceceb5f..da492110fe 100644 --- a/modules/lmdbbackend/lmdbbackend.cc +++ b/modules/lmdbbackend/lmdbbackend.cc @@ -1074,7 +1074,7 @@ void LMDBBackend::deleteDomainRecords(RecordsRWTransaction& txn, uint32_t domain */ -bool LMDBBackend::startTransaction(const DNSName& domain, int domain_id) +bool LMDBBackend::startTransaction(const ZoneName& domain, int domain_id) { // cout <<"startTransaction("<getROTransaction(); @@ -1686,7 +1686,7 @@ bool LMDBBackend::getDomainInfo(const DNSName& domain, DomainInfo& di, bool gets return true; } -int LMDBBackend::genChangeDomain(const DNSName& domain, const std::function& func) +int LMDBBackend::genChangeDomain(const ZoneName& domain, const std::function& func) { auto txn = d_tdomains->getRWTransaction(); @@ -1717,28 +1717,28 @@ int LMDBBackend::genChangeDomain(uint32_t id, const std::function& primaries) +bool LMDBBackend::setPrimaries(const ZoneName& domain, const vector& primaries) { return genChangeDomain(domain, [&primaries](DomainInfo& di) { di.primaries = primaries; }); } -bool LMDBBackend::createDomain(const DNSName& domain, const DomainInfo::DomainKind kind, const vector& primaries, const string& account) +bool LMDBBackend::createDomain(const ZoneName& domain, const DomainInfo::DomainKind kind, const vector& primaries, const string& account) { DomainInfo di; @@ -1764,8 +1764,8 @@ void LMDBBackend::getAllDomainsFiltered(vector* domains, const std:: { auto txn = d_tdomains->getROTransaction(); if (d_handle_dups) { - map zonemap; - set dups; + map zonemap; + set dups; for (auto iter = txn.begin(); iter != txn.end(); ++iter) { DomainInfo di = *iter; @@ -1910,7 +1910,7 @@ public: std::runtime_error("getCatalogMembers should return false") {} }; -bool LMDBBackend::getCatalogMembers(const DNSName& catalog, vector& members, CatalogInfo::CatalogType type) +bool LMDBBackend::getCatalogMembers(const ZoneName& catalog, vector& members, CatalogInfo::CatalogType type) { vector scratch; @@ -1943,21 +1943,21 @@ bool LMDBBackend::getCatalogMembers(const DNSName& catalog, vector& return true; } -bool LMDBBackend::setOptions(const DNSName& domain, const std::string& options) +bool LMDBBackend::setOptions(const ZoneName& domain, const std::string& options) { return genChangeDomain(domain, [options](DomainInfo& di) { di.options = options; }); } -bool LMDBBackend::setCatalog(const DNSName& domain, const DNSName& catalog) +bool LMDBBackend::setCatalog(const ZoneName& domain, const ZoneName& catalog) { return genChangeDomain(domain, [catalog](DomainInfo& di) { di.catalog = catalog; }); } -bool LMDBBackend::getAllDomainMetadata(const DNSName& name, std::map>& meta) +bool LMDBBackend::getAllDomainMetadata(const ZoneName& name, std::map>& meta) { meta.clear(); auto txn = d_tmeta->getROTransaction(); @@ -1974,7 +1974,7 @@ bool LMDBBackend::getAllDomainMetadata(const DNSName& name, std::map& meta) +bool LMDBBackend::setDomainMetadata(const ZoneName& name, const std::string& kind, const std::vector& meta) { auto txn = d_tmeta->getRWTransaction(); @@ -1999,7 +1999,7 @@ bool LMDBBackend::setDomainMetadata(const DNSName& name, const std::string& kind return true; } -bool LMDBBackend::getDomainKeys(const DNSName& name, std::vector& keys) +bool LMDBBackend::getDomainKeys(const ZoneName& name, std::vector& keys) { auto txn = d_tkdb->getROTransaction(); LmdbIdVec ids; @@ -2017,7 +2017,7 @@ bool LMDBBackend::getDomainKeys(const DNSName& name, std::vector& keys) return true; } -bool LMDBBackend::removeDomainKey(const DNSName& name, unsigned int id) +bool LMDBBackend::removeDomainKey(const ZoneName& name, unsigned int id) { auto txn = d_tkdb->getRWTransaction(); KeyDataDB kdb; @@ -2032,7 +2032,7 @@ bool LMDBBackend::removeDomainKey(const DNSName& name, unsigned int id) return true; } -bool LMDBBackend::addDomainKey(const DNSName& name, const KeyData& key, int64_t& id) +bool LMDBBackend::addDomainKey(const ZoneName& name, const KeyData& key, int64_t& id) { auto txn = d_tkdb->getRWTransaction(); KeyDataDB kdb{name, key.content, key.flags, key.active, key.published}; @@ -2042,7 +2042,7 @@ bool LMDBBackend::addDomainKey(const DNSName& name, const KeyData& key, int64_t& return true; } -bool LMDBBackend::activateDomainKey(const DNSName& name, unsigned int id) +bool LMDBBackend::activateDomainKey(const ZoneName& name, unsigned int id) { auto txn = d_tkdb->getRWTransaction(); KeyDataDB kdb; @@ -2060,7 +2060,7 @@ bool LMDBBackend::activateDomainKey(const DNSName& name, unsigned int id) return true; } -bool LMDBBackend::deactivateDomainKey(const DNSName& name, unsigned int id) +bool LMDBBackend::deactivateDomainKey(const ZoneName& name, unsigned int id) { auto txn = d_tkdb->getRWTransaction(); KeyDataDB kdb; @@ -2077,7 +2077,7 @@ bool LMDBBackend::deactivateDomainKey(const DNSName& name, unsigned int id) return true; } -bool LMDBBackend::publishDomainKey(const DNSName& name, unsigned int id) +bool LMDBBackend::publishDomainKey(const ZoneName& name, unsigned int id) { auto txn = d_tkdb->getRWTransaction(); KeyDataDB kdb; @@ -2095,7 +2095,7 @@ bool LMDBBackend::publishDomainKey(const DNSName& name, unsigned int id) return true; } -bool LMDBBackend::unpublishDomainKey(const DNSName& name, unsigned int id) +bool LMDBBackend::unpublishDomainKey(const ZoneName& name, unsigned int id) { auto txn = d_tkdb->getRWTransaction(); KeyDataDB kdb; @@ -2331,9 +2331,9 @@ bool LMDBBackend::getBeforeAndAfterNamesAbsolute(uint32_t id, const DNSName& qna return true; } -bool LMDBBackend::getBeforeAndAfterNames(uint32_t id, const DNSName& zonenameU, const DNSName& qname, DNSName& before, DNSName& after) +bool LMDBBackend::getBeforeAndAfterNames(uint32_t id, const ZoneName& zonenameU, const DNSName& qname, DNSName& before, DNSName& after) { - DNSName zonename = zonenameU.makeLowerCase(); + ZoneName zonename = zonenameU.makeLowerCase(); // cout << __PRETTY_FUNCTION__<< ": "< nl0 */ if (t.empty()) { - throw std::out_of_range(std::string(__PRETTY_FUNCTION__) + " Attempt to serialize an unset dnsname"); + throw std::out_of_range(std::string(__PRETTY_FUNCTION__) + " Attempt to serialize an unset DNSName"); } if (t.isRoot()) { @@ -63,12 +63,12 @@ public: ~LMDBBackend(); unsigned int getCapabilities() override { return CAP_DNSSEC | CAP_DIRECT | CAP_LIST | CAP_CREATE; } - bool list(const DNSName& target, int id, bool include_disabled) override; + bool list(const ZoneName& target, int id, bool include_disabled) override; - bool getDomainInfo(const DNSName& domain, DomainInfo& di, bool getserial = true) override; - bool createDomain(const DNSName& domain, const DomainInfo::DomainKind kind, const vector& primaries, const string& account) override; + bool getDomainInfo(const ZoneName& domain, DomainInfo& di, bool getserial = true) override; + bool createDomain(const ZoneName& domain, const DomainInfo::DomainKind kind, const vector& primaries, const string& account) override; - bool startTransaction(const DNSName& domain, int domain_id = -1) override; + bool startTransaction(const ZoneName& domain, int domain_id = -1) override; bool commitTransaction() override; bool abortTransaction() override; bool feedRecord(const DNSResourceRecord& r, const DNSName& ordername, bool ordernameIsNSEC3 = false) override; @@ -92,14 +92,14 @@ public: void setNotified(uint32_t id, uint32_t serial) override; // catalog zones - bool getCatalogMembers(const DNSName& catalog, vector& members, CatalogInfo::CatalogType type) override; - bool setOptions(const DNSName& domain, const std::string& options) override; - bool setCatalog(const DNSName& domain, const DNSName& options) override; - - bool setPrimaries(const DNSName& domain, const vector& primaries) override; - bool setKind(const DNSName& domain, const DomainInfo::DomainKind kind) override; - bool getAllDomainMetadata(const DNSName& name, std::map>& meta) override; - bool getDomainMetadata(const DNSName& name, const std::string& kind, std::vector& meta) override + bool getCatalogMembers(const ZoneName& catalog, vector& members, CatalogInfo::CatalogType type) override; + bool setOptions(const ZoneName& domain, const std::string& options) override; + bool setCatalog(const ZoneName& domain, const ZoneName& options) override; + + bool setPrimaries(const ZoneName& domain, const vector& primaries) override; + bool setKind(const ZoneName& domain, const DomainInfo::DomainKind kind) override; + bool getAllDomainMetadata(const ZoneName& name, std::map>& meta) override; + bool getDomainMetadata(const ZoneName& name, const std::string& kind, std::vector& meta) override { // std::cout<<"Request for metadata items for zone "<& meta) override; - bool setAccount(const DNSName& domain, const std::string& account) override; - bool deleteDomain(const DNSName& domain) override; + bool setDomainMetadata(const ZoneName& name, const std::string& kind, const std::vector& meta) override; + bool setAccount(const ZoneName& domain, const std::string& account) override; + bool deleteDomain(const ZoneName& domain) override; - bool getDomainKeys(const DNSName& name, std::vector& keys) override; - bool removeDomainKey(const DNSName& name, unsigned int id) override; - bool addDomainKey(const DNSName& name, const KeyData& key, int64_t& id) override; - bool activateDomainKey(const DNSName& name, unsigned int id) override; - bool deactivateDomainKey(const DNSName& name, unsigned int id) override; - bool publishDomainKey(const DNSName& name, unsigned int id) override; - bool unpublishDomainKey(const DNSName& name, unsigned int id) override; + bool getDomainKeys(const ZoneName& name, std::vector& keys) override; + bool removeDomainKey(const ZoneName& name, unsigned int id) override; + bool addDomainKey(const ZoneName& name, const KeyData& key, int64_t& id) override; + bool activateDomainKey(const ZoneName& name, unsigned int id) override; + bool deactivateDomainKey(const ZoneName& name, unsigned int id) override; + bool publishDomainKey(const ZoneName& name, unsigned int id) override; + bool unpublishDomainKey(const ZoneName& name, unsigned int id) override; // TSIG bool getTSIGKey(const DNSName& name, DNSName& algorithm, string& content) override; @@ -138,7 +138,7 @@ public: bool getBeforeAndAfterNamesAbsolute(uint32_t id, const DNSName& qname, DNSName& unhashed, DNSName& before, DNSName& after) override; - bool getBeforeAndAfterNames(uint32_t id, const DNSName& zonename, const DNSName& qname, DNSName& before, DNSName& after) override; + bool getBeforeAndAfterNames(uint32_t id, const ZoneName& zonename, const DNSName& qname, DNSName& before, DNSName& after) override; bool updateDNSSECOrderNameAndAuth(uint32_t domain_id, const DNSName& qname, const DNSName& ordername, bool auth, const uint16_t qtype = QType::ANY) override; @@ -226,13 +226,13 @@ private: public: struct DomainMeta { - DNSName domain; + ZoneName domain; string key; string value; }; struct KeyDataDB { - DNSName domain; + ZoneName domain; std::string content; unsigned int flags{0}; bool active{true}; @@ -250,15 +250,15 @@ public: private: typedef TypedDBI> + index_on> tdomains_t; typedef TypedDBI> + index_on> tmeta_t; typedef TypedDBI> + index_on> tkdb_t; typedef TypedDBI getRecordsRWTransaction(uint32_t id); std::shared_ptr getRecordsROTransaction(uint32_t id, const std::shared_ptr& rwtxn = nullptr); - int genChangeDomain(const DNSName& domain, const std::function& func); + int genChangeDomain(const ZoneName& domain, const std::function& func); int genChangeDomain(uint32_t id, const std::function& func); void deleteDomainRecords(RecordsRWTransaction& txn, uint32_t domain_id, uint16_t qtype = QType::ANY); @@ -318,7 +318,7 @@ private: bool get_list(DNSZoneRecord& rr); bool get_lookup(DNSZoneRecord& rr); std::string d_matchkey; - DNSName d_lookupdomain; + ZoneName d_lookupdomain; vector d_currentrrset; size_t d_currentrrsetpos; @@ -326,7 +326,7 @@ private: MDBOutVal d_currentVal; bool d_includedisabled; - DNSName d_transactiondomain; + ZoneName d_transactiondomain; uint32_t d_transactiondomainid; bool d_dolog; bool d_random_ids; diff --git a/modules/lua2backend/lua2api2.hh b/modules/lua2backend/lua2api2.hh index acd501fd88..25444f21fd 100644 --- a/modules/lua2backend/lua2api2.hh +++ b/modules/lua2backend/lua2api2.hh @@ -183,7 +183,7 @@ public: g_log << Logger::Debug << "[" << getPrefix() << "] Got empty result" << endl; } - bool list(const DNSName& target, int domain_id, bool /* include_disabled */ = false) override + bool list(const ZoneName& target, int domain_id, bool /* include_disabled */ = false) override { if (f_list == nullptr) { g_log << Logger::Error << "[" << getPrefix() << "] dns_list missing - cannot do AXFR" << endl; @@ -279,7 +279,7 @@ public: logResult("zone=" << di.zone << ",serial=" << di.serial << ",kind=" << di.getKindString()); } - bool getDomainInfo(const DNSName& domain, DomainInfo& di, bool /* getSerial */ = true) override + bool getDomainInfo(const ZoneName& domain, DomainInfo& di, bool /* getSerial */ = true) override { if (f_get_domaininfo == nullptr) { // use getAuth instead @@ -320,7 +320,7 @@ public: } } - bool getAllDomainMetadata(const DNSName& name, std::map>& meta) override + bool getAllDomainMetadata(const ZoneName& name, std::map>& meta) override { if (f_get_all_domain_metadata == nullptr) return false; @@ -340,7 +340,7 @@ public: return true; } - bool getDomainMetadata(const DNSName& name, const std::string& kind, std::vector& meta) override + bool getDomainMetadata(const ZoneName& name, const std::string& kind, std::vector& meta) override { if (f_get_domain_metadata == nullptr) return false; @@ -358,7 +358,7 @@ public: return true; } - bool getDomainKeys(const DNSName& name, std::vector& keys) override + bool getDomainKeys(const ZoneName& name, std::vector& keys) override { if (f_get_domain_keys == nullptr) return false; diff --git a/modules/pipebackend/pipebackend.cc b/modules/pipebackend/pipebackend.cc index 68173dc3a4..5a7b74d2ab 100644 --- a/modules/pipebackend/pipebackend.cc +++ b/modules/pipebackend/pipebackend.cc @@ -195,7 +195,7 @@ void PipeBackend::lookup(const QType& qtype, const DNSName& qname, int zoneId, D d_qname = qname; } -bool PipeBackend::list(const DNSName& target, int inZoneId, bool /* include_disabled */) +bool PipeBackend::list(const ZoneName& target, int inZoneId, bool /* include_disabled */) { try { launch(); diff --git a/modules/pipebackend/pipebackend.hh b/modules/pipebackend/pipebackend.hh index 64b4b3477e..a2d270bc8e 100644 --- a/modules/pipebackend/pipebackend.hh +++ b/modules/pipebackend/pipebackend.hh @@ -53,7 +53,7 @@ public: unsigned int getCapabilities() override { return CAP_DIRECT | CAP_LIST; } void lookup(const QType&, const DNSName& qdomain, int zoneId, DNSPacket* p = nullptr) override; - bool list(const DNSName& target, int domain_id, bool include_disabled = false) override; + bool list(const ZoneName& target, int domain_id, bool include_disabled = false) override; bool get(DNSResourceRecord& r) override; string directBackendCmd(const string& query) override; static DNSBackend* maker(); diff --git a/modules/remotebackend/remotebackend.cc b/modules/remotebackend/remotebackend.cc index b38280ed2d..b035dccae2 100644 --- a/modules/remotebackend/remotebackend.cc +++ b/modules/remotebackend/remotebackend.cc @@ -225,7 +225,7 @@ void RemoteBackend::lookup(const QType& qtype, const DNSName& qdomain, int zoneI d_index = 0; } -bool RemoteBackend::list(const DNSName& target, int domain_id, bool include_disabled) +bool RemoteBackend::list(const ZoneName& target, int domain_id, bool include_disabled) { if (d_index != -1) { throw PDNSException("Attempt to lookup while one running"); @@ -304,7 +304,7 @@ bool RemoteBackend::getBeforeAndAfterNamesAbsolute(uint32_t id, const DNSName& q return true; } -bool RemoteBackend::getAllDomainMetadata(const DNSName& name, std::map>& meta) +bool RemoteBackend::getAllDomainMetadata(const ZoneName& name, std::map>& meta) { Json query = Json::object{ {"method", "getAllDomainMetadata"}, @@ -336,7 +336,7 @@ bool RemoteBackend::getAllDomainMetadata(const DNSName& name, std::map& meta) +bool RemoteBackend::getDomainMetadata(const ZoneName& name, const std::string& kind, std::vector& meta) { Json query = Json::object{ {"method", "getDomainMetadata"}, @@ -366,7 +366,7 @@ bool RemoteBackend::getDomainMetadata(const DNSName& name, const std::string& ki return true; } -bool RemoteBackend::setDomainMetadata(const DNSName& name, const std::string& kind, const std::vector& meta) +bool RemoteBackend::setDomainMetadata(const ZoneName& name, const std::string& kind, const std::vector& meta) { Json query = Json::object{ {"method", "setDomainMetadata"}, @@ -380,7 +380,7 @@ bool RemoteBackend::setDomainMetadata(const DNSName& name, const std::string& ki return boolFromJson(answer, "result", false); } -bool RemoteBackend::getDomainKeys(const DNSName& name, std::vector& keys) +bool RemoteBackend::getDomainKeys(const ZoneName& name, std::vector& keys) { // no point doing dnssec if it's not supported if (!d_dnssec) { @@ -411,7 +411,7 @@ bool RemoteBackend::getDomainKeys(const DNSName& name, std::vectorsend(query) && this->recv(answer); } -bool RemoteBackend::addDomainKey(const DNSName& name, const KeyData& key, int64_t& id) +bool RemoteBackend::addDomainKey(const ZoneName& name, const KeyData& key, int64_t& id) { // no point doing dnssec if it's not supported if (!d_dnssec) { @@ -446,7 +446,7 @@ bool RemoteBackend::addDomainKey(const DNSName& name, const KeyData& key, int64_ return id >= 0; } -bool RemoteBackend::activateDomainKey(const DNSName& name, unsigned int id) +bool RemoteBackend::activateDomainKey(const ZoneName& name, unsigned int id) { // no point doing dnssec if it's not supported if (!d_dnssec) { @@ -461,7 +461,7 @@ bool RemoteBackend::activateDomainKey(const DNSName& name, unsigned int id) return this->send(query) && this->recv(answer); } -bool RemoteBackend::deactivateDomainKey(const DNSName& name, unsigned int id) +bool RemoteBackend::deactivateDomainKey(const ZoneName& name, unsigned int id) { // no point doing dnssec if it's not supported if (!d_dnssec) { @@ -476,7 +476,7 @@ bool RemoteBackend::deactivateDomainKey(const DNSName& name, unsigned int id) return this->send(query) && this->recv(answer); } -bool RemoteBackend::publishDomainKey(const DNSName& name, unsigned int id) +bool RemoteBackend::publishDomainKey(const ZoneName& name, unsigned int id) { // no point doing dnssec if it's not supported if (!d_dnssec) { @@ -491,7 +491,7 @@ bool RemoteBackend::publishDomainKey(const DNSName& name, unsigned int id) return this->send(query) && this->recv(answer); } -bool RemoteBackend::unpublishDomainKey(const DNSName& name, unsigned int id) +bool RemoteBackend::unpublishDomainKey(const ZoneName& name, unsigned int id) { // no point doing dnssec if it's not supported if (!d_dnssec) { @@ -595,7 +595,7 @@ bool RemoteBackend::getTSIGKeys(std::vector& keys) void RemoteBackend::parseDomainInfo(const Json& obj, DomainInfo& di) { di.id = intFromJson(obj, "id", -1); - di.zone = DNSName(stringFromJson(obj, "zone")); + di.zone = ZoneName(stringFromJson(obj, "zone")); for (const auto& primary : obj["masters"].array_items()) { di.primaries.emplace_back(primary.string_value(), 53); } @@ -620,7 +620,7 @@ void RemoteBackend::parseDomainInfo(const Json& obj, DomainInfo& di) di.backend = this; } -bool RemoteBackend::getDomainInfo(const DNSName& domain, DomainInfo& di, bool /* getSerial */) +bool RemoteBackend::getDomainInfo(const ZoneName& domain, DomainInfo& di, bool /* getSerial */) { if (domain.empty()) { return false; @@ -651,7 +651,7 @@ void RemoteBackend::setNotified(uint32_t id, uint32_t serial) } } -bool RemoteBackend::autoPrimaryBackend(const string& ip, const DNSName& domain, const vector& nsset, string* nameserver, string* account, DNSBackend** ddb) +bool RemoteBackend::autoPrimaryBackend(const string& ip, const ZoneName& domain, const vector& nsset, string* nameserver, string* account, DNSBackend** ddb) { Json::array rrset; @@ -688,7 +688,7 @@ bool RemoteBackend::autoPrimaryBackend(const string& ip, const DNSName& domain, return true; } -bool RemoteBackend::createSecondaryDomain(const string& ip, const DNSName& domain, const string& nameserver, const string& account) +bool RemoteBackend::createSecondaryDomain(const string& ip, const ZoneName& domain, const string& nameserver, const string& account) { Json query = Json::object{ {"method", "createSlaveDomain"}, @@ -775,7 +775,7 @@ bool RemoteBackend::feedEnts3(int domain_id, const DNSName& domain, mapsend(query) && this->recv(answer); } -bool RemoteBackend::startTransaction(const DNSName& domain, int domain_id) +bool RemoteBackend::startTransaction(const ZoneName& domain, int domain_id) { this->d_trxid = time((time_t*)nullptr); diff --git a/modules/remotebackend/remotebackend.hh b/modules/remotebackend/remotebackend.hh index 0949150872..5aa7b5b73a 100644 --- a/modules/remotebackend/remotebackend.hh +++ b/modules/remotebackend/remotebackend.hh @@ -170,29 +170,29 @@ public: unsigned int getCapabilities() override; void lookup(const QType& qtype, const DNSName& qdomain, int zoneId = -1, DNSPacket* pkt_p = nullptr) override; bool get(DNSResourceRecord& rr) override; - bool list(const DNSName& target, int domain_id, bool include_disabled = false) override; + bool list(const ZoneName& target, int domain_id, bool include_disabled = false) override; - bool getAllDomainMetadata(const DNSName& name, std::map>& meta) override; - bool getDomainMetadata(const DNSName& name, const std::string& kind, std::vector& meta) override; - bool getDomainKeys(const DNSName& name, std::vector& keys) override; + bool getAllDomainMetadata(const ZoneName& name, std::map>& meta) override; + bool getDomainMetadata(const ZoneName& name, const std::string& kind, std::vector& meta) override; + bool getDomainKeys(const ZoneName& name, std::vector& keys) override; bool getTSIGKey(const DNSName& name, DNSName& algorithm, std::string& content) override; bool getBeforeAndAfterNamesAbsolute(uint32_t id, const DNSName& qname, DNSName& unhashed, DNSName& before, DNSName& after) override; bool setDomainMetadata(const DNSName& name, const string& kind, const std::vector>& meta) override; - bool removeDomainKey(const DNSName& name, unsigned int id) override; - bool addDomainKey(const DNSName& name, const KeyData& key, int64_t& id) override; - bool activateDomainKey(const DNSName& name, unsigned int id) override; - bool deactivateDomainKey(const DNSName& name, unsigned int id) override; - bool publishDomainKey(const DNSName& name, unsigned int id) override; - bool unpublishDomainKey(const DNSName& name, unsigned int id) override; - bool getDomainInfo(const DNSName& domain, DomainInfo& di, bool getSerial = true) override; + bool removeDomainKey(const ZoneName& name, unsigned int id) override; + bool addDomainKey(const ZoneName& name, const KeyData& key, int64_t& id) override; + bool activateDomainKey(const ZoneName& name, unsigned int id) override; + bool deactivateDomainKey(const ZoneName& name, unsigned int id) override; + bool publishDomainKey(const ZoneName& name, unsigned int id) override; + bool unpublishDomainKey(const ZoneName& name, unsigned int id) override; + bool getDomainInfo(const ZoneName& domain, DomainInfo& di, bool getSerial = true) override; void setNotified(uint32_t id, uint32_t serial) override; - bool autoPrimaryBackend(const string& ip, const DNSName& domain, const vector& nsset, string* nameserver, string* account, DNSBackend** ddb) override; - bool createSecondaryDomain(const string& ip, const DNSName& domain, const string& nameserver, const string& account) override; + bool autoPrimaryBackend(const string& ip, const ZoneName& domain, const vector& nsset, string* nameserver, string* account, DNSBackend** ddb) override; + bool createSecondaryDomain(const string& ip, const ZoneName& domain, const string& nameserver, const string& account) override; bool replaceRRSet(uint32_t domain_id, const DNSName& qname, const QType& qt, const vector& rrset) override; bool feedRecord(const DNSResourceRecord& r, const DNSName& ordername, bool ordernameIsNSEC3 = false) override; bool feedEnts(int domain_id, map& nonterm) override; bool feedEnts3(int domain_id, const DNSName& domain, map& nonterm, const NSEC3PARAMRecordContent& ns3prc, bool narrow) override; - bool startTransaction(const DNSName& domain, int domain_id) override; + bool startTransaction(const ZoneName& domain, int domain_id) override; bool commitTransaction() override; bool abortTransaction() override; bool setTSIGKey(const DNSName& name, const DNSName& algorithm, const string& content) override; diff --git a/modules/remotebackend/test-remotebackend.cc b/modules/remotebackend/test-remotebackend.cc index 0aa002df9d..9589c68e5d 100644 --- a/modules/remotebackend/test-remotebackend.cc +++ b/modules/remotebackend/test-remotebackend.cc @@ -77,7 +77,7 @@ BOOST_AUTO_TEST_CASE(test_method_list) DNSResourceRecord resourceRecord; BOOST_TEST_MESSAGE("Testing list method"); - backendUnderTest->list(DNSName("unit.test."), -1); + backendUnderTest->list(ZoneName("unit.test."), -1); while (backendUnderTest->get(resourceRecord)) { record_count++; } @@ -96,27 +96,27 @@ BOOST_AUTO_TEST_CASE(test_method_setDomainMetadata) std::vector meta; meta.emplace_back("VALUE"); BOOST_TEST_MESSAGE("Testing setDomainMetadata method"); - BOOST_CHECK(backendUnderTest->setDomainMetadata(DNSName("unit.test."), "TEST", meta)); + BOOST_CHECK(backendUnderTest->setDomainMetadata(ZoneName("unit.test."), "TEST", meta)); } BOOST_AUTO_TEST_CASE(test_method_alsoNotifies) { - BOOST_CHECK(backendUnderTest->setDomainMetadata(DNSName("unit.test."), "ALSO-NOTIFY", {"192.0.2.1"})); + BOOST_CHECK(backendUnderTest->setDomainMetadata(ZoneName("unit.test."), "ALSO-NOTIFY", {"192.0.2.1"})); std::set alsoNotifies; BOOST_TEST_MESSAGE("Testing alsoNotifies method"); - backendUnderTest->alsoNotifies(DNSName("unit.test."), &alsoNotifies); + backendUnderTest->alsoNotifies(ZoneName("unit.test."), &alsoNotifies); BOOST_CHECK_EQUAL(alsoNotifies.size(), 1); if (!alsoNotifies.empty()) { BOOST_CHECK_EQUAL(alsoNotifies.count("192.0.2.1"), 1); } - BOOST_CHECK(backendUnderTest->setDomainMetadata(DNSName("unit.test."), "ALSO-NOTIFY", std::vector())); + BOOST_CHECK(backendUnderTest->setDomainMetadata(ZoneName("unit.test."), "ALSO-NOTIFY", std::vector())); } BOOST_AUTO_TEST_CASE(test_method_getDomainMetadata) { std::vector meta; BOOST_TEST_MESSAGE("Testing getDomainMetadata method"); - backendUnderTest->getDomainMetadata(DNSName("unit.test."), "TEST", meta); + backendUnderTest->getDomainMetadata(ZoneName("unit.test."), "TEST", meta); BOOST_CHECK_EQUAL(meta.size(), 1); // in case we got more than one value, which would be unexpected // but not fatal @@ -129,7 +129,7 @@ BOOST_AUTO_TEST_CASE(test_method_getAllDomainMetadata) { std::map> meta; BOOST_TEST_MESSAGE("Testing getAllDomainMetadata method"); - backendUnderTest->getAllDomainMetadata(DNSName("unit.test."), meta); + backendUnderTest->getAllDomainMetadata(ZoneName("unit.test."), meta); BOOST_CHECK_EQUAL(meta.size(), 1); // in case we got more than one value, which would be unexpected // but not fatal @@ -142,9 +142,9 @@ BOOST_AUTO_TEST_CASE(test_method_addDomainKey) { BOOST_TEST_MESSAGE("Testing addDomainKey method"); int64_t keyID = 0; - backendUnderTest->addDomainKey(DNSName("unit.test."), k1, keyID); + backendUnderTest->addDomainKey(ZoneName("unit.test."), k1, keyID); BOOST_CHECK_EQUAL(keyID, 1); - backendUnderTest->addDomainKey(DNSName("unit.test."), k2, keyID); + backendUnderTest->addDomainKey(ZoneName("unit.test."), k2, keyID); BOOST_CHECK_EQUAL(keyID, 2); } @@ -153,7 +153,7 @@ BOOST_AUTO_TEST_CASE(test_method_getDomainKeys) std::vector keys; BOOST_TEST_MESSAGE("Testing getDomainKeys method"); // we expect to get two keys - backendUnderTest->getDomainKeys(DNSName("unit.test."), keys); + backendUnderTest->getDomainKeys(ZoneName("unit.test."), keys); BOOST_CHECK_EQUAL(keys.size(), 2); // in case we got more than 2 keys, which would be unexpected // but not fatal @@ -172,19 +172,19 @@ BOOST_AUTO_TEST_CASE(test_method_getDomainKeys) BOOST_AUTO_TEST_CASE(test_method_deactivateDomainKey) { BOOST_TEST_MESSAGE("Testing deactivateDomainKey method"); - BOOST_CHECK(backendUnderTest->deactivateDomainKey(DNSName("unit.test."), 1)); + BOOST_CHECK(backendUnderTest->deactivateDomainKey(ZoneName("unit.test."), 1)); } BOOST_AUTO_TEST_CASE(test_method_activateDomainKey) { BOOST_TEST_MESSAGE("Testing activateDomainKey method"); - BOOST_CHECK(backendUnderTest->activateDomainKey(DNSName("unit.test."), 1)); + BOOST_CHECK(backendUnderTest->activateDomainKey(ZoneName("unit.test."), 1)); } BOOST_AUTO_TEST_CASE(test_method_removeDomainKey) { - BOOST_CHECK(backendUnderTest->removeDomainKey(DNSName("unit.test."), 2)); - BOOST_CHECK(backendUnderTest->removeDomainKey(DNSName("unit.test."), 1)); + BOOST_CHECK(backendUnderTest->removeDomainKey(ZoneName("unit.test."), 2)); + BOOST_CHECK(backendUnderTest->removeDomainKey(ZoneName("unit.test."), 1)); } BOOST_AUTO_TEST_CASE(test_method_getBeforeAndAfterNamesAbsolute) @@ -250,7 +250,7 @@ BOOST_AUTO_TEST_CASE(test_method_getDomainInfo) { DomainInfo domainInfo; BOOST_TEST_MESSAGE("Testing getDomainInfo method"); - backendUnderTest->getDomainInfo(DNSName("unit.test."), domainInfo); + backendUnderTest->getDomainInfo(ZoneName("unit.test."), domainInfo); BOOST_CHECK_EQUAL(domainInfo.zone.toString(), "unit.test."); BOOST_CHECK_EQUAL(domainInfo.serial, 2); BOOST_CHECK_EQUAL(domainInfo.notified_serial, 2); @@ -295,7 +295,7 @@ BOOST_AUTO_TEST_CASE(test_method_autoPrimaryBackend) resourceRecord.content = "ns2.example.com."; nsset.push_back(resourceRecord); - BOOST_CHECK(backendUnderTest->autoPrimaryBackend("10.0.0.1", DNSName("example.com."), nsset, nullptr, nullptr, &dbd)); + BOOST_CHECK(backendUnderTest->autoPrimaryBackend("10.0.0.1", ZoneName("example.com."), nsset, nullptr, nullptr, &dbd)); // let's see what we got BOOST_CHECK_EQUAL(dbd, backendUnderTest.get()); @@ -304,14 +304,14 @@ BOOST_AUTO_TEST_CASE(test_method_autoPrimaryBackend) BOOST_AUTO_TEST_CASE(test_method_createSecondaryDomain) { BOOST_TEST_MESSAGE("Testing createSecondaryDomain method"); - BOOST_CHECK(backendUnderTest->createSecondaryDomain("10.0.0.1", DNSName("pirate.unit.test."), "", "")); + BOOST_CHECK(backendUnderTest->createSecondaryDomain("10.0.0.1", ZoneName("pirate.unit.test."), "", "")); } BOOST_AUTO_TEST_CASE(test_method_feedRecord) { DNSResourceRecord resourceRecord; BOOST_TEST_MESSAGE("Testing feedRecord method"); - backendUnderTest->startTransaction(DNSName("example.com."), 3); + backendUnderTest->startTransaction(ZoneName("example.com."), 3); resourceRecord.qname = DNSName("example.com."); resourceRecord.qtype = QType::SOA; resourceRecord.qclass = QClass::IN; @@ -329,7 +329,7 @@ BOOST_AUTO_TEST_CASE(test_method_feedRecord) BOOST_AUTO_TEST_CASE(test_method_replaceRRSet) { - backendUnderTest->startTransaction(DNSName("example.com."), 3); + backendUnderTest->startTransaction(ZoneName("example.com."), 3); DNSResourceRecord resourceRecord; std::vector rrset; BOOST_TEST_MESSAGE("Testing replaceRRSet method"); @@ -346,7 +346,7 @@ BOOST_AUTO_TEST_CASE(test_method_replaceRRSet) BOOST_AUTO_TEST_CASE(test_method_feedEnts) { BOOST_TEST_MESSAGE("Testing feedEnts method"); - backendUnderTest->startTransaction(DNSName("example.com."), 3); + backendUnderTest->startTransaction(ZoneName("example.com."), 3); map nonterm = boost::assign::map_list_of(DNSName("_udp"), true)(DNSName("_sip._udp"), true); BOOST_CHECK(backendUnderTest->feedEnts(2, nonterm)); backendUnderTest->commitTransaction(); @@ -355,7 +355,7 @@ BOOST_AUTO_TEST_CASE(test_method_feedEnts) BOOST_AUTO_TEST_CASE(test_method_feedEnts3) { BOOST_TEST_MESSAGE("Testing feedEnts3 method"); - backendUnderTest->startTransaction(DNSName("example.com"), 3); + backendUnderTest->startTransaction(ZoneName("example.com"), 3); NSEC3PARAMRecordContent ns3prc; ns3prc.d_iterations = 1; ns3prc.d_salt = "\u00aa\u00bb\u00cc\u00dd"; @@ -367,7 +367,7 @@ BOOST_AUTO_TEST_CASE(test_method_feedEnts3) BOOST_AUTO_TEST_CASE(test_method_abortTransaction) { BOOST_TEST_MESSAGE("Testing abortTransaction method"); - backendUnderTest->startTransaction(DNSName("example.com."), 3); + backendUnderTest->startTransaction(ZoneName("example.com."), 3); BOOST_CHECK(backendUnderTest->abortTransaction()); } diff --git a/modules/tinydnsbackend/tinydnsbackend.cc b/modules/tinydnsbackend/tinydnsbackend.cc index 009f48c41d..0f5b714da3 100644 --- a/modules/tinydnsbackend/tinydnsbackend.cc +++ b/modules/tinydnsbackend/tinydnsbackend.cc @@ -173,7 +173,7 @@ void TinyDNSBackend::getAllDomains_locked(vector* domains, bool getS DomainInfo di; di.id = -1; // Will be overridden by caller di.backend = this; - di.zone = rr.qname; + di.zone = ZoneName(rr.qname); di.kind = DomainInfo::Primary; di.last_check = time(0); @@ -214,7 +214,7 @@ void TinyDNSBackend::getAllDomains(vector* domains, bool getSerial, } //NOLINTNEXTLINE(readability-identifier-length) -bool TinyDNSBackend::getDomainInfo(const DNSName& domain, DomainInfo& di, bool getSerial) +bool TinyDNSBackend::getDomainInfo(const ZoneName& domain, DomainInfo& di, bool getSerial) { auto domainInfo = s_domainInfo.lock(); //TODO: We could actually lock less if we do it per suffix. if (domainInfo->count(d_suffix) == 0) { @@ -240,7 +240,7 @@ bool TinyDNSBackend::getDomainInfo(const DNSName& domain, DomainInfo& di, bool g return found; } -bool TinyDNSBackend::list(const DNSName& target, int /* domain_id */, bool /* include_disabled */) +bool TinyDNSBackend::list(const ZoneName& target, int /* domain_id */, bool /* include_disabled */) { d_isAxfr = true; d_isGetDomains = false; diff --git a/modules/tinydnsbackend/tinydnsbackend.hh b/modules/tinydnsbackend/tinydnsbackend.hh index d227f51bd5..b7477c7ebb 100644 --- a/modules/tinydnsbackend/tinydnsbackend.hh +++ b/modules/tinydnsbackend/tinydnsbackend.hh @@ -40,7 +40,7 @@ struct TinyDomainInfo { uint32_t id; uint32_t notified_serial; - DNSName zone; + ZoneName zone; bool operator<(const TinyDomainInfo& tdi) const { @@ -70,9 +70,9 @@ public: unsigned int getCapabilities() override { return CAP_LIST; } void lookup(const QType& qtype, const DNSName& qdomain, int zoneId, DNSPacket* pkt_p = nullptr) override; - bool list(const DNSName& target, int domain_id, bool include_disabled = false) override; + bool list(const ZoneName& target, int domain_id, bool include_disabled = false) override; bool get(DNSResourceRecord& rr) override; - bool getDomainInfo(const DNSName& domain, DomainInfo& di, bool getSerial = true) override; + bool getDomainInfo(const ZoneName& domain, DomainInfo& di, bool getSerial = true) override; void getAllDomains(vector* domains, bool getSerial, bool include_disabled) override; // Primary mode operation @@ -90,7 +90,7 @@ private: typedef multi_index_container< TinyDomainInfo, indexed_by< - hashed_unique, member>, + hashed_unique, member>, hashed_unique, member>>> TDI_t; typedef map TDI_suffix_t; diff --git a/pdns/auth-catalogzone.cc b/pdns/auth-catalogzone.cc index bcff734f08..f07e39360f 100644 --- a/pdns/auth-catalogzone.cc +++ b/pdns/auth-catalogzone.cc @@ -113,7 +113,7 @@ void CatalogInfo::updateHash(CatalogHashMap& hashes, const DomainInfo& di) const } } -DNSZoneRecord CatalogInfo::getCatalogVersionRecord(const DNSName& zone) +DNSZoneRecord CatalogInfo::getCatalogVersionRecord(const ZoneName& zone) { DNSZoneRecord dzr; dzr.dr.d_name = DNSName("version") + zone; @@ -123,7 +123,7 @@ DNSZoneRecord CatalogInfo::getCatalogVersionRecord(const DNSName& zone) return dzr; } -void CatalogInfo::toDNSZoneRecords(const DNSName& zone, vector& dzrs) const +void CatalogInfo::toDNSZoneRecords(const ZoneName& zone, vector& dzrs) const { DNSName prefix; if (d_unique.empty()) { diff --git a/pdns/auth-catalogzone.hh b/pdns/auth-catalogzone.hh index d8a4fe907c..fc040c6bd2 100644 --- a/pdns/auth-catalogzone.hh +++ b/pdns/auth-catalogzone.hh @@ -28,7 +28,7 @@ struct DomainInfo; -typedef map CatalogHashMap; +typedef map CatalogHashMap; class CatalogInfo { @@ -48,7 +48,7 @@ public: CatalogInfo() : d_id(0), d_type(CatalogType::None) {} - CatalogInfo(uint32_t id, const DNSName& zone, const std::string& options, CatalogType type) + CatalogInfo(uint32_t id, const ZoneName& zone, const std::string& options, CatalogType type) { d_id = id; d_zone = zone; @@ -61,8 +61,8 @@ public: void updateHash(CatalogHashMap& hashes, const DomainInfo& di) const; DNSName getUnique() const { return DNSName(toBase32Hex(hashQNameWithSalt(std::to_string(d_id), 0, d_zone))); } // salt with domain id to detect recreated zones - static DNSZoneRecord getCatalogVersionRecord(const DNSName& zone); - void toDNSZoneRecords(const DNSName& zone, vector& dzrs) const; + static DNSZoneRecord getCatalogVersionRecord(const ZoneName& zone); + void toDNSZoneRecords(const ZoneName& zone, vector& dzrs) const; bool operator<(const CatalogInfo& rhs) const { @@ -70,7 +70,8 @@ public: } uint32_t d_id; - DNSName d_zone, d_coo, d_unique; + ZoneName d_zone; + DNSName d_coo, d_unique; std::set d_group; vector d_primaries; diff --git a/pdns/auth-primarycommunicator.cc b/pdns/auth-primarycommunicator.cc index 82314c3cd8..a52ea89771 100644 --- a/pdns/auth-primarycommunicator.cc +++ b/pdns/auth-primarycommunicator.cc @@ -111,7 +111,7 @@ void CommunicatorClass::queueNotifyDomain(const DomainInfo& di, UeberBackend* B) g_log << Logger::Warning << "Request to queue notification for domain '" << di.zone << "' was processed, but no valid nameservers or ALSO-NOTIFYs found. Not notifying!" << endl; } -bool CommunicatorClass::notifyDomain(const DNSName& domain, UeberBackend* B) +bool CommunicatorClass::notifyDomain(const ZoneName& domain, UeberBackend* B) { DomainInfo di; if (!B->getDomainInfo(domain, di)) { @@ -247,7 +247,7 @@ time_t CommunicatorClass::doNotifications(PacketHandler* P) } // send out possible new notifications - DNSName domain; + ZoneName domain; string ip; uint16_t id = 0; @@ -280,7 +280,7 @@ time_t CommunicatorClass::doNotifications(PacketHandler* P) return d_nq.earliest(); } -void CommunicatorClass::sendNotification(int sock, const DNSName& domain, const ComboAddress& remote, uint16_t id, UeberBackend* B) +void CommunicatorClass::sendNotification(int sock, const ZoneName& domain, const ComboAddress& remote, uint16_t id, UeberBackend* B) { vector meta; DNSName tsigkeyname; @@ -323,12 +323,12 @@ void CommunicatorClass::sendNotification(int sock, const DNSName& domain, const } } -void CommunicatorClass::drillHole(const DNSName& domain, const string& ip) +void CommunicatorClass::drillHole(const ZoneName& domain, const string& ip) { (*d_holes.lock())[pair(domain, ip)] = time(nullptr); } -bool CommunicatorClass::justNotified(const DNSName& domain, const string& ip) +bool CommunicatorClass::justNotified(const ZoneName& domain, const string& ip) { auto holes = d_holes.lock(); auto it = holes->find(pair(domain, ip)); @@ -362,7 +362,7 @@ void CommunicatorClass::makeNotifySockets() } } -void CommunicatorClass::notify(const DNSName& domain, const string& ip) +void CommunicatorClass::notify(const ZoneName& domain, const string& ip) { d_nq.add(domain, ip); } diff --git a/pdns/auth-secondarycommunicator.cc b/pdns/auth-secondarycommunicator.cc index 739838afe9..f05347dcfb 100644 --- a/pdns/auth-secondarycommunicator.cc +++ b/pdns/auth-secondarycommunicator.cc @@ -48,7 +48,7 @@ #include "ixfr.hh" -void CommunicatorClass::addSuckRequest(const DNSName& domain, const ComboAddress& primary, SuckRequest::RequestPriority priority, bool force) +void CommunicatorClass::addSuckRequest(const ZoneName& domain, const ComboAddress& primary, SuckRequest::RequestPriority priority, bool force) { auto data = d_data.lock(); SuckRequest sr; @@ -94,7 +94,7 @@ static bool catalogDiff(const DomainInfo& di, vector& fromXFR, vect bool doTransaction{true}; bool inTransaction{false}; CatalogInfo ciCreate, ciRemove; - std::unordered_map clearCache; + std::unordered_map clearCache; vector retrieve; try { @@ -309,7 +309,7 @@ static bool catalogProcess(const DomainInfo& di, vector& rrs, logPrefix += "Catalog-Zone "; vector fromXFR, fromDB; - std::unordered_set dupcheck; + std::unordered_set dupcheck; // From XFR bool hasSOA{false}; @@ -425,7 +425,7 @@ static bool catalogProcess(const DomainInfo& di, vector& rrs, return catalogDiff(di, fromXFR, fromDB, logPrefix); } -void CommunicatorClass::ixfrSuck(const DNSName& domain, const TSIGTriplet& tt, const ComboAddress& laddr, const ComboAddress& remote, ZoneStatus& zs, vector* axfr) +void CommunicatorClass::ixfrSuck(const ZoneName& domain, const TSIGTriplet& tt, const ComboAddress& laddr, const ComboAddress& remote, ZoneStatus& zs, vector* axfr) { string logPrefix = "IXFR-in zone '" + domain.toLogString() + "', primary '" + remote.toString() + "', "; @@ -471,7 +471,7 @@ void CommunicatorClass::ixfrSuck(const DNSName& domain, const TSIGTriplet& tt, c // this means that we must group updates by {qname,qtype}, retrieve the RRSET, apply // the add/remove updates, and replaceRRSet the whole thing. - map, pair, vector>> grouped; + map, pair, vector>> grouped; for (const auto& x : remove) grouped[{x.d_name, x.d_type}].first.push_back(x); @@ -636,7 +636,7 @@ static vector doAxfr(const ComboAddress& raddr, const DNSName return rrs; } -void CommunicatorClass::suck(const DNSName& domain, const ComboAddress& remote, bool force) // NOLINT(readability-function-cognitive-complexity) +void CommunicatorClass::suck(const ZoneName& domain, const ComboAddress& remote, bool force) // NOLINT(readability-function-cognitive-complexity) { { auto data = d_data.lock(); @@ -1391,9 +1391,9 @@ void CommunicatorClass::secondaryRefresh(PacketHandler* P) } } -vector> CommunicatorClass::getSuckRequests() +vector> CommunicatorClass::getSuckRequests() { - vector> ret; + vector> ret; auto data = d_data.lock(); ret.reserve(data->d_suckdomains.size()); for (auto const& d : data->d_suckdomains) { diff --git a/pdns/auth-zonecache.cc b/pdns/auth-zonecache.cc index 09a460eaa4..f1c26f0a9c 100644 --- a/pdns/auth-zonecache.cc +++ b/pdns/auth-zonecache.cc @@ -42,7 +42,7 @@ AuthZoneCache::AuthZoneCache(size_t mapsCount) : d_statnumentries = S.getPointer("zone-cache-size"); } -bool AuthZoneCache::getEntry(const DNSName& zone, int& zoneId) +bool AuthZoneCache::getEntry(const ZoneName& zone, int& zoneId) { auto& mc = getMap(zone); bool found = false; @@ -74,7 +74,7 @@ void AuthZoneCache::clear() purgeLockedCollectionsVector(d_maps); } -void AuthZoneCache::replace(const vector>& zone_indices) +void AuthZoneCache::replace(const vector>& zone_indices) { if (!d_refreshinterval) return; @@ -133,7 +133,7 @@ void AuthZoneCache::replace(const vector>& zone_indices } } -void AuthZoneCache::add(const DNSName& zone, const int zoneId) +void AuthZoneCache::add(const ZoneName& zone, const int zoneId) { if (!d_refreshinterval) return; @@ -163,7 +163,7 @@ void AuthZoneCache::add(const DNSName& zone, const int zoneId) } } -void AuthZoneCache::remove(const DNSName& zone) +void AuthZoneCache::remove(const ZoneName& zone) { if (!d_refreshinterval) return; diff --git a/pdns/auth-zonecache.hh b/pdns/auth-zonecache.hh index 2a25cc4c8e..02db80f9c5 100644 --- a/pdns/auth-zonecache.hh +++ b/pdns/auth-zonecache.hh @@ -32,12 +32,12 @@ class AuthZoneCache : public boost::noncopyable public: AuthZoneCache(size_t mapsCount = 1024); - void replace(const vector>& zone); - void add(const DNSName& zone, const int zoneId); - void remove(const DNSName& zone); + void replace(const vector>& zone); + void add(const ZoneName& zone, const int zoneId); + void remove(const ZoneName& zone); void setReplacePending(); //!< call this when data collection for the subsequent replace() call starts. - bool getEntry(const DNSName& zone, int& zoneId); + bool getEntry(const ZoneName& zone, int& zoneId); size_t size() { return *d_statnumentries; } //!< number of entries in the cache @@ -62,7 +62,7 @@ private: int zoneId{-1}; }; - typedef std::unordered_map> cmap_t; + typedef std::unordered_map> cmap_t; struct MapCombo { @@ -75,11 +75,11 @@ private: }; vector d_maps; - size_t getMapIndex(const DNSName& zone) + size_t getMapIndex(const ZoneName& zone) { return zone.hash() % d_maps.size(); } - MapCombo& getMap(const DNSName& qname) + MapCombo& getMap(const ZoneName& qname) { return d_maps[getMapIndex(qname)]; } @@ -92,7 +92,7 @@ private: struct PendingData { - std::vector> d_pendingUpdates; + std::vector> d_pendingUpdates; bool d_replacePending{false}; }; LockGuarded d_pending; diff --git a/pdns/axfr-retriever.cc b/pdns/axfr-retriever.cc index 4e93d3af2a..216f80f9fb 100644 --- a/pdns/axfr-retriever.cc +++ b/pdns/axfr-retriever.cc @@ -30,7 +30,7 @@ using pdns::resolver::parseResult; AXFRRetriever::AXFRRetriever(const ComboAddress& remote, - const DNSName& domain, + const ZoneName& domain, const TSIGTriplet& tsigConf, const ComboAddress* laddr, size_t maxReceivedBytes, diff --git a/pdns/axfr-retriever.hh b/pdns/axfr-retriever.hh index 18e37f6c5d..a2542a0301 100644 --- a/pdns/axfr-retriever.hh +++ b/pdns/axfr-retriever.hh @@ -30,7 +30,7 @@ class AXFRRetriever : public boost::noncopyable { public: AXFRRetriever(const ComboAddress& remote, - const DNSName& zone, + const ZoneName& zone, const TSIGTriplet& tt = TSIGTriplet(), const ComboAddress* laddr = NULL, size_t maxReceivedBytes=0, diff --git a/pdns/backends/gsql/gsqlbackend.cc b/pdns/backends/gsql/gsqlbackend.cc index 7cc9851469..1dafd5bbdc 100644 --- a/pdns/backends/gsql/gsqlbackend.cc +++ b/pdns/backends/gsql/gsqlbackend.cc @@ -248,7 +248,7 @@ void GSQLBackend::setFresh(uint32_t domain_id) setLastCheck(domain_id, time(nullptr)); } -bool GSQLBackend::setPrimaries(const DNSName& domain, const vector& primaries) +bool GSQLBackend::setPrimaries(const ZoneName& domain, const vector& primaries) { vector primaries_s; primaries_s.reserve(primaries.size()); @@ -275,7 +275,7 @@ bool GSQLBackend::setPrimaries(const DNSName& domain, const vector return true; } -bool GSQLBackend::setKind(const DNSName &domain, const DomainInfo::DomainKind kind) +bool GSQLBackend::setKind(const ZoneName &domain, const DomainInfo::DomainKind kind) { try { reconnectIfNeeded(); @@ -294,7 +294,7 @@ bool GSQLBackend::setKind(const DNSName &domain, const DomainInfo::DomainKind ki return true; } -bool GSQLBackend::setOptions(const DNSName& domain, const string& options) +bool GSQLBackend::setOptions(const ZoneName& domain, const string& options) { try { reconnectIfNeeded(); @@ -313,7 +313,7 @@ bool GSQLBackend::setOptions(const DNSName& domain, const string& options) return true; } -bool GSQLBackend::setCatalog(const DNSName& domain, const DNSName& catalog) +bool GSQLBackend::setCatalog(const ZoneName& domain, const ZoneName& catalog) { try { reconnectIfNeeded(); @@ -332,7 +332,7 @@ bool GSQLBackend::setCatalog(const DNSName& domain, const DNSName& catalog) return true; } -bool GSQLBackend::setAccount(const DNSName &domain, const string &account) +bool GSQLBackend::setAccount(const ZoneName &domain, const string &account) { try { reconnectIfNeeded(); @@ -351,7 +351,7 @@ bool GSQLBackend::setAccount(const DNSName &domain, const string &account) return true; } -bool GSQLBackend::getDomainInfo(const DNSName &domain, DomainInfo &di, bool getSerial) +bool GSQLBackend::getDomainInfo(const ZoneName &domain, DomainInfo &di, bool getSerial) { /* fill DomainInfo from database info: id,name,master IP(s),last_check,notified_serial,type,account */ @@ -378,8 +378,8 @@ bool GSQLBackend::getDomainInfo(const DNSName &domain, DomainInfo &di, bool getS pdns::checked_stoi_into(di.id, d_result[0][0]); try { - di.zone=DNSName(d_result[0][1]); - di.catalog = (!d_result[0][7].empty() ? DNSName(d_result[0][7]) : DNSName()); + di.zone=ZoneName(d_result[0][1]); + di.catalog = (!d_result[0][7].empty() ? ZoneName(d_result[0][7]) : ZoneName()); } catch (...) { return false; } @@ -443,7 +443,7 @@ void GSQLBackend::getUnfreshSecondaryInfos(vector* unfreshDomains) ASSERT_ROW_COLUMNS("info-all-secondaries-query", row, 6); try { - di.zone = DNSName(row[1]); + di.zone = ZoneName(row[1]); } catch (const std::runtime_error& e) { g_log << Logger::Warning << __PRETTY_FUNCTION__ << " zone name '" << row[1] << "' is not a valid DNS name: " << e.what() << endl; @@ -559,7 +559,7 @@ void GSQLBackend::getUpdatedPrimaries(vector& updatedDomains, std::u } try { - di.zone = DNSName(row[1]); + di.zone = ZoneName(row[1]); } catch (const std::runtime_error& e) { g_log << Logger::Warning << __PRETTY_FUNCTION__ << " zone name '" << row[1] << "' is not a valid DNS name: " << e.what() << endl; @@ -571,7 +571,7 @@ void GSQLBackend::getUpdatedPrimaries(vector& updatedDomains, std::u } try { - di.catalog = DNSName(row[5]); + di.catalog = ZoneName(row[5]); } catch (const std::runtime_error& e) { g_log << Logger::Warning << __PRETTY_FUNCTION__ << " zone name '" << row[5] << "' is not a valid DNS name: " << e.what() << endl; @@ -632,7 +632,7 @@ void GSQLBackend::getUpdatedPrimaries(vector& updatedDomains, std::u } } -bool GSQLBackend::getCatalogMembers(const DNSName& catalog, vector& members, CatalogInfo::CatalogType type) +bool GSQLBackend::getCatalogMembers(const ZoneName& catalog, vector& members, CatalogInfo::CatalogType type) { try { reconnectIfNeeded(); @@ -675,7 +675,7 @@ bool GSQLBackend::getCatalogMembers(const DNSName& catalog, vector& CatalogInfo ci; try { - ci.d_zone = DNSName(row[1]); + ci.d_zone = ZoneName(row[1]); } catch (const std::runtime_error& e) { g_log << Logger::Warning << __PRETTY_FUNCTION__ << " zone name '" << row[1] << "' is not a valid DNS name: " << e.what() << endl; @@ -989,7 +989,7 @@ bool GSQLBackend::getBeforeAndAfterNamesAbsolute(uint32_t id, const DNSName& qna return true; } -bool GSQLBackend::addDomainKey(const DNSName& name, const KeyData& key, int64_t& id) +bool GSQLBackend::addDomainKey(const ZoneName& name, const KeyData& key, int64_t& id) { if(!d_dnssecQueries) return false; @@ -1046,7 +1046,7 @@ bool GSQLBackend::addDomainKey(const DNSName& name, const KeyData& key, int64_t& } } -bool GSQLBackend::activateDomainKey(const DNSName& name, unsigned int id) +bool GSQLBackend::activateDomainKey(const ZoneName& name, unsigned int id) { if(!d_dnssecQueries) return false; @@ -1068,7 +1068,7 @@ bool GSQLBackend::activateDomainKey(const DNSName& name, unsigned int id) return true; } -bool GSQLBackend::deactivateDomainKey(const DNSName& name, unsigned int id) +bool GSQLBackend::deactivateDomainKey(const ZoneName& name, unsigned int id) { if(!d_dnssecQueries) return false; @@ -1090,7 +1090,7 @@ bool GSQLBackend::deactivateDomainKey(const DNSName& name, unsigned int id) return true; } -bool GSQLBackend::publishDomainKey(const DNSName& name, unsigned int id) +bool GSQLBackend::publishDomainKey(const ZoneName& name, unsigned int id) { if(!d_dnssecQueries) return false; @@ -1112,7 +1112,7 @@ bool GSQLBackend::publishDomainKey(const DNSName& name, unsigned int id) return true; } -bool GSQLBackend::unpublishDomainKey(const DNSName& name, unsigned int id) +bool GSQLBackend::unpublishDomainKey(const ZoneName& name, unsigned int id) { if(!d_dnssecQueries) return false; @@ -1136,7 +1136,7 @@ bool GSQLBackend::unpublishDomainKey(const DNSName& name, unsigned int id) -bool GSQLBackend::removeDomainKey(const DNSName& name, unsigned int id) +bool GSQLBackend::removeDomainKey(const ZoneName& name, unsigned int id) { if(!d_dnssecQueries) return false; @@ -1264,7 +1264,7 @@ bool GSQLBackend::getTSIGKeys(std::vector< struct TSIGKey > &keys) return true; } -bool GSQLBackend::getDomainKeys(const DNSName& name, std::vector& keys) +bool GSQLBackend::getDomainKeys(const ZoneName& name, std::vector& keys) { if(!d_dnssecQueries) return false; @@ -1303,7 +1303,7 @@ bool GSQLBackend::getDomainKeys(const DNSName& name, std::vector& keys) return true; } -bool GSQLBackend::getAllDomainMetadata(const DNSName& name, std::map >& meta) +bool GSQLBackend::getAllDomainMetadata(const ZoneName& name, std::map >& meta) { try { reconnectIfNeeded(); @@ -1334,7 +1334,7 @@ bool GSQLBackend::getAllDomainMetadata(const DNSName& name, std::map& meta) +bool GSQLBackend::getDomainMetadata(const ZoneName& name, const std::string& kind, std::vector& meta) { if(!d_dnssecQueries && isDnssecDomainMetadata(kind)) return false; @@ -1366,7 +1366,7 @@ bool GSQLBackend::getDomainMetadata(const DNSName& name, const std::string& kind return true; } -bool GSQLBackend::setDomainMetadata(const DNSName& name, const std::string& kind, const std::vector& meta) +bool GSQLBackend::setDomainMetadata(const ZoneName& name, const std::string& kind, const std::vector& meta) { if(!d_dnssecQueries && isDnssecDomainMetadata(kind)) return false; @@ -1456,7 +1456,7 @@ void GSQLBackend::lookup(const QType& qtype, const DNSName& qname, int domain_id d_qname=qname; } -bool GSQLBackend::list(const DNSName &target, int domain_id, bool include_disabled) +bool GSQLBackend::list(const ZoneName &target, int domain_id, bool include_disabled) { DLOG(g_log<<"GSQLBackend constructing handle for list of domain id '"<& primaries) return true; } -bool GSQLBackend::autoPrimaryBackend(const string& ip, const DNSName& domain, const vector& nsset, string* nameserver, string* account, DNSBackend** ddb) +bool GSQLBackend::autoPrimaryBackend(const string& ip, const ZoneName& domain, const vector& nsset, string* nameserver, string* account, DNSBackend** ddb) { // check if we know the ip/ns couple in the database for(const auto & i : nsset) { @@ -1639,7 +1639,7 @@ bool GSQLBackend::autoPrimaryBackend(const string& ip, const DNSName& domain, co return false; } -bool GSQLBackend::createDomain(const DNSName& domain, const DomainInfo::DomainKind kind, const vector& primaries, const string& account) +bool GSQLBackend::createDomain(const ZoneName& domain, const DomainInfo::DomainKind kind, const vector& primaries, const string& account) { vector primaries_s; primaries_s.reserve(primaries.size()); @@ -1666,7 +1666,7 @@ bool GSQLBackend::createDomain(const DNSName& domain, const DomainInfo::DomainKi return true; } -bool GSQLBackend::createSecondaryDomain(const string& ip, const DNSName& domain, const string& nameserver, const string& account) +bool GSQLBackend::createSecondaryDomain(const string& ip, const ZoneName& domain, const string& nameserver, const string& account) { string name; vector primaries({ComboAddress(ip, 53)}); @@ -1703,7 +1703,7 @@ bool GSQLBackend::createSecondaryDomain(const string& ip, const DNSName& domain, return true; } -bool GSQLBackend::deleteDomain(const DNSName &domain) +bool GSQLBackend::deleteDomain(const ZoneName &domain) { if (!d_inTransaction) { throw PDNSException("deleteDomain called outside of transaction"); @@ -1766,9 +1766,9 @@ void GSQLBackend::getAllDomains(vector* domains, bool getSerial, boo DomainInfo di; pdns::checked_stoi_into(di.id, row[0]); try { - di.zone = DNSName(row[1]); + di.zone = ZoneName(row[1]); if (!row[8].empty()) { - di.catalog = DNSName(row[8]); + di.catalog = ZoneName(row[8]); } } catch (...) { continue; @@ -2013,7 +2013,7 @@ bool GSQLBackend::feedEnts3(int domain_id, const DNSName& /* domain */, map* domains, bool getSerial, bool include_disabled) override; - bool startTransaction(const DNSName &domain, int domain_id=-1) override; + bool startTransaction(const ZoneName &domain, int domain_id=-1) override; bool commitTransaction() override; bool abortTransaction() override; bool feedRecord(const DNSResourceRecord &r, const DNSName &ordername, bool ordernameIsNSEC3=false) override; bool feedEnts(int domain_id, map& nonterm) override; bool feedEnts3(int domain_id, const DNSName &domain, map &nonterm, const NSEC3PARAMRecordContent& ns3prc, bool narrow) override; - bool createDomain(const DNSName& domain, const DomainInfo::DomainKind kind, const vector& primaries, const string& account) override; - bool createSecondaryDomain(const string& ip, const DNSName& domain, const string& nameserver, const string& account) override; - bool deleteDomain(const DNSName &domain) override; + bool createDomain(const ZoneName& domain, const DomainInfo::DomainKind kind, const vector& primaries, const string& account) override; + bool createSecondaryDomain(const string& ip, const ZoneName& domain, const string& nameserver, const string& account) override; + bool deleteDomain(const ZoneName &domain) override; bool autoPrimaryAdd(const AutoPrimary& primary) override; bool autoPrimaryRemove(const AutoPrimary& primary) override; bool autoPrimariesList(std::vector& primaries) override; - bool autoPrimaryBackend(const string& ip, const DNSName& domain, const vector& nsset, string* nameserver, string* account, DNSBackend** db) override; + bool autoPrimaryBackend(const string& ip, const ZoneName& domain, const vector& nsset, string* nameserver, string* account, DNSBackend** db) override; void setStale(uint32_t domain_id) override; void setFresh(uint32_t domain_id) override; void getUnfreshSecondaryInfos(vector* domains) override; void getUpdatedPrimaries(vector& updatedDomains, std::unordered_set& catalogs, CatalogHashMap& catalogHashes) override; - bool getCatalogMembers(const DNSName& catalog, vector& members, CatalogInfo::CatalogType type) override; - bool getDomainInfo(const DNSName &domain, DomainInfo &di, bool getSerial=true) override; + bool getCatalogMembers(const ZoneName& catalog, vector& members, CatalogInfo::CatalogType type) override; + bool getDomainInfo(const ZoneName &domain, DomainInfo &di, bool getSerial=true) override; void setNotified(uint32_t domain_id, uint32_t serial) override; - bool setPrimaries(const DNSName& domain, const vector& primaries) override; - bool setKind(const DNSName &domain, const DomainInfo::DomainKind kind) override; - bool setOptions(const DNSName& domain, const string& options) override; - bool setCatalog(const DNSName& domain, const DNSName& catalog) override; - bool setAccount(const DNSName &domain, const string &account) override; + bool setPrimaries(const ZoneName& domain, const vector& primaries) override; + bool setKind(const ZoneName &domain, const DomainInfo::DomainKind kind) override; + bool setOptions(const ZoneName& domain, const string& options) override; + bool setCatalog(const ZoneName& domain, const ZoneName& catalog) override; + bool setAccount(const ZoneName &domain, const string &account) override; bool getBeforeAndAfterNamesAbsolute(uint32_t id, const DNSName& qname, DNSName& unhashed, DNSName& before, DNSName& after) override; bool updateDNSSECOrderNameAndAuth(uint32_t domain_id, const DNSName& qname, const DNSName& ordername, bool auth, const uint16_t=QType::ANY) override; @@ -231,18 +231,18 @@ public: bool updateEmptyNonTerminals(uint32_t domain_id, set& insert ,set& erase, bool remove) override; bool replaceRRSet(uint32_t domain_id, const DNSName& qname, const QType& qt, const vector& rrset) override; - bool listSubZone(const DNSName &zone, int domain_id) override; - bool addDomainKey(const DNSName& name, const KeyData& key, int64_t& id) override; - bool getDomainKeys(const DNSName& name, std::vector& keys) override; - bool getAllDomainMetadata(const DNSName& name, std::map >& meta) override; - bool getDomainMetadata(const DNSName& name, const std::string& kind, std::vector& meta) override; - bool setDomainMetadata(const DNSName& name, const std::string& kind, const std::vector& meta) override; - - bool removeDomainKey(const DNSName& name, unsigned int id) override; - bool activateDomainKey(const DNSName& name, unsigned int id) override; - bool deactivateDomainKey(const DNSName& name, unsigned int id) override; - bool publishDomainKey(const DNSName& name, unsigned int id) override; - bool unpublishDomainKey(const DNSName& name, unsigned int id) override; + bool listSubZone(const ZoneName &zone, int domain_id) override; + bool addDomainKey(const ZoneName& name, const KeyData& key, int64_t& id) override; + bool getDomainKeys(const ZoneName& name, std::vector& keys) override; + bool getAllDomainMetadata(const ZoneName& name, std::map >& meta) override; + bool getDomainMetadata(const ZoneName& name, const std::string& kind, std::vector& meta) override; + bool setDomainMetadata(const ZoneName& name, const std::string& kind, const std::vector& meta) override; + + bool removeDomainKey(const ZoneName& name, unsigned int id) override; + bool activateDomainKey(const ZoneName& name, unsigned int id) override; + bool deactivateDomainKey(const ZoneName& name, unsigned int id) override; + bool publishDomainKey(const ZoneName& name, unsigned int id) override; + bool unpublishDomainKey(const ZoneName& name, unsigned int id) override; bool getTSIGKey(const DNSName& name, DNSName& algorithm, string& content) override; bool setTSIGKey(const DNSName& name, const DNSName& algorithm, const string& content) override; diff --git a/pdns/bindparser.yy b/pdns/bindparser.yy index 7b9e49eda9..aaf96155e4 100644 --- a/pdns/bindparser.yy +++ b/pdns/bindparser.yy @@ -132,7 +132,7 @@ command: global_zone_command: ZONETOK quotedname zone_block { - s_di.name=DNSName($2); + s_di.name=ZoneName($2); free($2); parent->commit(s_di); s_di.clear(); @@ -140,7 +140,7 @@ global_zone_command: | ZONETOK quotedname AWORD zone_block { - s_di.name=DNSName($2); + s_di.name=ZoneName($2); free($2); parent->commit(s_di); s_di.clear(); diff --git a/pdns/bindparserclasses.hh b/pdns/bindparserclasses.hh index 655367abdf..a6c63d97ee 100644 --- a/pdns/bindparserclasses.hh +++ b/pdns/bindparserclasses.hh @@ -34,14 +34,14 @@ class BindDomainInfo public: void clear() { - name=DNSName(); + name=ZoneName(); filename=type=""; primaries.clear(); alsoNotify.clear(); d_dev=0; d_ino=0; } - DNSName name; + ZoneName name; string viewName; string filename; vector primaries; @@ -88,7 +88,6 @@ class BindParser set & getAlsoNotify() { return this->alsoNotify; } private: string d_dir{"."}; - typedef map zonedomain_t; set alsoNotify; vector d_zonedomains; bool d_verbose{false}; diff --git a/pdns/communicator.hh b/pdns/communicator.hh index 4fba795a50..7af12f9811 100644 --- a/pdns/communicator.hh +++ b/pdns/communicator.hh @@ -44,7 +44,7 @@ using namespace boost::multi_index; struct SuckRequest { - DNSName domain; + ZoneName domain; ComboAddress primary; bool force; enum RequestPriority : uint8_t @@ -76,13 +76,13 @@ using domains_by_name_t = UniQueue::index::type; class NotificationQueue { public: - void add(const DNSName& domain, const string& ipstring, time_t delay = 0) + void add(const ZoneName& domain, const string& ipstring, time_t delay = 0) { const ComboAddress ipaddress(ipstring); add(domain, ipaddress, delay); } - void add(const DNSName& domain, const ComboAddress& ipaddress, time_t delay = 0) + void add(const ZoneName& domain, const ComboAddress& ipaddress, time_t delay = 0) { NotificationRequest nr; nr.domain = domain; @@ -94,7 +94,7 @@ public: d_nqueue.push_back(nr); } - bool removeIf(const ComboAddress& remote, uint16_t id, const DNSName& domain) + bool removeIf(const ComboAddress& remote, uint16_t id, const ZoneName& domain) { for (auto i = d_nqueue.begin(); i != d_nqueue.end(); ++i) { ComboAddress stQueued{i->ip}; @@ -106,7 +106,7 @@ public: return false; } - bool getOne(DNSName& domain, string& ip, uint16_t* id, bool& purged) + bool getOne(ZoneName& domain, string& ip, uint16_t* id, bool& purged) { for (d_nqueue_t::iterator i = d_nqueue.begin(); i != d_nqueue.end(); ++i) if (i->next <= time(nullptr)) { @@ -139,7 +139,7 @@ public: private: struct NotificationRequest { - DNSName domain; + ZoneName domain; string ip; time_t next; int attempts; @@ -169,17 +169,17 @@ public: time_t doNotifications(PacketHandler* P); void go(); - void drillHole(const DNSName& domain, const string& ip); - bool justNotified(const DNSName& domain, const string& ip); - void addSuckRequest(const DNSName& domain, const ComboAddress& primary, SuckRequest::RequestPriority, bool force = false); + void drillHole(const ZoneName& domain, const string& ip); + bool justNotified(const ZoneName& domain, const string& ip); + void addSuckRequest(const ZoneName& domain, const ComboAddress& primary, SuckRequest::RequestPriority, bool force = false); void addSecondaryCheckRequest(const DomainInfo& di, const ComboAddress& remote); void addTryAutoPrimaryRequest(const DNSPacket& p); - void notify(const DNSName& domain, const string& ip); + void notify(const ZoneName& domain, const string& ip); void mainloop(); void retrievalLoopThread(); - void sendNotification(int sock, const DNSName& domain, const ComboAddress& remote, uint16_t id, UeberBackend* B); - bool notifyDomain(const DNSName& domain, UeberBackend* B); - vector> getSuckRequests(); + void sendNotification(int sock, const ZoneName& domain, const ComboAddress& remote, uint16_t id, UeberBackend* B); + bool notifyDomain(const ZoneName& domain, UeberBackend* B); + vector> getSuckRequests(); size_t getSuckRequestsWaiting(); private: @@ -187,10 +187,10 @@ private: void makeNotifySockets(); void queueNotifyDomain(const DomainInfo& di, UeberBackend* B); int d_nsock4, d_nsock6; - LockGuarded, time_t>> d_holes; + LockGuarded, time_t>> d_holes; - void suck(const DNSName& domain, const ComboAddress& remote, bool force = false); - void ixfrSuck(const DNSName& domain, const TSIGTriplet& tt, const ComboAddress& laddr, const ComboAddress& remote, ZoneStatus& zs, vector* axfr); + void suck(const ZoneName& domain, const ComboAddress& remote, bool force = false); + void ixfrSuck(const ZoneName& domain, const TSIGTriplet& tt, const ComboAddress& laddr, const ComboAddress& remote, ZoneStatus& zs, vector* axfr); void secondaryRefresh(PacketHandler* P); void primaryUpdateCheck(PacketHandler* P); @@ -212,7 +212,7 @@ private: { uint64_t d_sorthelper{0}; UniQueue d_suckdomains; - set d_inprogress; + set d_inprogress; set d_tocheck; struct cmp @@ -228,14 +228,14 @@ private: // Used to keep some state on domains that failed their freshness checks. // uint64_t == counter of the number of failures (increased by 1 every consecutive slave-cycle-interval that the domain fails) // time_t == wait at least until this time before attempting a new check - map> d_failedSecondaryRefresh; + map> d_failedSecondaryRefresh; }; LockGuarded d_data; struct RemoveSentinel { - explicit RemoveSentinel(DNSName dn, CommunicatorClass* cc) : + explicit RemoveSentinel(ZoneName dn, CommunicatorClass* cc) : d_dn(std::move(dn)), d_cc(cc) {} @@ -247,7 +247,7 @@ private: catch (...) { } } - DNSName d_dn; + ZoneName d_dn; CommunicatorClass* d_cc; }; }; diff --git a/pdns/dbdnsseckeeper.cc b/pdns/dbdnsseckeeper.cc index 8685920dc7..d3ce6015f8 100644 --- a/pdns/dbdnsseckeeper.cc +++ b/pdns/dbdnsseckeeper.cc @@ -58,7 +58,7 @@ bool DNSSECKeeper::doesDNSSEC() return d_keymetadb->doesDNSSEC(); } -bool DNSSECKeeper::isSecuredZone(const DNSName& zone, bool useCache) +bool DNSSECKeeper::isSecuredZone(const ZoneName& zone, bool useCache) { if(isPresigned(zone, useCache)) return true; @@ -73,7 +73,7 @@ bool DNSSECKeeper::isSecuredZone(const DNSName& zone, bool useCache) return false; } -bool DNSSECKeeper::isPresigned(const DNSName& name, bool useCache) +bool DNSSECKeeper::isPresigned(const ZoneName& name, bool useCache) { string meta; if (useCache) { @@ -86,7 +86,7 @@ bool DNSSECKeeper::isPresigned(const DNSName& name, bool useCache) } -bool DNSSECKeeper::addKey(const DNSName& name, bool setSEPBit, int algorithm, int64_t& id, int bits, bool active, bool published) +bool DNSSECKeeper::addKey(const ZoneName& name, bool setSEPBit, int algorithm, int64_t& id, int bits, bool active, bool published) { if(!bits) { if(algorithm <= 10) @@ -121,26 +121,26 @@ void DNSSECKeeper::clearAllCaches() { /* This function never fails, the return value is to simplify call chains elsewhere so we can do mutate && clear */ -bool DNSSECKeeper::clearKeyCache(const DNSName& name) +bool DNSSECKeeper::clearKeyCache(const ZoneName& name) { s_keycache.write_lock()->erase(name); return true; } -bool DNSSECKeeper::clearMetaCache(const DNSName& name) +bool DNSSECKeeper::clearMetaCache(const ZoneName& name) { s_metacache.write_lock()->erase(name); ++s_metaCacheCleanActions; return true; } -void DNSSECKeeper::clearCaches(const DNSName& name) +void DNSSECKeeper::clearCaches(const ZoneName& name) { (void)clearKeyCache(name); (void)clearMetaCache(name); } -bool DNSSECKeeper::addKey(const DNSName& name, const DNSSECPrivateKey& dpk, int64_t& id, bool active, bool published) +bool DNSSECKeeper::addKey(const ZoneName& name, const DNSSECPrivateKey& dpk, int64_t& id, bool active, bool published) { DNSBackend::KeyData kd; kd.flags = dpk.getFlags(); // the dpk doesn't get stored, only they key part @@ -158,7 +158,7 @@ static bool keyCompareByKindAndID(const DNSSECKeeper::keyset_t::value_type& a, c pair(!b.second.keyType, b.second.id); } -DNSSECPrivateKey DNSSECKeeper::getKeyById(const DNSName& zname, unsigned int id) +DNSSECPrivateKey DNSSECKeeper::getKeyById(const ZoneName& zname, unsigned int id) { vector keys; d_keymetadb->getDomainKeys(zname, keys); @@ -177,32 +177,32 @@ DNSSECPrivateKey DNSSECKeeper::getKeyById(const DNSName& zname, unsigned int id) } -bool DNSSECKeeper::removeKey(const DNSName& zname, unsigned int id) +bool DNSSECKeeper::removeKey(const ZoneName& zname, unsigned int id) { return d_keymetadb->removeDomainKey(zname, id) && clearKeyCache(zname); } -bool DNSSECKeeper::deactivateKey(const DNSName& zname, unsigned int id) +bool DNSSECKeeper::deactivateKey(const ZoneName& zname, unsigned int id) { return d_keymetadb->deactivateDomainKey(zname, id) && clearKeyCache(zname); } -bool DNSSECKeeper::activateKey(const DNSName& zname, unsigned int id) +bool DNSSECKeeper::activateKey(const ZoneName& zname, unsigned int id) { return d_keymetadb->activateDomainKey(zname, id) && clearKeyCache(zname); } -bool DNSSECKeeper::unpublishKey(const DNSName& zname, unsigned int id) +bool DNSSECKeeper::unpublishKey(const ZoneName& zname, unsigned int id) { return d_keymetadb->unpublishDomainKey(zname, id) && clearKeyCache(zname); } -bool DNSSECKeeper::publishKey(const DNSName& zname, unsigned int id) +bool DNSSECKeeper::publishKey(const ZoneName& zname, unsigned int id) { return d_keymetadb->publishDomainKey(zname, id) && clearKeyCache(zname); } -void DNSSECKeeper::getFromMetaOrDefault(const DNSName& zname, const std::string& key, std::string& value, const std::string& defaultvalue) +void DNSSECKeeper::getFromMetaOrDefault(const ZoneName& zname, const std::string& key, std::string& value, const std::string& defaultvalue) { if (getFromMeta(zname, key, value)) return; @@ -210,7 +210,7 @@ void DNSSECKeeper::getFromMetaOrDefault(const DNSName& zname, const std::string& value = defaultvalue; } -bool DNSSECKeeper::getFromMeta(const DNSName& zname, const std::string& key, std::string& value) +bool DNSSECKeeper::getFromMeta(const ZoneName& zname, const std::string& key, std::string& value) { if (d_metaUpdate) { if (d_keymetadb->inTransaction()) { @@ -273,7 +273,7 @@ bool DNSSECKeeper::getFromMeta(const DNSName& zname, const std::string& key, std return ret; } -bool DNSSECKeeper::getFromMetaNoCache(const DNSName& name, const std::string& kind, std::string& value) +bool DNSSECKeeper::getFromMetaNoCache(const ZoneName& name, const std::string& kind, std::string& value) { std::vector meta; if (d_keymetadb->getDomainMetadata(name, kind, meta)) { @@ -285,7 +285,7 @@ bool DNSSECKeeper::getFromMetaNoCache(const DNSName& name, const std::string& ki return false; } -void DNSSECKeeper::getSoaEdit(const DNSName& zname, std::string& value, bool useCache) +void DNSSECKeeper::getSoaEdit(const ZoneName& zname, std::string& value, bool useCache) { static const string soaEdit(::arg()["default-soa-edit"]); static const string soaEditSigned(::arg()["default-soa-edit-signed"]); @@ -318,7 +318,7 @@ uint64_t DNSSECKeeper::dbdnssecCacheSizes(const std::string& str) return (uint64_t)-1; } -bool DNSSECKeeper::getNSEC3PARAM(const DNSName& zname, NSEC3PARAMRecordContent* ns3p, bool* narrow, bool useCache) +bool DNSSECKeeper::getNSEC3PARAM(const ZoneName& zname, NSEC3PARAMRecordContent* ns3p, bool* narrow, bool useCache) { string value; if(useCache) { @@ -381,7 +381,7 @@ bool DNSSECKeeper::checkNSEC3PARAM(const NSEC3PARAMRecordContent& ns3p, string& return ret; } -bool DNSSECKeeper::setNSEC3PARAM(const DNSName& zname, const NSEC3PARAMRecordContent& ns3p, const bool& narrow) +bool DNSSECKeeper::setNSEC3PARAM(const ZoneName& zname, const NSEC3PARAMRecordContent& ns3p, const bool& narrow) { if (d_keymetadb->inTransaction()) { d_metaUpdate = true; @@ -405,7 +405,7 @@ bool DNSSECKeeper::setNSEC3PARAM(const DNSName& zname, const NSEC3PARAMRecordCon return false; } -bool DNSSECKeeper::unsetNSEC3PARAM(const DNSName& zname) +bool DNSSECKeeper::unsetNSEC3PARAM(const ZoneName& zname) { if (d_keymetadb->inTransaction()) { d_metaUpdate = true; @@ -415,7 +415,7 @@ bool DNSSECKeeper::unsetNSEC3PARAM(const DNSName& zname) } -bool DNSSECKeeper::setPresigned(const DNSName& zname) +bool DNSSECKeeper::setPresigned(const ZoneName& zname) { if (d_keymetadb->inTransaction()) { d_metaUpdate = true; @@ -426,7 +426,7 @@ bool DNSSECKeeper::setPresigned(const DNSName& zname) return d_keymetadb->setDomainMetadata(zname, "PRESIGNED", meta) && clearMetaCache(zname); } -bool DNSSECKeeper::unsetPresigned(const DNSName& zname) +bool DNSSECKeeper::unsetPresigned(const ZoneName& zname) { if (d_keymetadb->inTransaction()) { d_metaUpdate = true; @@ -438,13 +438,13 @@ bool DNSSECKeeper::unsetPresigned(const DNSName& zname) /** * Add domainmetadata to allow publishing CDS records for zone zname * - * @param zname DNSName of the zone + * @param zname ZoneName of the zone * @param digestAlgos string with comma-separated numbers that describe the * used digest algorithms. This is copied to the database * verbatim * @return true if the data was inserted, false otherwise */ -bool DNSSECKeeper::setPublishCDS(const DNSName& zname, const string& digestAlgos) +bool DNSSECKeeper::setPublishCDS(const ZoneName& zname, const string& digestAlgos) { if (d_keymetadb->inTransaction()) { d_metaUpdate = true; @@ -455,7 +455,7 @@ bool DNSSECKeeper::setPublishCDS(const DNSName& zname, const string& digestAlgos return d_keymetadb->setDomainMetadata(zname, "PUBLISH-CDS", meta) && clearMetaCache(zname); } -void DNSSECKeeper::getPublishCDS(const DNSName& zname, std::string& value) +void DNSSECKeeper::getPublishCDS(const ZoneName& zname, std::string& value) { getFromMetaOrDefault(zname, "PUBLISH-CDS", value, ::arg()["default-publish-cds"]); } @@ -463,10 +463,10 @@ void DNSSECKeeper::getPublishCDS(const DNSName& zname, std::string& value) /** * Remove domainmetadata to stop publishing CDS records for zone zname * - * @param zname DNSName of the zone + * @param zname ZoneName of the zone * @return true if the operation was successful, false otherwise */ -bool DNSSECKeeper::unsetPublishCDS(const DNSName& zname) +bool DNSSECKeeper::unsetPublishCDS(const ZoneName& zname) { if (d_keymetadb->inTransaction()) { d_metaUpdate = true; @@ -478,10 +478,10 @@ bool DNSSECKeeper::unsetPublishCDS(const DNSName& zname) /** * Add domainmetadata to allow publishing CDNSKEY records.for zone zname * - * @param zname DNSName of the zone + * @param zname ZoneName of the zone * @return true if the data was inserted, false otherwise */ -bool DNSSECKeeper::setPublishCDNSKEY(const DNSName& zname, bool deleteAlg) +bool DNSSECKeeper::setPublishCDNSKEY(const ZoneName& zname, bool deleteAlg) { if (d_keymetadb->inTransaction()) { d_metaUpdate = true; @@ -492,7 +492,7 @@ bool DNSSECKeeper::setPublishCDNSKEY(const DNSName& zname, bool deleteAlg) return d_keymetadb->setDomainMetadata(zname, "PUBLISH-CDNSKEY", meta) && clearMetaCache(zname); } -void DNSSECKeeper::getPublishCDNSKEY(const DNSName& zname, std::string& value) +void DNSSECKeeper::getPublishCDNSKEY(const ZoneName& zname, std::string& value) { getFromMetaOrDefault(zname, "PUBLISH-CDNSKEY", value, ::arg()["default-publish-cdnskey"]); } @@ -500,10 +500,10 @@ void DNSSECKeeper::getPublishCDNSKEY(const DNSName& zname, std::string& value) /** * Remove domainmetadata to stop publishing CDNSKEY records for zone zname * - * @param zname DNSName of the zone + * @param zname ZoneName of the zone * @return true if the operation was successful, false otherwise */ -bool DNSSECKeeper::unsetPublishCDNSKEY(const DNSName& zname) +bool DNSSECKeeper::unsetPublishCDNSKEY(const ZoneName& zname) { if (d_keymetadb->inTransaction()) { d_metaUpdate = true; @@ -515,11 +515,11 @@ bool DNSSECKeeper::unsetPublishCDNSKEY(const DNSName& zname) /** * Returns all keys that are used to sign the DNSKEY RRSet in a zone * - * @param zname DNSName of the zone + * @param zname ZoneName of the zone * @return a keyset_t with all keys that are used to sign the DNSKEY * RRSet (these are the entrypoint(s) to the zone) */ -DNSSECKeeper::keyset_t DNSSECKeeper::getEntryPoints(const DNSName& zname) +DNSSECKeeper::keyset_t DNSSECKeeper::getEntryPoints(const ZoneName& zname) { DNSSECKeeper::keyset_t ret; DNSSECKeeper::keyset_t keys = getKeys(zname); @@ -530,7 +530,7 @@ DNSSECKeeper::keyset_t DNSSECKeeper::getEntryPoints(const DNSName& zname) return ret; } -DNSSECKeeper::keyset_t DNSSECKeeper::getKeys(const DNSName& zone, bool useCache) +DNSSECKeeper::keyset_t DNSSECKeeper::getKeys(const ZoneName& zone, bool useCache) { static int ttl = ::arg().asNum("dnssec-key-cache-ttl"); // coverity[store_truncates_time_t] @@ -615,7 +615,7 @@ DNSSECKeeper::keyset_t DNSSECKeeper::getKeys(const DNSName& zone, bool useCache) return retkeyset; } -bool DNSSECKeeper::checkKeys(const DNSName& zone, std::optional>> errorMessages) +bool DNSSECKeeper::checkKeys(const ZoneName& zone, std::optional>> errorMessages) { vector dbkeyset; d_keymetadb->getDomainKeys(zone, dbkeyset); @@ -655,7 +655,7 @@ void DNSSECKeeper::getPreRRSIGs(UeberBackend& db, vector& rrs, ui } } -bool DNSSECKeeper::TSIGGrantsAccess(const DNSName& zone, const DNSName& keyname) +bool DNSSECKeeper::TSIGGrantsAccess(const ZoneName& zone, const DNSName& keyname) { vector allowed; @@ -668,7 +668,7 @@ bool DNSSECKeeper::TSIGGrantsAccess(const DNSName& zone, const DNSName& keyname) return false; } -bool DNSSECKeeper::getTSIGForAccess(const DNSName& zone, const ComboAddress& /* primary */, DNSName* keyname) +bool DNSSECKeeper::getTSIGForAccess(const ZoneName& zone, const ComboAddress& /* primary */, DNSName* keyname) { vector keynames; d_keymetadb->getDomainMetadata(zone, "AXFR-MASTER-TSIG", keynames); @@ -682,7 +682,7 @@ bool DNSSECKeeper::getTSIGForAccess(const DNSName& zone, const ComboAddress& /* return false; } -bool DNSSECKeeper::unSecureZone(const DNSName& zone, string& error) { +bool DNSSECKeeper::unSecureZone(const ZoneName& zone, string& error) { // Not calling isSecuredZone(), as it will return false for zones with zero // active keys. DNSSECKeeper::keyset_t keyset=getKeys(zone); @@ -718,7 +718,8 @@ struct RecordStatus * \param info& A string where informational messages are added * \param doTransaction Whether or not to wrap the rectify in a transaction */ -bool DNSSECKeeper::rectifyZone(const DNSName& zone, string& error, string& info, bool doTransaction) { +// NOLINTNEXTLINE(readability-function-cognitive-complexity) +bool DNSSECKeeper::rectifyZone(const ZoneName& zone, string& error, string& info, bool doTransaction) { if (isPresigned(zone, doTransaction)) { error = "Rectify presigned zone '"+zone.toLogString()+"' is not allowed/necessary."; return false; diff --git a/pdns/dnsbackend.cc b/pdns/dnsbackend.cc index 289cee88b6..db5fc19af7 100644 --- a/pdns/dnsbackend.cc +++ b/pdns/dnsbackend.cc @@ -42,7 +42,7 @@ extern StatBag S; // this is so the geoipbackend can set this pointer if loaded for lua-record.cc std::function g_getGeo; -bool DNSBackend::getAuth(const DNSName& target, SOAData* soaData) +bool DNSBackend::getAuth(const ZoneName& target, SOAData* soaData) { return this->getSOA(target, *soaData); } @@ -242,7 +242,7 @@ vector> BackendMakerClass::all(bool metadataOnly) \param sd SOAData which is filled with the SOA details \param unmodifiedSerial bool if set, serial will be returned as stored in the backend (maybe 0) */ -bool DNSBackend::getSOA(const DNSName& domain, SOAData& soaData) +bool DNSBackend::getSOA(const ZoneName& domain, SOAData& soaData) { this->lookup(QType(QType::SOA), domain, -1); S.inc("backend-queries"); @@ -300,7 +300,7 @@ bool DNSBackend::get(DNSZoneRecord& zoneRecord) return true; } -bool DNSBackend::getBeforeAndAfterNames(uint32_t id, const DNSName& zonename, const DNSName& qname, DNSName& before, DNSName& after) +bool DNSBackend::getBeforeAndAfterNames(uint32_t id, const ZoneName& zonename, const DNSName& qname, DNSName& before, DNSName& after) { DNSName unhashed; bool ret = this->getBeforeAndAfterNamesAbsolute(id, qname.makeRelative(zonename).makeLowerCase(), unhashed, before, after); diff --git a/pdns/dnsbackend.hh b/pdns/dnsbackend.hh index 51b04194e2..5b670f439a 100644 --- a/pdns/dnsbackend.hh +++ b/pdns/dnsbackend.hh @@ -54,8 +54,8 @@ struct DomainInfo { DomainInfo() = default; - DNSName zone; - DNSName catalog; + ZoneName zone; + ZoneName catalog; time_t last_check{}; string options; string account; @@ -177,19 +177,19 @@ public: if the backend does not consider itself responsible for the id passed. \param domain_id ID of which a list is requested */ - virtual bool list(const DNSName& target, int domain_id, bool include_disabled = false) = 0; + virtual bool list(const ZoneName& target, int domain_id, bool include_disabled = false) = 0; virtual ~DNSBackend() = default; //! fills the soadata struct with the SOA details. Returns false if there is no SOA. - virtual bool getSOA(const DNSName& domain, SOAData& soaData); + virtual bool getSOA(const ZoneName& domain, SOAData& soaData); virtual bool replaceRRSet(uint32_t /* domain_id */, const DNSName& /* qname */, const QType& /* qt */, const vector& /* rrset */) { return false; } - virtual bool listSubZone(const DNSName& /* zone */, int /* domain_id */) + virtual bool listSubZone(const ZoneName& /* zone */, int /* domain_id */) { return false; } @@ -199,9 +199,9 @@ public: { return (name == "PRESIGNED" || name == "NSEC3PARAM" || name == "NSEC3NARROW"); } - virtual bool getAllDomainMetadata(const DNSName& /* name */, std::map>& /* meta */) { return false; }; - virtual bool getDomainMetadata(const DNSName& /* name */, const std::string& /* kind */, std::vector& /* meta */) { return false; } - virtual bool getDomainMetadataOne(const DNSName& name, const std::string& kind, std::string& value) + virtual bool getAllDomainMetadata(const ZoneName& /* name */, std::map>& /* meta */) { return false; }; + virtual bool getDomainMetadata(const ZoneName& /* name */, const std::string& /* kind */, std::vector& /* meta */) { return false; } + virtual bool getDomainMetadataOne(const ZoneName& name, const std::string& kind, std::string& value) { std::vector meta; if (getDomainMetadata(name, kind, meta)) { @@ -213,8 +213,8 @@ public: return false; } - virtual bool setDomainMetadata(const DNSName& /* name */, const std::string& /* kind */, const std::vector& /* meta */) { return false; } - virtual bool setDomainMetadataOne(const DNSName& name, const std::string& kind, const std::string& value) + virtual bool setDomainMetadata(const ZoneName& /* name */, const std::string& /* kind */, const std::vector& /* meta */) { return false; } + virtual bool setDomainMetadataOne(const ZoneName& name, const std::string& kind, const std::string& value) { const std::vector meta(1, value); return setDomainMetadata(name, kind, meta); @@ -223,7 +223,7 @@ public: virtual void getAllDomains(vector* domains, bool getSerial, bool include_disabled); /** Determines if we are authoritative for a zone, and at what level */ - virtual bool getAuth(const DNSName& target, SOAData* /* sd */); + virtual bool getAuth(const ZoneName& target, SOAData* /* sd */); struct KeyData { @@ -234,13 +234,13 @@ public: bool published{false}; }; - virtual bool getDomainKeys(const DNSName& /* name */, std::vector& /* keys */) { return false; } - virtual bool removeDomainKey(const DNSName& /* name */, unsigned int /* id */) { return false; } - virtual bool addDomainKey(const DNSName& /* name */, const KeyData& /* key */, int64_t& /* id */) { return false; } - virtual bool activateDomainKey(const DNSName& /* name */, unsigned int /* id */) { return false; } - virtual bool deactivateDomainKey(const DNSName& /* name */, unsigned int /* id */) { return false; } - virtual bool publishDomainKey(const DNSName& /* name */, unsigned int /* id */) { return false; } - virtual bool unpublishDomainKey(const DNSName& /* name */, unsigned int /* id */) { return false; } + virtual bool getDomainKeys(const ZoneName& /* name */, std::vector& /* keys */) { return false; } + virtual bool removeDomainKey(const ZoneName& /* name */, unsigned int /* id */) { return false; } + virtual bool addDomainKey(const ZoneName& /* name */, const KeyData& /* key */, int64_t& /* id */) { return false; } + virtual bool activateDomainKey(const ZoneName& /* name */, unsigned int /* id */) { return false; } + virtual bool deactivateDomainKey(const ZoneName& /* name */, unsigned int /* id */) { return false; } + virtual bool publishDomainKey(const ZoneName& /* name */, unsigned int /* id */) { return false; } + virtual bool unpublishDomainKey(const ZoneName& /* name */, unsigned int /* id */) { return false; } virtual bool setTSIGKey(const DNSName& /* name */, const DNSName& /* algorithm */, const string& /* content */) { return false; } virtual bool getTSIGKey(const DNSName& /* name */, DNSName& /* algorithm */, string& /* content */) { return false; } @@ -254,7 +254,7 @@ public: return false; } - virtual bool getBeforeAndAfterNames(uint32_t /* id */, const DNSName& zonename, const DNSName& qname, DNSName& before, DNSName& after); + virtual bool getBeforeAndAfterNames(uint32_t /* id */, const ZoneName& zonename, const DNSName& qname, DNSName& before, DNSName& after); virtual bool updateDNSSECOrderNameAndAuth(uint32_t /* domain_id */, const DNSName& /* qname */, const DNSName& /* ordername */, bool /* auth */, const uint16_t /* qtype */ = QType::ANY) { @@ -295,8 +295,12 @@ public: } //! returns true if primary ip is primary for domain name. - //! starts the transaction for updating domain qname (FIXME: what is id?) - virtual bool startTransaction(const DNSName& /* qname */, int /* id */ = -1) + //! starts the transaction for updating domain qname, destroying all + //! existing data for that domain if id is >= 0. In this case, the id MUST + //! match the DomainInfo information for qname, or very bad things will + //! happen. + //! FIXME: replace this with a bool to make this a less error-prone interface. + virtual bool startTransaction(const ZoneName& /* qname */, int /* id */ = -1) { return false; } @@ -341,7 +345,7 @@ public: } //! if this returns true, DomainInfo di contains information about the domain - virtual bool getDomainInfo(const DNSName& /* domain */, DomainInfo& /* di */, bool /* getSerial */ = true) + virtual bool getDomainInfo(const ZoneName& /* domain */, DomainInfo& /* di */, bool /* getSerial */ = true) { return false; } @@ -351,7 +355,7 @@ public: } //! get a list of IP addresses that should also be notified for a domain - virtual void alsoNotifies(const DNSName& domain, set* ips) + virtual void alsoNotifies(const ZoneName& domain, set* ips) { std::vector meta; getDomainMetadata(domain, "ALSO-NOTIFY", meta); @@ -364,7 +368,7 @@ public: } //! get list of all members in a catalog - [[nodiscard]] virtual bool getCatalogMembers(const DNSName& /* catalog */, vector& /* members */, CatalogInfo::CatalogType /* type */) + [[nodiscard]] virtual bool getCatalogMembers(const ZoneName& /* catalog */, vector& /* members */, CatalogInfo::CatalogType /* type */) { return false; } @@ -385,31 +389,31 @@ public: } //! Called when the Primary list of a domain should be changed - virtual bool setPrimaries(const DNSName& /* domain */, const vector& /* primaries */) + virtual bool setPrimaries(const ZoneName& /* domain */, const vector& /* primaries */) { return false; } //! Called when the Kind of a domain should be changed (primary -> native and similar) - virtual bool setKind(const DNSName& /* domain */, const DomainInfo::DomainKind /* kind */) + virtual bool setKind(const ZoneName& /* domain */, const DomainInfo::DomainKind /* kind */) { return false; } //! Called when the options of a domain should be changed - virtual bool setOptions(const DNSName& /* domain */, const string& /* options */) + virtual bool setOptions(const ZoneName& /* domain */, const string& /* options */) { return false; } //! Called when the catalog of a domain should be changed - virtual bool setCatalog(const DNSName& /* domain */, const DNSName& /* catalog */) + virtual bool setCatalog(const ZoneName& /* domain */, const ZoneName& /* catalog */) { return false; } //! Called when the Account of a domain should be changed - virtual bool setAccount(const DNSName& /* domain */, const string& /* account */) + virtual bool setAccount(const ZoneName& /* domain */, const string& /* account */) { return false; } @@ -436,25 +440,25 @@ public: } //! determine if ip is a autoprimary or a domain - virtual bool autoPrimaryBackend(const string& /* ip */, const DNSName& /* domain */, const vector& /* nsset */, string* /* nameserver */, string* /* account */, DNSBackend** /* db */) + virtual bool autoPrimaryBackend(const string& /* ip */, const ZoneName& /* domain */, const vector& /* nsset */, string* /* nameserver */, string* /* account */, DNSBackend** /* db */) { return false; } //! called by PowerDNS to create a new domain - virtual bool createDomain(const DNSName& /* domain */, const DomainInfo::DomainKind /* kind */, const vector& /* primaries */, const string& /* account */) + virtual bool createDomain(const ZoneName& /* domain */, const DomainInfo::DomainKind /* kind */, const vector& /* primaries */, const string& /* account */) { return false; } //! called by PowerDNS to create a secondary record for a autoPrimary - virtual bool createSecondaryDomain(const string& /* ip */, const DNSName& /* domain */, const string& /* nameserver */, const string& /* account */) + virtual bool createSecondaryDomain(const string& /* ip */, const ZoneName& /* domain */, const string& /* nameserver */, const string& /* account */) { return false; } //! called to delete a domain, incl. all metadata, zone contents, etc. - virtual bool deleteDomain(const DNSName& /* domain */) + virtual bool deleteDomain(const ZoneName& /* domain */) { return false; } diff --git a/pdns/dnsname.cc b/pdns/dnsname.cc index bbac4ffcb6..1af07d4dc5 100644 --- a/pdns/dnsname.cc +++ b/pdns/dnsname.cc @@ -257,7 +257,7 @@ std::string DNSName::toString(const std::string& separator, const bool trailing) void DNSName::toString(std::string& output, const std::string& separator, const bool trailing) const { if (empty()) { - throw std::out_of_range("Attempt to print an unset dnsname"); + throw std::out_of_range("Attempt to print an unset DNSName"); } if (isRoot()) { @@ -298,7 +298,7 @@ std::string DNSName::toLogString() const std::string DNSName::toDNSString() const { if (empty()) { - throw std::out_of_range("Attempt to DNSString an unset dnsname"); + throw std::out_of_range("Attempt to DNSString an unset DNSName"); } return std::string(d_storage.c_str(), d_storage.length()); @@ -324,7 +324,7 @@ size_t DNSName::wirelength() const { bool DNSName::isPartOf(const DNSName& parent) const { if(parent.empty() || empty()) { - throw std::out_of_range("empty dnsnames aren't part of anything"); + throw std::out_of_range("empty DNSNames aren't part of anything"); } if(parent.d_storage.size() > d_storage.size()) { @@ -346,7 +346,7 @@ bool DNSName::isPartOf(const DNSName& parent) const return true; } if (static_cast(*us) > 63) { - throw std::out_of_range("illegal label length in dnsname"); + throw std::out_of_range("illegal label length in DNSName"); } } return false; diff --git a/pdns/dnsname.hh b/pdns/dnsname.hh index 86079bae32..ed3e73f027 100644 --- a/pdns/dnsname.hh +++ b/pdns/dnsname.hh @@ -57,11 +57,6 @@ inline unsigned char dns_tolower(unsigned char c) #include "burtle.hh" #include "views.hh" -// #include "dns.hh" -// #include "logger.hh" - -//#include - /* Quest in life: accept escaped ascii presentations of DNS names and store them "natively" accept a DNS packet with an offset, and extract a DNS name from it @@ -74,6 +69,14 @@ inline unsigned char dns_tolower(unsigned char c) NOTE: For now, everything MUST be . terminated, otherwise it is an error */ +// DNSName: represents a case-insensitive string, allowing for non-printable +// characters. It is used for all kinds of name (of hosts, domains, keys, +// algorithm...) overall the PowerDNS codebase. +// +// The following type traits are provided: +// - EqualityComparable +// - LessThanComparable +// - Hash class DNSName { public: @@ -304,6 +307,11 @@ inline DNSName operator+(const DNSName& lhs, const DNSName& rhs) extern const DNSName g_rootdnsname, g_wildcarddnsname; +// ZoneName: this is equivalent to DNSName, but intended to only store zone +// names. For the time being, they are strictly identical. +using ZoneName = DNSName; +using CanonZoneNameCompare = CanonDNSNameCompare; + template struct SuffixMatchTree { diff --git a/pdns/dnspacket.hh b/pdns/dnspacket.hh index 67b84c651a..8a6500133f 100644 --- a/pdns/dnspacket.hh +++ b/pdns/dnspacket.hh @@ -139,7 +139,7 @@ public: DNSName qdomain; //!< qname of the question 4 - unsure how this is used DNSName qdomainwild; //!< wildcard matched by qname, used by LuaPolicyEngine - DNSName qdomainzone; //!< zone name for the answer (as reflected in SOA for negative responses), used by LuaPolicyEngine + ZoneName qdomainzone; //!< zone name for the answer (as reflected in SOA for negative responses), used by LuaPolicyEngine string d_peer_principal; const DNSName& getTSIGKeyname() const; diff --git a/pdns/dnsrecords.hh b/pdns/dnsrecords.hh index 7bddcc2b6d..a79bd2fbb4 100644 --- a/pdns/dnsrecords.hh +++ b/pdns/dnsrecords.hh @@ -885,7 +885,7 @@ class NSECRecordContent : public DNSRecordContent public: static void report(const ReportIsOnlyCallableByReportAllTypes& guard); NSECRecordContent() = default; - NSECRecordContent(const string& content, const DNSName& zone=DNSName()); + NSECRecordContent(const string& content, const ZoneName& zone=ZoneName()); static std::shared_ptr make(const DNSRecord &dr, PacketReader& pr); static std::shared_ptr make(const string& content); @@ -926,7 +926,7 @@ class NSEC3RecordContent : public DNSRecordContent public: static void report(const ReportIsOnlyCallableByReportAllTypes& guard); NSEC3RecordContent() = default; - NSEC3RecordContent(const string& content, const DNSName& zone=DNSName()); + NSEC3RecordContent(const string& content, const ZoneName& zone=ZoneName()); static std::shared_ptr make(const DNSRecord &dr, PacketReader& pr); static std::shared_ptr make(const string& content); @@ -976,7 +976,7 @@ class CSYNCRecordContent : public DNSRecordContent public: static void report(const ReportIsOnlyCallableByReportAllTypes& guard); CSYNCRecordContent() = default; - CSYNCRecordContent(const string& content, const DNSName& zone=DNSName()); + CSYNCRecordContent(const string& content, const ZoneName& zone=ZoneName()); static std::shared_ptr make(const DNSRecord &dr, PacketReader& pr); static std::shared_ptr make(const string& content); @@ -1009,7 +1009,7 @@ class NSEC3PARAMRecordContent : public DNSRecordContent public: static void report(const ReportIsOnlyCallableByReportAllTypes& guard); NSEC3PARAMRecordContent() = default; - NSEC3PARAMRecordContent(const string& content, const DNSName& zone=DNSName()); + NSEC3PARAMRecordContent(const string& content, const ZoneName& zone=ZoneName()); static std::shared_ptr make(const DNSRecord &dr, PacketReader& pr); static std::shared_ptr make(const string& content); diff --git a/pdns/dnssecinfra.hh b/pdns/dnssecinfra.hh index 32b565d756..3a9b8c8b01 100644 --- a/pdns/dnssecinfra.hh +++ b/pdns/dnssecinfra.hh @@ -292,7 +292,7 @@ string hashQNameWithSalt(const std::string& salt, unsigned int iterations, const void incrementHash(std::string& raw); void decrementHash(std::string& raw); -void addRRSigs(DNSSECKeeper& dk, UeberBackend& db, const std::set& authSet, vector& rrs, DNSPacket* packet=nullptr); +void addRRSigs(DNSSECKeeper& dk, UeberBackend& db, const std::set& authSet, vector& rrs, DNSPacket* packet=nullptr); void addTSIG(DNSPacketWriter& pw, TSIGRecordContent& trc, const DNSName& tsigkeyname, const string& tsigsecret, const string& tsigprevious, bool timersonly); bool validateTSIG(const std::string& packet, size_t sigPos, const TSIGTriplet& tt, const TSIGRecordContent& trc, const std::string& previousMAC, const std::string& theirMAC, bool timersOnly, unsigned int dnsHeaderOffset=0); diff --git a/pdns/dnsseckeeper.hh b/pdns/dnsseckeeper.hh index 04727305ee..5af42115d1 100644 --- a/pdns/dnsseckeeper.hh +++ b/pdns/dnsseckeeper.hh @@ -187,43 +187,43 @@ public: static uint64_t dbdnssecCacheSizes(const std::string& str); static void clearAllCaches(); - static bool clearKeyCache(const DNSName& name); - static bool clearMetaCache(const DNSName& name); - static void clearCaches(const DNSName& name); + static bool clearKeyCache(const ZoneName& name); + static bool clearMetaCache(const ZoneName& name); + static void clearCaches(const ZoneName& name); bool doesDNSSEC(); - bool isSecuredZone(const DNSName& zone, bool useCache=true); - keyset_t getEntryPoints(const DNSName& zname); - keyset_t getKeys(const DNSName& zone, bool useCache = true); - DNSSECPrivateKey getKeyById(const DNSName& zone, unsigned int id); - bool addKey(const DNSName& zname, bool setSEPBit, int algorithm, int64_t& id, int bits=0, bool active=true, bool published=true); - bool addKey(const DNSName& zname, const DNSSECPrivateKey& dpk, int64_t& id, bool active=true, bool published=true); - bool removeKey(const DNSName& zname, unsigned int id); - bool activateKey(const DNSName& zname, unsigned int id); - bool deactivateKey(const DNSName& zname, unsigned int id); - bool publishKey(const DNSName& zname, unsigned int id); - bool unpublishKey(const DNSName& zname, unsigned int id); - bool checkKeys(const DNSName& zname, std::optional>> errorMessages); - - bool getNSEC3PARAM(const DNSName& zname, NSEC3PARAMRecordContent* n3p=nullptr, bool* narrow=nullptr, bool useCache=true); + bool isSecuredZone(const ZoneName& zone, bool useCache=true); + keyset_t getEntryPoints(const ZoneName& zname); + keyset_t getKeys(const ZoneName& zone, bool useCache = true); + DNSSECPrivateKey getKeyById(const ZoneName& zone, unsigned int id); + bool addKey(const ZoneName& zname, bool setSEPBit, int algorithm, int64_t& id, int bits=0, bool active=true, bool published=true); + bool addKey(const ZoneName& zname, const DNSSECPrivateKey& dpk, int64_t& id, bool active=true, bool published=true); + bool removeKey(const ZoneName& zname, unsigned int id); + bool activateKey(const ZoneName& zname, unsigned int id); + bool deactivateKey(const ZoneName& zname, unsigned int id); + bool publishKey(const ZoneName& zname, unsigned int id); + bool unpublishKey(const ZoneName& zname, unsigned int id); + bool checkKeys(const ZoneName& zname, std::optional>> errorMessages); + + bool getNSEC3PARAM(const ZoneName& zname, NSEC3PARAMRecordContent* n3p=nullptr, bool* narrow=nullptr, bool useCache=true); bool checkNSEC3PARAM(const NSEC3PARAMRecordContent& ns3p, string& msg); - bool setNSEC3PARAM(const DNSName& zname, const NSEC3PARAMRecordContent& n3p, const bool& narrow=false); - bool unsetNSEC3PARAM(const DNSName& zname); + bool setNSEC3PARAM(const ZoneName& zname, const NSEC3PARAMRecordContent& n3p, const bool& narrow=false); + bool unsetNSEC3PARAM(const ZoneName& zname); void getPreRRSIGs(UeberBackend& db, vector& rrs, uint32_t signTTL, DNSPacket* p=nullptr); - bool isPresigned(const DNSName& zname, bool useCache=true); - bool setPresigned(const DNSName& zname); - bool unsetPresigned(const DNSName& zname); - bool setPublishCDNSKEY(const DNSName& zname, bool deleteAlg); - void getPublishCDNSKEY(const DNSName& zname, std::string& value); - bool unsetPublishCDNSKEY(const DNSName& zname); - bool setPublishCDS(const DNSName& zname, const string& digestAlgos); - void getPublishCDS(const DNSName& zname, std::string& value); - bool unsetPublishCDS(const DNSName& zname); - - bool TSIGGrantsAccess(const DNSName& zone, const DNSName& keyname); - bool getTSIGForAccess(const DNSName& zone, const ComboAddress& primary, DNSName* keyname); - - void startTransaction(const DNSName& zone, int zone_id) + bool isPresigned(const ZoneName& zname, bool useCache=true); + bool setPresigned(const ZoneName& zname); + bool unsetPresigned(const ZoneName& zname); + bool setPublishCDNSKEY(const ZoneName& zname, bool deleteAlg); + void getPublishCDNSKEY(const ZoneName& zname, std::string& value); + bool unsetPublishCDNSKEY(const ZoneName& zname); + bool setPublishCDS(const ZoneName& zname, const string& digestAlgos); + void getPublishCDS(const ZoneName& zname, std::string& value); + bool unsetPublishCDS(const ZoneName& zname); + + bool TSIGGrantsAccess(const ZoneName& zone, const DNSName& keyname); + bool getTSIGForAccess(const ZoneName& zone, const ComboAddress& primary, DNSName* keyname); + + void startTransaction(const ZoneName& zone, int zone_id) { (*d_keymetadb->backends.begin())->startTransaction(zone, zone_id); } @@ -233,17 +233,17 @@ public: (*d_keymetadb->backends.begin())->commitTransaction(); } - void getFromMetaOrDefault(const DNSName& zname, const std::string& key, std::string& value, const std::string& defaultvalue); - bool getFromMeta(const DNSName& zname, const std::string& key, std::string& value); - void getSoaEdit(const DNSName& zname, std::string& value, bool useCache=true); - bool unSecureZone(const DNSName& zone, std::string& error); - bool rectifyZone(const DNSName& zone, std::string& error, std::string& info, bool doTransaction); + void getFromMetaOrDefault(const ZoneName& zname, const std::string& key, std::string& value, const std::string& defaultvalue); + bool getFromMeta(const ZoneName& zname, const std::string& key, std::string& value); + void getSoaEdit(const ZoneName& zname, std::string& value, bool useCache=true); + bool unSecureZone(const ZoneName& zone, std::string& error); + bool rectifyZone(const ZoneName& zone, std::string& error, std::string& info, bool doTransaction); static void setMaxEntries(size_t maxEntries); typedef std::map > METAValues; private: - bool getFromMetaNoCache(const DNSName& name, const std::string& kind, std::string& value); + bool getFromMetaNoCache(const ZoneName& name, const std::string& kind, std::string& value); int64_t d_metaCacheCleanAction{0}; bool d_metaUpdate{false}; @@ -257,7 +257,7 @@ private: return d_ttd < now; } - DNSName d_domain; + ZoneName d_domain; mutable keys_t d_keys; unsigned int d_ttd; }; @@ -269,7 +269,7 @@ private: return d_ttd < now; } - DNSName d_domain; + ZoneName d_domain; mutable METAValues d_value; time_t d_ttd; }; @@ -281,7 +281,7 @@ private: typedef multi_index_container< KeyCacheEntry, indexed_by< - hashed_unique,member >, + hashed_unique,member >, sequenced> > > keycache_t; @@ -289,7 +289,7 @@ private: typedef multi_index_container< METACacheEntry, indexed_by< - ordered_unique >, + ordered_unique >, sequenced> > > metacache_t; @@ -306,8 +306,8 @@ private: uint32_t localtime_format_YYYYMMDDSS(time_t t, uint32_t seq); // for SOA-EDIT -uint32_t calculateEditSOA(uint32_t old_serial, DNSSECKeeper& dk, const DNSName& zonename); -uint32_t calculateEditSOA(uint32_t old_serial, const string& kind, const DNSName& zonename); +uint32_t calculateEditSOA(uint32_t old_serial, DNSSECKeeper& dk, const ZoneName& zonename); +uint32_t calculateEditSOA(uint32_t old_serial, const string& kind, const ZoneName& zonename); // for SOA-EDIT-DNSUPDATE/API bool increaseSOARecord(DNSResourceRecord& dr, const string& increaseKind, const string& editKind); bool makeIncreasedSOARecord(SOAData& sd, const string& increaseKind, const string& editKind, DNSResourceRecord& rrout); diff --git a/pdns/dnssecsigner.cc b/pdns/dnssecsigner.cc index 4a9ab1e7da..50fe1a3b64 100644 --- a/pdns/dnssecsigner.cc +++ b/pdns/dnssecsigner.cc @@ -106,7 +106,7 @@ static void fillOutRRSIG(DNSSECPrivateKey& dpk, const DNSName& signQName, RRSIGR /* this is where the RRSIGs begin, keys are retrieved, but the actual signing happens in fillOutRRSIG */ -static int getRRSIGsForRRSET(DNSSECKeeper& dk, const DNSName& signer, const DNSName& signQName, uint16_t signQType, uint32_t signTTL, +static int getRRSIGsForRRSET(DNSSECKeeper& dk, const ZoneName& signer, const DNSName& signQName, uint16_t signQType, uint32_t signTTL, const sortedRecords_t& toSign, vector& rrcs) { if(toSign.empty()) @@ -143,7 +143,7 @@ static int getRRSIGsForRRSET(DNSSECKeeper& dk, const DNSName& signer, const DNSN } // this is the entrypoint from DNSPacket -static void addSignature(DNSSECKeeper& dk, UeberBackend& db, const DNSName& signer, const DNSName& signQName, const DNSName& wildcardname, uint16_t signQType, +static void addSignature(DNSSECKeeper& dk, UeberBackend& db, const ZoneName& signer, const DNSName& signQName, const DNSName& wildcardname, uint16_t signQType, uint32_t signTTL, DNSResourceRecord::Place signPlace, sortedRecords_t& toSign, vector& outsigned, uint32_t origTTL, DNSPacket* packet) { @@ -190,10 +190,10 @@ static bool rrsigncomp(const DNSZoneRecord& a, const DNSZoneRecord& b) return std::tie(a.dr.d_place, a.dr.d_type) < std::tie(b.dr.d_place, b.dr.d_type); } -static bool getBestAuthFromSet(const set& authSet, const DNSName& name, DNSName& auth) +static bool getBestAuthFromSet(const set& authSet, const DNSName& name, ZoneName& auth) { auth.trimToLabels(0); - DNSName sname(name); + ZoneName sname(name); do { if(authSet.find(sname) != authSet.end()) { auth = sname; @@ -205,7 +205,7 @@ static bool getBestAuthFromSet(const set& authSet, const DNSName& name, return false; } -void addRRSigs(DNSSECKeeper& dk, UeberBackend& db, const set& authSet, vector& rrs, DNSPacket* packet) +void addRRSigs(DNSSECKeeper& dk, UeberBackend& db, const set& authSet, vector& rrs, DNSPacket* packet) { stable_sort(rrs.begin(), rrs.end(), rrsigncomp); @@ -220,7 +220,7 @@ void addRRSigs(DNSSECKeeper& dk, UeberBackend& db, const set& authSet, vector signedRecords; signedRecords.reserve(rrs.size()*1.5); // cout<dr.d_type || signQName != pos->dr.d_name)) { if (getBestAuthFromSet(authSet, authQName, signer)) diff --git a/pdns/dynhandler.cc b/pdns/dynhandler.cc index 4add3bfbdf..2fef06ac1f 100644 --- a/pdns/dynhandler.cc +++ b/pdns/dynhandler.cc @@ -139,7 +139,7 @@ string DLPurgeHandler(const vector& parts, Utility::pid_t /* ppid */) g_log<& parts, Utility::pid_t /* pp if(parts.size()!=2 && parts.size()!=3) return "syntax: retrieve zone [ip]"; - DNSName domain; + ZoneName domain; try { - domain = DNSName(parts[1]); + domain = ZoneName(parts[1]); } catch (...) { return "Failed to parse zone as valid DNS name"; } @@ -295,9 +295,9 @@ string DLNotifyHostHandler(const vector& parts, Utility::pid_t /* ppid * if(!::arg().mustDo("primary") && !(::arg().mustDo("secondary") && ::arg().mustDo("secondary-do-renotify"))) return "PowerDNS not configured as primary, or secondary with re-notifications"; - DNSName domain; + ZoneName domain; try { - domain = DNSName(parts[1]); + domain = ZoneName(parts[1]); } catch (...) { return "Failed to parse zone as valid DNS name"; } @@ -342,13 +342,13 @@ string DLNotifyHandler(const vector& parts, Utility::pid_t /* ppid */) return std::to_string(notified)+" out of "+std::to_string(total)+" zones added to queue - see log"; return "Added " + std::to_string(total) + " MASTER/SLAVE/PRODUCER/CONSUMER zones to queue"; } else { - DNSName domain; + ZoneName domain; try { - domain = DNSName(parts[1]); + domain = ZoneName(parts[1]); } catch (...) { return "Failed to parse zone as valid DNS name"; } - if(!Communicator.notifyDomain(DNSName(parts[1]), &B)) + if(!Communicator.notifyDomain(domain, &B)) return "Failed to add to the queue - see log"; return "Added to queue"; } diff --git a/pdns/ixfrdist-stats.hh b/pdns/ixfrdist-stats.hh index 69f48f9458..c6cb0f564f 100644 --- a/pdns/ixfrdist-stats.hh +++ b/pdns/ixfrdist-stats.hh @@ -36,37 +36,37 @@ class ixfrdistStats { std::string getStats(); - void setSOASerial(const DNSName& d, const uint32_t serial) { + void setSOASerial(const ZoneName& d, const uint32_t serial) { auto stat = getRegisteredDomain(d); stat->second.currentSOA = serial; stat->second.haveZone = true; } - void incrementSOAChecks(const DNSName& d, const uint64_t amount = 1) { + void incrementSOAChecks(const ZoneName& d, const uint64_t amount = 1) { getRegisteredDomain(d)->second.numSOAChecks += amount; } - void incrementSOAChecksFailed(const DNSName& d, const uint64_t amount = 1) { + void incrementSOAChecksFailed(const ZoneName& d, const uint64_t amount = 1) { getRegisteredDomain(d)->second.numSOAChecksFailed += amount; } - void incrementSOAinQueries(const DNSName& d, const uint64_t amount = 1) { + void incrementSOAinQueries(const ZoneName& d, const uint64_t amount = 1) { getRegisteredDomain(d)->second.numSOAinQueries += amount; } - void incrementAXFRinQueries(const DNSName& d, const uint64_t amount = 1) { + void incrementAXFRinQueries(const ZoneName& d, const uint64_t amount = 1) { getRegisteredDomain(d)->second.numAXFRinQueries += amount; } - void incrementIXFRinQueries(const DNSName& d, const uint64_t amount = 1) { + void incrementIXFRinQueries(const ZoneName& d, const uint64_t amount = 1) { getRegisteredDomain(d)->second.numIXFRinQueries += amount; } - void incrementAXFRFailures(const DNSName& d, const uint64_t amount = 1) { + void incrementAXFRFailures(const ZoneName& d, const uint64_t amount = 1) { getRegisteredDomain(d)->second.numAXFRFailures += amount; } - void incrementIXFRFailures(const DNSName& d, const uint64_t amount = 1) { + void incrementIXFRFailures(const ZoneName& d, const uint64_t amount = 1) { getRegisteredDomain(d)->second.numIXFRFailures += amount; } - void registerDomain(const DNSName& d) { + void registerDomain(const ZoneName& d) { domainStats[d].haveZone = false; } - void incrementUnknownDomainInQueries(const DNSName& /* d */) + void incrementUnknownDomainInQueries(const ZoneName& /* d */) { // the name is ignored. It would be great to report it, but we don't want to blow up Prometheus progStats.unknownDomainInQueries += 1; } @@ -98,11 +98,11 @@ class ixfrdistStats { std::atomic unknownDomainInQueries{0}; }; - std::map domainStats; + std::map domainStats; std::array, 16> notimpStats{}; programStats progStats; - std::map::iterator getRegisteredDomain(const DNSName& d) { + std::map::iterator getRegisteredDomain(const DNSName& d) { auto ret = domainStats.find(d); if (ret == domainStats.end()) { throw PDNSException("Domain '" + d.toLogString() + "' not defined in the statistics map"); diff --git a/pdns/ixfrdist.cc b/pdns/ixfrdist.cc index 61eb200ef1..ac755d5b22 100644 --- a/pdns/ixfrdist.cc +++ b/pdns/ixfrdist.cc @@ -78,7 +78,7 @@ ArgvMap &arg() } /* END Needed because of deeper dependencies */ -// Allows reading/writing ComboAddresses and DNSNames in YAML-cpp +// Allows reading/writing ComboAddresses and ZoneNames in YAML-cpp namespace YAML { template<> struct convert { @@ -101,16 +101,16 @@ struct convert { }; template<> -struct convert { - static Node encode(const DNSName& rhs) { +struct convert { + static Node encode(const ZoneName& rhs) { return Node(rhs.toStringRootDot()); } - static bool decode(const Node& node, DNSName& rhs) { + static bool decode(const Node& node, ZoneName& rhs) { if (!node.IsScalar()) { return false; } try { - rhs = DNSName(node.as()); + rhs = ZoneName(node.as()); return true; } catch(const runtime_error &e) { return false; @@ -165,14 +165,14 @@ struct ixfrdistdomain_t { }; // This contains the configuration for each domain -static map g_domainConfigs; +static map g_domainConfigs; // Map domains and their data -static LockGuarded>> g_soas; +static LockGuarded>> g_soas; // Queue of received NOTIFYs, already verified against their primary IPs // Lazily implemented as a set -static LockGuarded> g_notifiesReceived; +static LockGuarded> g_notifiesReceived; // Queue of outgoing NOTIFY static LockGuarded g_notificationQueue; @@ -217,7 +217,7 @@ static bool sortSOA(uint32_t i, uint32_t j) { return rfc1982LessThan(i, j); } -static void cleanUpDomain(const DNSName& domain, const uint16_t& keep, const string& workdir) { +static void cleanUpDomain(const ZoneName& domain, const uint16_t& keep, const string& workdir) { string dir = workdir + "/" + domain.toString(); vector zoneVersions; auto directoryError = pdns::visit_directory(dir, [&zoneVersions]([[maybe_unused]] ino_t inodeNumber, const std::string_view& name) { @@ -288,12 +288,12 @@ static void makeIXFRDiff(const records_t& from, const records_t& to, std::shared } /* you can _never_ alter the content of the resulting shared pointer */ -static std::shared_ptr getCurrentZoneInfo(const DNSName& domain) +static std::shared_ptr getCurrentZoneInfo(const ZoneName& domain) { return (*g_soas.lock())[domain]; } -static void updateCurrentZoneInfo(const DNSName& domain, std::shared_ptr& newInfo) +static void updateCurrentZoneInfo(const ZoneName& domain, std::shared_ptr& newInfo) { auto soas = g_soas.lock(); (*soas)[domain] = newInfo; @@ -301,7 +301,7 @@ static void updateCurrentZoneInfo(const DNSName& domain, std::shared_ptr meta; std::vector packet; @@ -356,7 +356,7 @@ static void communicatorReceiveNotificationAnswers(const int sock4, const int so static void communicatorSendNotifications(const int sock4, const int sock6) { - DNSName domain; + ZoneName domain; string destinationIp; uint16_t notificationId = 0; bool purged{false}; @@ -407,11 +407,11 @@ static void communicatorThread() static void updateThread(const string& workdir, const uint16_t& keep, const uint16_t& axfrTimeout, const uint16_t& soaRetry, const uint32_t axfrMaxRecords) { // NOLINT(readability-function-cognitive-complexity) 13400 https://github.com/PowerDNS/pdns/issues/13400 Habbie: ixfrdist: reduce complexity setThreadName("ixfrdist/update"); - std::map lastCheck; + std::map lastCheck; // Initialize the serials we have for (const auto &domainConfig : g_domainConfigs) { - DNSName domain = domainConfig.first; + ZoneName domain = domainConfig.first; lastCheck[domain] = 0; string dir = workdir + "/" + domain.toString(); try { @@ -464,7 +464,7 @@ static void updateThread(const string& workdir, const uint16_t& keep, const uint break; } - DNSName domain = domainConfig.first; + ZoneName domain = domainConfig.first; shared_ptr current_soa; const auto& zoneInfo = getCurrentZoneInfo(domain); if (zoneInfo != nullptr) { @@ -1391,7 +1391,7 @@ static bool parseAndCheckConfig(const string& configpath, YAML::Node& config) { retval = false; continue; } - domain["domain"].as(); + domain["domain"].as(); } catch (const runtime_error &e) { g_log<()<<"': "< parseConfiguration(int argc, char** for (auto const &domain : config["domains"]) { set s; s.insert(domain["master"].as()); - g_domainConfigs[domain["domain"].as()].primaries = s; + g_domainConfigs[domain["domain"].as()].primaries = s; if (domain["max-soa-refresh"].IsDefined()) { - g_domainConfigs[domain["domain"].as()].maxSOARefresh = domain["max-soa-refresh"].as(); + g_domainConfigs[domain["domain"].as()].maxSOARefresh = domain["max-soa-refresh"].as(); } if (domain["notify"].IsDefined()) { - auto& listset = g_domainConfigs[domain["domain"].as()].notify; + auto& listset = g_domainConfigs[domain["domain"].as()].notify; if (domain["notify"].IsScalar()) { auto remote = domain["notify"].as(); try { @@ -1582,7 +1582,7 @@ static std::optional parseConfiguration(int argc, char** } } } - g_stats.registerDomain(domain["domain"].as()); + g_stats.registerDomain(domain["domain"].as()); } for (const auto &addr : config["acl"].as>()) { diff --git a/pdns/ixfrutils.cc b/pdns/ixfrutils.cc index 53e1831353..5babad55f4 100644 --- a/pdns/ixfrutils.cc +++ b/pdns/ixfrutils.cc @@ -31,7 +31,7 @@ #include "zoneparser-tng.hh" #include "dnsparser.hh" -uint32_t getSerialFromPrimary(const ComboAddress& primary, const DNSName& zone, shared_ptr& sr, const TSIGTriplet& tt, const uint16_t timeout) +uint32_t getSerialFromPrimary(const ComboAddress& primary, const ZoneName& zone, shared_ptr& sr, const TSIGTriplet& tt, const uint16_t timeout) { vector packet; DNSPacketWriter pw(packet, zone, QType::SOA); @@ -126,7 +126,7 @@ static void writeRecords(FILE* fp, const records_t& records) } } -void writeZoneToDisk(const records_t& records, const DNSName& zone, const std::string& directory) +void writeZoneToDisk(const records_t& records, const ZoneName& zone, const std::string& directory) { DNSRecord soa; auto serial = getSerialFromRecords(records, soa); @@ -169,7 +169,7 @@ void writeZoneToDisk(const records_t& records, const DNSName& zone, const std::s } } -void loadZoneFromDisk(records_t& records, const string& fname, const DNSName& zone) +void loadZoneFromDisk(records_t& records, const string& fname, const ZoneName& zone) { ZoneParserTNG zpt(fname, zone); @@ -197,7 +197,7 @@ void loadZoneFromDisk(records_t& records, const string& fname, const DNSName& zo * Load the zone `zone` from `fname` and put the first found SOA into `soa` * Does NOT check for nullptr */ -void loadSOAFromDisk(const DNSName& zone, const string& fname, shared_ptr& soa, uint32_t& soaTTL) +void loadSOAFromDisk(const ZoneName& zone, const string& fname, shared_ptr& soa, uint32_t& soaTTL) { ZoneParserTNG zpt(fname, zone); zpt.disableGenerate(); diff --git a/pdns/ixfrutils.hh b/pdns/ixfrutils.hh index 10285029c0..92579181b2 100644 --- a/pdns/ixfrutils.hh +++ b/pdns/ixfrutils.hh @@ -56,9 +56,9 @@ typedef multi_index_container < > /* indexed_by */ > /* multi_index_container */ records_t; -uint32_t getSerialFromPrimary(const ComboAddress& primary, const DNSName& zone, shared_ptr& sr, const TSIGTriplet& tt = TSIGTriplet(), const uint16_t timeout = 2); +uint32_t getSerialFromPrimary(const ComboAddress& primary, const ZoneName& zone, shared_ptr& sr, const TSIGTriplet& tt = TSIGTriplet(), const uint16_t timeout = 2); uint32_t getSerialFromDir(const std::string& dir); uint32_t getSerialFromRecords(const records_t& records, DNSRecord& soaret); -void writeZoneToDisk(const records_t& records, const DNSName& zone, const std::string& directory); -void loadZoneFromDisk(records_t& records, const string& fname, const DNSName& zone); -void loadSOAFromDisk(const DNSName& zone, const string& fname, shared_ptr& soa, uint32_t& soaTTL); +void writeZoneToDisk(const records_t& records, const ZoneName& zone, const std::string& directory); +void loadZoneFromDisk(records_t& records, const string& fname, const ZoneName& zone); +void loadSOAFromDisk(const ZoneName& zone, const string& fname, shared_ptr& soa, uint32_t& soaTTL); diff --git a/pdns/ixplore.cc b/pdns/ixplore.cc index a8e0c3cba1..bf8bd064af 100644 --- a/pdns/ixplore.cc +++ b/pdns/ixplore.cc @@ -73,7 +73,7 @@ int main(int argc, char** argv) { } if(command=="diff") { records_t before, after; - DNSName zone(argv[2]); + ZoneName zone(argv[2]); cout<<"Loading before from "< lookup(const DNSName& name, uint16_t qtype, in return ret; } -static bool getAuth(const DNSName& name, uint16_t qtype, SOAData* soaData) +static bool getAuth(const ZoneName& name, uint16_t qtype, SOAData* soaData) { static LockGuarded s_ub; @@ -1567,10 +1567,10 @@ static vector lua_all(const vector< pair >& ips) static vector lua_dblookup(const string& record, uint16_t qtype) { - DNSName rec; + ZoneName rec; vector ret; try { - rec = DNSName(record); + rec = ZoneName(record); } catch (const std::exception& e) { g_log << Logger::Error << "DB lookup cannot be performed, the name (" << record << ") is malformed: " << e.what() << endl; diff --git a/pdns/misc.hh b/pdns/misc.hh index efc5e8bf20..6129d37664 100644 --- a/pdns/misc.hh +++ b/pdns/misc.hh @@ -45,6 +45,7 @@ #include "namespaces.hh" class DNSName; +using ZoneName = DNSName; // Do not change to "using TSIGHashEnum ..." until you know CodeQL does not choke on it typedef enum @@ -476,7 +477,7 @@ inline bool isCanonical(const string& qname) return qname[qname.size()-1]=='.'; } -inline DNSName toCanonic(const DNSName& zone, const string& qname) +inline DNSName toCanonic(const ZoneName& zone, const string& qname) { if(qname.size()==1 && qname[0]=='@') return zone; diff --git a/pdns/nsecrecords.cc b/pdns/nsecrecords.cc index eadeebb696..4161587dfd 100644 --- a/pdns/nsecrecords.cc +++ b/pdns/nsecrecords.cc @@ -174,7 +174,7 @@ std::shared_ptr NSECRecordContent::make(const string& content) return std::make_shared(content); } -NSECRecordContent::NSECRecordContent(const string& content, const DNSName& zone) +NSECRecordContent::NSECRecordContent(const string& content, const ZoneName& zone) { RecordTextReader rtr(content, zone); rtr.xfrName(d_next); @@ -223,7 +223,7 @@ std::shared_ptr NSEC3RecordContent::make(const string& content return std::make_shared(content); } -NSEC3RecordContent::NSEC3RecordContent(const string& content, const DNSName& zone) +NSEC3RecordContent::NSEC3RecordContent(const string& content, const ZoneName& zone) { RecordTextReader rtr(content, zone); rtr.xfr8BitInt(d_algorithm); @@ -297,7 +297,7 @@ std::shared_ptr NSEC3PARAMRecordContent::make(const string& co return std::make_shared(content); } -NSEC3PARAMRecordContent::NSEC3PARAMRecordContent(const string& content, const DNSName& zone) +NSEC3PARAMRecordContent::NSEC3PARAMRecordContent(const string& content, const ZoneName& zone) { RecordTextReader rtr(content, zone); rtr.xfr8BitInt(d_algorithm); @@ -353,7 +353,7 @@ std::shared_ptr CSYNCRecordContent::make(const string& content return std::make_shared(content); } -CSYNCRecordContent::CSYNCRecordContent(const string& content, const DNSName& zone) +CSYNCRecordContent::CSYNCRecordContent(const string& content, const ZoneName& zone) { RecordTextReader rtr(content, zone); rtr.xfr32BitInt(d_serial); diff --git a/pdns/pdnsutil.cc b/pdns/pdnsutil.cc index ae2c0bcb15..c144571792 100644 --- a/pdns/pdnsutil.cc +++ b/pdns/pdnsutil.cc @@ -205,7 +205,7 @@ static int usage(const std::string_view synopsis) return EXIT_FAILURE; } -static bool rectifyZone(DNSSECKeeper& dk, const DNSName& zone, bool quiet = false, bool rectifyTransaction = true) +static bool rectifyZone(DNSSECKeeper& dk, const ZoneName& zone, bool quiet = false, bool rectifyTransaction = true) { string output; string error; @@ -286,7 +286,7 @@ static bool rectifyAllZones(DNSSECKeeper &dk, bool quiet = false) return result; } -static int checkZone(DNSSECKeeper &dk, UeberBackend &B, const DNSName& zone, const vector* suppliedrecords=nullptr) // NOLINT(readability-function-cognitive-complexity,readability-identifier-length) +static int checkZone(DNSSECKeeper &dk, UeberBackend &B, const ZoneName& zone, const vector* suppliedrecords=nullptr) // NOLINT(readability-function-cognitive-complexity,readability-identifier-length) { int numerrors=0; int numwarnings=0; @@ -372,7 +372,7 @@ static int checkZone(DNSSECKeeper &dk, UeberBackend &B, const DNSName& zone, con } // Check for delegation in parent zone - DNSName parent(zone); + ZoneName parent(zone); while(parent.chopOff()) { SOAData sd_p; if(B.getSOAUncached(parent, sd_p)) { @@ -905,7 +905,7 @@ static int checkAllZones(DNSSECKeeper &dk, bool exitOnError) multi_index_container< DomainInfo, indexed_by< - ordered_non_unique< member, CanonDNSNameCompare >, + ordered_non_unique< member, CanonZoneNameCompare >, ordered_non_unique< member > > > seenInfos; @@ -944,7 +944,7 @@ static int checkAllZones(DNSSECKeeper &dk, bool exitOnError) return EXIT_FAILURE; } -static int increaseSerial(const DNSName& zone, DNSSECKeeper &dk) +static int increaseSerial(const ZoneName& zone, DNSSECKeeper &dk) { UtilBackend B("default"); //NOLINT(readability-identifier-length) SOAData sd; @@ -1008,7 +1008,7 @@ static int increaseSerial(const DNSName& zone, DNSSECKeeper &dk) return 0; } -static int deleteZone(const DNSName &zone) { +static int deleteZone(const ZoneName &zone) { UtilBackend B; //NOLINT(readability-identifier-length) DomainInfo di; if (! B.getDomainInfo(zone, di)) { @@ -1113,7 +1113,7 @@ static int listKeys(const string &zname, DNSSECKeeper& dk){ if (!zname.empty()) { DomainInfo di; - if(!B.getDomainInfo(DNSName(zname), di)) { + if(!B.getDomainInfo(ZoneName(zname), di)) { cerr << "Zone "<& cmds) { DNSResourceRecord rr; vector newrrs; - DNSName zone(cmds.at(1)); + ZoneName zone(cmds.at(1)); DNSName name; if (cmds.at(2) == "@") name=zone; @@ -1838,7 +1838,7 @@ static int deleteRRSet(const std::string& zone_, const std::string& name_, const { UtilBackend B; //NOLINT(readability-identifier-length) DomainInfo di; - DNSName zone(zone_); + ZoneName zone(zone_); if(!B.getDomainInfo(zone, di)) { cerr << "Zone '" << zone << "' does not exist" << endl; return EXIT_FAILURE; @@ -1907,7 +1907,7 @@ static int listMemberZones(const string& catalog) UtilBackend B("default"); //NOLINT(readability-identifier-length) - DNSName catz(catalog); + ZoneName catz(catalog); DomainInfo di; if (!B.getDomainInfo(catz, di)) { cerr << "Zone '" << catz << "' not found" << endl; @@ -1953,7 +1953,7 @@ static bool testAlgorithms() return DNSCryptoKeyEngine::testAll(); } -static void testSpeed(const DNSName& zone, int cores) +static void testSpeed(const ZoneName& zone, int cores) { DNSResourceRecord rr; rr.qname=DNSName("blah")+zone; @@ -1969,7 +1969,7 @@ static void testSpeed(const DNSName& zone, int cores) throw runtime_error("No backends available for DNSSEC key storage"); } - ChunkedSigningPipe csp(DNSName(zone), true, cores, 100); + ChunkedSigningPipe csp(zone, true, cores, 100); vector signatures; uint32_t rnd; @@ -2038,7 +2038,7 @@ static void verifyCrypto(const string& zone) } } -static bool disableDNSSECOnZone(DNSSECKeeper& dk, const DNSName& zone) +static bool disableDNSSECOnZone(DNSSECKeeper& dk, const ZoneName& zone) { UtilBackend B("default"); //NOLINT(readability-identifier-length) DomainInfo di; @@ -2056,7 +2056,7 @@ static bool disableDNSSECOnZone(DNSSECKeeper& dk, const DNSName& zone) return ret; } -static int setZoneOptionsJson(const DNSName& zone, const string& options) +static int setZoneOptionsJson(const ZoneName& zone, const string& options) { UtilBackend B("default"); //NOLINT(readability-identifier-length) DomainInfo di; @@ -2072,7 +2072,7 @@ static int setZoneOptionsJson(const DNSName& zone, const string& options) return EXIT_SUCCESS; } -static int setZoneOption(const DNSName& zone, const string& type, const string& option, const set& values) +static int setZoneOption(const ZoneName& zone, const string& type, const string& option, const set& values) { UtilBackend B("default"); //NOLINT(readability-identifier-length) DomainInfo di; @@ -2111,7 +2111,7 @@ static int setZoneOption(const DNSName& zone, const string& type, const string& return EXIT_SUCCESS; } -static int setZoneCatalog(const DNSName& zone, const DNSName& catalog) +static int setZoneCatalog(const ZoneName& zone, const ZoneName& catalog) { UtilBackend B("default"); //NOLINT(readability-identifier-length) DomainInfo di; @@ -2127,7 +2127,7 @@ static int setZoneCatalog(const DNSName& zone, const DNSName& catalog) return EXIT_SUCCESS; } -static int setZoneAccount(const DNSName& zone, const string &account) +static int setZoneAccount(const ZoneName& zone, const string &account) { UtilBackend B("default"); //NOLINT(readability-identifier-length) DomainInfo di; @@ -2143,7 +2143,7 @@ static int setZoneAccount(const DNSName& zone, const string &account) return EXIT_SUCCESS; } -static int setZoneKind(const DNSName& zone, const DomainInfo::DomainKind kind) +static int setZoneKind(const ZoneName& zone, const DomainInfo::DomainKind kind) { UtilBackend B("default"); //NOLINT(readability-identifier-length) DomainInfo di; @@ -2159,7 +2159,7 @@ static int setZoneKind(const DNSName& zone, const DomainInfo::DomainKind kind) return EXIT_SUCCESS; } -static bool showZone(DNSSECKeeper& dnsseckeeper, const DNSName& zone, bool exportDS = false) // NOLINT(readability-function-cognitive-complexity) +static bool showZone(DNSSECKeeper& dnsseckeeper, const ZoneName& zone, bool exportDS = false) // NOLINT(readability-function-cognitive-complexity) { UtilBackend B("default"); //NOLINT(readability-identifier-length) DomainInfo di; @@ -2387,7 +2387,7 @@ static bool showZone(DNSSECKeeper& dnsseckeeper, const DNSName& zone, bool expor return true; } -static bool secureZone(DNSSECKeeper& dk, const DNSName& zone) +static bool secureZone(DNSSECKeeper& dk, const ZoneName& zone) { // temp var for addKey int64_t id{-1}; @@ -2476,7 +2476,7 @@ static bool secureZone(DNSSECKeeper& dk, const DNSName& zone) return true; } -static int testSchema(DNSSECKeeper& dk, const DNSName& zone) +static int testSchema(DNSSECKeeper& dk, const ZoneName& zone) { cout<<"Note: test-schema will try to create the zone, but it will not remove it."<& values, bool clobber) { +static int addOrSetMeta(const ZoneName& zone, const string& kind, const vector& values, bool clobber) { UtilBackend B("default"); //NOLINT(readability-identifier-length) DomainInfo di; @@ -2773,7 +2773,7 @@ static int zonemdVerifyFile(vector& cmds, const std::string_view synopsi cmds[1].clear(); } - return zonemdVerifyFile(DNSName(cmds[1]), cmds[2]); + return zonemdVerifyFile(ZoneName(cmds[1]), cmds[2]); } @@ -2784,7 +2784,7 @@ static int testSchema(vector& cmds, const std::string_view synopsis) return usage(synopsis); } DNSSECKeeper dk; //NOLINT(readability-identifier-length) - return testSchema(dk, DNSName(cmds.at(1))); + return testSchema(dk, ZoneName(cmds.at(1))); } static int rectifyZone(vector& cmds, const std::string_view synopsis) @@ -2795,7 +2795,7 @@ static int rectifyZone(vector& cmds, const std::string_view synopsis) DNSSECKeeper dk; //NOLINT(readability-identifier-length) int exitCode = 0; for(unsigned int n = 1; n < cmds.size(); ++n) { // NOLINT(readability-identifier-length) - if (!rectifyZone(dk, DNSName(cmds.at(n)))) { + if (!rectifyZone(dk, ZoneName(cmds.at(n)))) { exitCode = 1; } } @@ -2819,7 +2819,7 @@ static int checkZone(vector& cmds, const std::string_view synopsis) } DNSSECKeeper dk; //NOLINT(readability-identifier-length) UtilBackend B("default"); // NOLINT(readability-identifier-length) - return checkZone(dk, B, DNSName(cmds.at(1))); + return checkZone(dk, B, ZoneName(cmds.at(1))); } static int benchDb(vector& cmds, [[maybe_unused]] const std::string_view synopsis) @@ -2859,7 +2859,7 @@ static int testSpeed(vector& cmds, const std::string_view synopsis) if(cmds.size() < 3) { return usage(synopsis); } - testSpeed(DNSName(cmds.at(1)), pdns::checked_stoi(cmds.at(2))); + testSpeed(ZoneName(cmds.at(1)), pdns::checked_stoi(cmds.at(2))); return 0; } @@ -2878,7 +2878,7 @@ static int showZone(vector& cmds, const std::string_view synopsis) return usage(synopsis); } DNSSECKeeper dk; //NOLINT(readability-identifier-length) - if (!showZone(dk, DNSName(cmds.at(1)))) { + if (!showZone(dk, ZoneName(cmds.at(1)))) { return 1; } return 0; @@ -2890,7 +2890,7 @@ static int exportZoneDS(vector& cmds, const std::string_view synopsis) return usage(synopsis); } DNSSECKeeper dk; //NOLINT(readability-identifier-length) - if (!showZone(dk, DNSName(cmds.at(1)), true)) { + if (!showZone(dk, ZoneName(cmds.at(1)), true)) { return 1; } return 0; @@ -2902,7 +2902,7 @@ static int disableDNSSEC(vector& cmds, const std::string_view synopsis) return usage(synopsis); } DNSSECKeeper dk; //NOLINT(readability-identifier-length) - DNSName zone(cmds.at(1)); + ZoneName zone(cmds.at(1)); if(!disableDNSSECOnZone(dk, zone)) { cerr << "Cannot disable DNSSEC on " << zone << endl; return 1; @@ -2915,7 +2915,7 @@ static int activateZoneKey(vector& cmds, const std::string_view synopsis if(cmds.size() != 3) { return usage(synopsis); } - DNSName zone(cmds.at(1)); + ZoneName zone(cmds.at(1)); // NOLINTNEXTLINE(readability-identifier-length) unsigned int id = atoi(cmds.at(2).c_str()); // if you make this pdns::checked_stoi, the error gets worse if(id == 0) @@ -2942,7 +2942,7 @@ static int deactivateZoneKey(vector& cmds, const std::string_view synops if(cmds.size() != 3) { return usage(synopsis); } - DNSName zone(cmds.at(1)); + ZoneName zone(cmds.at(1)); auto id = pdns::checked_stoi(cmds.at(2)); // NOLINT(readability-identifier-length) if(id == 0) { @@ -2968,7 +2968,7 @@ static int publishZoneKey(vector& cmds, const std::string_view synopsis) if(cmds.size() != 3) { return usage(synopsis); } - DNSName zone(cmds.at(1)); + ZoneName zone(cmds.at(1)); // NOLINTNEXTLINE(readability-identifier-length) unsigned int id = atoi(cmds.at(2).c_str()); // if you make this pdns::checked_stoi, the error gets worse if(id == 0) @@ -2995,7 +2995,7 @@ static int unpublishZoneKey(vector& cmds, const std::string_view synopsi if(cmds.size() != 3) { return usage(synopsis); } - DNSName zone(cmds.at(1)); + ZoneName zone(cmds.at(1)); // NOLINTNEXTLINE(readability-identifier-length) unsigned int id = atoi(cmds.at(2).c_str()); // if you make this pdns::checked_stoi, the error gets worse if(id == 0) @@ -3017,7 +3017,7 @@ static int unpublishZoneKey(vector& cmds, const std::string_view synopsi return 0; } -static int checkZoneKey(DNSSECKeeper &dsk, DNSName &zone, int64_t keyId) +static int checkZoneKey(DNSSECKeeper &dsk, ZoneName &zone, int64_t keyId) { if (keyId == -1) { cerr<& cmds, const std::string_view synopsis) return usage(synopsis); } DNSSECKeeper dk; //NOLINT(readability-identifier-length) - DNSName zone(cmds.at(1)); + ZoneName zone(cmds.at(1)); UtilBackend B("default"); //NOLINT(readability-identifier-length) DomainInfo di; //NOLINT(readability-identifier-length) @@ -3148,7 +3148,7 @@ static int removeZoneKey(vector& cmds, const std::string_view synopsis) return usage(synopsis); } DNSSECKeeper dk; //NOLINT(readability-identifier-length) - DNSName zone(cmds.at(1)); + ZoneName zone(cmds.at(1)); auto id = pdns::checked_stoi(cmds.at(2)); // NOLINT(readability-identifier-length) if (!dk.removeKey(zone, id)) { cerr<<"Cannot remove key " << id << " from " << zone <& cmds, const std::string_view synopsis) if(cmds.size() != 2) { return usage(synopsis); } - return deleteZone(DNSName(cmds.at(1))); + return deleteZone(ZoneName(cmds.at(1))); } static int createZone(vector& cmds, const std::string_view synopsis) @@ -3170,7 +3170,7 @@ static int createZone(vector& cmds, const std::string_view synopsis) if(cmds.size() != 2 && cmds.size()!=3 ) { return usage(synopsis); } - return createZone(DNSName(cmds.at(1)), cmds.size() > 2 ? DNSName(cmds.at(2)) : DNSName()); + return createZone(ZoneName(cmds.at(1)), cmds.size() > 2 ? DNSName(cmds.at(2)) : DNSName()); } static int createSecondaryZone(vector& cmds, const std::string_view synopsis) @@ -3180,7 +3180,7 @@ static int createSecondaryZone(vector& cmds, const std::string_view syno } UtilBackend B; // NOLINT(readability-identifier-length) DomainInfo di; // NOLINT(readability-identifier-length) - DNSName zone(cmds.at(1)); + ZoneName zone(cmds.at(1)); if (B.getDomainInfo(zone, di)) { cerr << "Zone '" << zone << "' exists already" << endl; return EXIT_FAILURE; @@ -3210,7 +3210,7 @@ static int changeSecondaryZonePrimary(vector& cmds, const std::string_vi } UtilBackend B; // NOLINT(readability-identifier-length) DomainInfo di; // NOLINT(readability-identifier-length) - DNSName zone(cmds.at(1)); + ZoneName zone(cmds.at(1)); if (!B.getDomainInfo(zone, di)) { cerr << "Zone '" << zone << "' doesn't exist" << endl; return EXIT_FAILURE; @@ -3284,7 +3284,7 @@ static int listZone(vector& cmds, const std::string_view synopsis) cmds.at(1).clear(); } - return listZone(DNSName(cmds.at(1))); + return listZone(ZoneName(cmds.at(1))); } static int editZone(vector& cmds, const std::string_view synopsis) @@ -3297,7 +3297,7 @@ static int editZone(vector& cmds, const std::string_view synopsis) } PDNSColors col(g_vm.count("no-colors") != 0); - return editZone(DNSName(cmds.at(1)), col); + return editZone(ZoneName(cmds.at(1)), col); } static int clearZone(vector& cmds, const std::string_view synopsis) @@ -3309,7 +3309,7 @@ static int clearZone(vector& cmds, const std::string_view synopsis) cmds.at(1).clear(); } - return clearZone(DNSName(cmds.at(1))); + return clearZone(ZoneName(cmds.at(1))); } static int listKeys(vector& cmds, const std::string_view synopsis) @@ -3335,7 +3335,7 @@ static int loadZone(vector& cmds, const std::string_view synopsis) } for(size_t n=1; n + 2 <= cmds.size(); n+=2) { // NOLINT(readability-identifier-length) - int ret = loadZone(DNSName(cmds.at(n)), cmds.at(n + 1)); + int ret = loadZone(ZoneName(cmds.at(n)), cmds.at(n + 1)); if (ret != 0) { return ret; } @@ -3349,10 +3349,10 @@ static int secureZone(vector& cmds, const std::string_view synopsis) return usage(synopsis); } DNSSECKeeper dk; //NOLINT(readability-identifier-length) - vector mustRectify; + vector mustRectify; unsigned int zoneErrors=0; for(unsigned int n = 1; n < cmds.size(); ++n) { // NOLINT(readability-identifier-length) - DNSName zone(cmds.at(n)); + ZoneName zone(cmds.at(n)); dk.startTransaction(zone, -1); if(secureZone(dk, zone)) { mustRectify.push_back(std::move(zone)); @@ -3416,7 +3416,7 @@ static int setKind(vector& cmds, const std::string_view synopsis) if(cmds.size() != 3) { return usage(synopsis); } - DNSName zone(cmds.at(1)); + ZoneName zone(cmds.at(1)); auto kind = DomainInfo::stringToKind(cmds.at(2)); return setZoneKind(zone, kind); } @@ -3437,7 +3437,7 @@ static int setOptionsJson(vector& cmds, const std::string_view synopsis) } } - DNSName zone(cmds.at(1)); + ZoneName zone(cmds.at(1)); return setZoneOptionsJson(zone, cmds.at(2)); } @@ -3451,7 +3451,7 @@ static int setOption(vector& cmds, const std::string_view synopsis) return usage(synopsis); } - DNSName zone(cmds.at(1)); + ZoneName zone(cmds.at(1)); set values; for (unsigned int n = 4; n < cmds.size(); ++n) { // NOLINT(readability-identifier-length) if (!cmds.at(n).empty()) { @@ -3467,10 +3467,10 @@ static int setCatalog(vector& cmds, const std::string_view synopsis) if (cmds.size() < 2) { return usage(synopsis); } - DNSName zone(cmds.at(1)); - DNSName catalog; // Create an empty DNSName() + ZoneName zone(cmds.at(1)); + ZoneName catalog; // Create an empty ZoneName() if (cmds.size() > 2 && !cmds.at(2).empty()) { - catalog = DNSName(cmds.at(2)); + catalog = ZoneName(cmds.at(2)); } return setZoneCatalog(zone, catalog); } @@ -3480,7 +3480,7 @@ static int setAccount(vector& cmds, const std::string_view synopsis) if(cmds.size() != 3) { return usage(synopsis); } - DNSName zone(cmds.at(1)); + ZoneName zone(cmds.at(1)); return setZoneAccount(zone, cmds.at(2)); } @@ -3494,7 +3494,7 @@ static int setNsec3(vector& cmds, const std::string_view synopsis) NSEC3PARAMRecordContent ns3pr(nsec3params); DNSSECKeeper dk; //NOLINT(readability-identifier-length) - DNSName zone(cmds.at(1)); + ZoneName zone(cmds.at(1)); if (zone.wirelength() > 222) { cerr<<"Cannot enable NSEC3 for " << zone << " as it is too long (" << zone.wirelength() << " bytes, maximum is 222 bytes)"<& cmds, const std::string_view synopsis) return usage(synopsis); } DNSSECKeeper dk; //NOLINT(readability-identifier-length) - if (!dk.setPresigned(DNSName(cmds.at(1)))) { + if (!dk.setPresigned(ZoneName(cmds.at(1)))) { cerr << "Could not set presigned for " << cmds.at(1) << " (is DNSSEC enabled in your backend?)" << endl; return 1; } @@ -3544,7 +3544,7 @@ static int setPublishCDNSKey(vector& cmds, const std::string_view synops return usage(synopsis); } DNSSECKeeper dk; //NOLINT(readability-identifier-length) - if (!dk.setPublishCDNSKEY(DNSName(cmds.at(1)), (cmds.size() == 3 && cmds.at(2) == "delete"))) { + if (!dk.setPublishCDNSKEY(ZoneName(cmds.at(1)), (cmds.size() == 3 && cmds.at(2) == "delete"))) { cerr << "Could not set publishing for CDNSKEY records for " << cmds.at(1) << endl; return 1; } @@ -3563,7 +3563,7 @@ static int setPublishCDs(vector& cmds, const std::string_view synopsis) } DNSSECKeeper dk; //NOLINT(readability-identifier-length) - if (!dk.setPublishCDS(DNSName(cmds.at(1)), cmds.at(2))) { + if (!dk.setPublishCDS(ZoneName(cmds.at(1)), cmds.at(2))) { cerr << "Could not set publishing for CDS records for " << cmds.at(1) << endl; return 1; } @@ -3576,7 +3576,7 @@ static int unsetPresigned(vector& cmds, const std::string_view synopsis) return usage(synopsis); } DNSSECKeeper dk; //NOLINT(readability-identifier-length) - if (!dk.unsetPresigned(DNSName(cmds.at(1)))) { + if (!dk.unsetPresigned(ZoneName(cmds.at(1)))) { cerr << "Could not unset presigned on for " << cmds.at(1) << endl; return 1; } @@ -3589,7 +3589,7 @@ static int unsetPublishCDNSKey(vector& cmds, const std::string_view syno return usage(synopsis); } DNSSECKeeper dk; //NOLINT(readability-identifier-length) - if (!dk.unsetPublishCDNSKEY(DNSName(cmds.at(1)))) { + if (!dk.unsetPublishCDNSKEY(ZoneName(cmds.at(1)))) { cerr << "Could not unset publishing for CDNSKEY records for " << cmds.at(1) << endl; return 1; } @@ -3602,7 +3602,7 @@ static int unsetPublishCDs(vector& cmds, const std::string_view synopsis return usage(synopsis); } DNSSECKeeper dk; //NOLINT(readability-identifier-length) - if (!dk.unsetPublishCDS(DNSName(cmds.at(1)))) { + if (!dk.unsetPublishCDS(ZoneName(cmds.at(1)))) { cerr << "Could not unset publishing for CDS records for " << cmds.at(1) << endl; return 1; } @@ -3615,7 +3615,7 @@ static int hashZoneRecord(vector& cmds, const std::string_view synopsis) return usage(synopsis); } DNSSECKeeper dk; //NOLINT(readability-identifier-length) - DNSName zone(cmds.at(1)); + ZoneName zone(cmds.at(1)); DNSName record(cmds.at(2)); NSEC3PARAMRecordContent ns3pr; bool narrow = false; @@ -3637,7 +3637,7 @@ static int unsetNSec3(vector& cmds, const std::string_view synopsis) return usage(synopsis); } DNSSECKeeper dk; //NOLINT(readability-identifier-length) - if (!dk.unsetNSEC3PARAM(DNSName(cmds.at(1)))) { + if (!dk.unsetNSEC3PARAM(ZoneName(cmds.at(1)))) { cerr << "Cannot unset NSEC3 param for " << cmds.at(1) << endl; return 1; } @@ -3655,7 +3655,7 @@ static int exportZoneKey(vector& cmds, const std::string_view synopsis) DNSSECKeeper dk; //NOLINT(readability-identifier-length) string zone = cmds.at(1); auto id = pdns::checked_stoi(cmds.at(2)); // NOLINT(readability-identifier-length) - DNSSECPrivateKey dpk = dk.getKeyById(DNSName(zone), id); + DNSSECPrivateKey dpk = dk.getKeyById(ZoneName(zone), id); cout << dpk.getKey()->convertToISC() << endl; return 0; } @@ -3669,7 +3669,7 @@ static int exportZoneKeyPEM(vector& cmds, const std::string_view synopsi DNSSECKeeper dk; //NOLINT(readability-identifier-length) string zone = cmds.at(1); auto id = pdns::checked_stoi(cmds.at(2)); // NOLINT(readability-identifier-length) - DNSSECPrivateKey dpk = dk.getKeyById(DNSName(zone), id); + DNSSECPrivateKey dpk = dk.getKeyById(ZoneName(zone), id); dpk.getKey()->convertToPEMFile(*stdout); return 0; } @@ -3680,7 +3680,7 @@ static int increaseSerial(vector& cmds, const std::string_view synopsis) return usage(synopsis); } DNSSECKeeper dk; //NOLINT(readability-identifier-length) - return increaseSerial(DNSName(cmds.at(1)), dk); + return increaseSerial(ZoneName(cmds.at(1)), dk); } static int importZoneKeyPEM(vector& cmds, const std::string_view synopsis) @@ -3689,7 +3689,7 @@ static int importZoneKeyPEM(vector& cmds, const std::string_view synopsi return usage(synopsis); } - DNSName zone(cmds.at(1)); + ZoneName zone(cmds.at(1)); const string filename = cmds.at(2); const auto algorithm = pdns::checked_stoi(cmds.at(3)); @@ -3749,7 +3749,7 @@ static int importZoneKey(vector& cmds, const std::string_view synopsis) if(cmds.size() < 3) { return usage(synopsis); } - DNSName zone(cmds.at(1)); + ZoneName zone(cmds.at(1)); string fname = cmds.at(2); DNSKEYRecordContent drc; shared_ptr key(DNSCryptoKeyEngine::makeFromISCFile(drc, fname.c_str())); @@ -3806,7 +3806,7 @@ static int exportZoneDNSKey(vector& cmds, const std::string_view synopsi } DNSSECKeeper dk; //NOLINT(readability-identifier-length) - DNSName zone(cmds.at(1)); + ZoneName zone(cmds.at(1)); auto id = pdns::checked_stoi(cmds.at(2)); // NOLINT(readability-identifier-length) DNSSECPrivateKey dpk=dk.getKeyById(zone, id); cout << zone<<" IN DNSKEY "<& cmds, const std::string_view synopsis if (cmds.size() < 4) { return usage(synopsis); } - DNSName zname(cmds.at(1)); + ZoneName zname(cmds.at(1)); string name = cmds.at(2); if (cmds.at(3) == "primary" || cmds.at(3) == "producer") { metaKey = "TSIG-ALLOW-AXFR"; @@ -4005,7 +4005,7 @@ static int deactivateTSIGKey(vector& cmds, const std::string_view synops if (cmds.size() < 4) { return usage(synopsis); } - DNSName zname(cmds.at(1)); + ZoneName zname(cmds.at(1)); string name = cmds.at(2); if (cmds.at(3) == "primary" || cmds.at(3) == "producer") { metaKey = "TSIG-ALLOW-AXFR"; @@ -4053,7 +4053,7 @@ static int getMeta(vector& cmds, const std::string_view synopsis) return usage(synopsis); } UtilBackend B("default"); // NOLINT(readability-identifier-length) - DNSName zone(cmds.at(1)); + ZoneName zone(cmds.at(1)); vector keys; DomainInfo di; // NOLINT(readability-identifier-length) @@ -4088,7 +4088,7 @@ static int setMeta(vector& cmds, const std::string_view synopsis) if (cmds.size() < 3) { return usage(synopsis); } - DNSName zone(cmds.at(1)); + ZoneName zone(cmds.at(1)); string kind = cmds.at(2); const static std::array multiMetaWhitelist = {"ALLOW-AXFR-FROM", "ALLOW-DNSUPDATE-FROM", "ALSO-NOTIFY", "TSIG-ALLOW-AXFR", "TSIG-ALLOW-DNSUPDATE", "GSS-ALLOW-AXFR-PRINCIPAL", @@ -4118,7 +4118,7 @@ static int HSMAssign(vector& cmds, const std::string_view synopsis) } UtilBackend B("default"); // NOLINT(readability-identifier-length) - DNSName zone(cmds.at(2)); + ZoneName zone(cmds.at(2)); // verify zone if (!B.getDomainInfo(zone, di)) { @@ -4199,7 +4199,7 @@ static int HSMCreateKey(vector& cmds, const std::string_view synopsis) } UtilBackend B("default"); // NOLINT(readability-identifier-length) DomainInfo di; // NOLINT(readability-identifier-length) - DNSName zone(cmds.at(2)); + ZoneName zone(cmds.at(2)); unsigned int id{0}; // NOLINT(readability-identifier-length) int bits = 2048; // verify zone diff --git a/pdns/rcpgenerator.cc b/pdns/rcpgenerator.cc index db5e48933c..9a4c240000 100644 --- a/pdns/rcpgenerator.cc +++ b/pdns/rcpgenerator.cc @@ -36,7 +36,7 @@ #include "base64.hh" #include "namespaces.hh" -RecordTextReader::RecordTextReader(string str, DNSName zone) : +RecordTextReader::RecordTextReader(string str, ZoneName zone) : d_string(std::move(str)), d_zone(std::move(zone)) { /* remove whitespace */ diff --git a/pdns/rcpgenerator.hh b/pdns/rcpgenerator.hh index 914a353aa8..87880008c4 100644 --- a/pdns/rcpgenerator.hh +++ b/pdns/rcpgenerator.hh @@ -40,7 +40,7 @@ public: class RecordTextReader { public: - RecordTextReader(string str, DNSName zone=DNSName("")); + RecordTextReader(string str, ZoneName zone=ZoneName("")); void xfrNodeOrLocatorID(NodeOrLocatorID& val); void xfr64BitInt(uint64_t& val); void xfr48BitInt(uint64_t& val); @@ -76,7 +76,7 @@ public: bool eof(); private: string d_string; - DNSName d_zone; + ZoneName d_zone; string::size_type d_pos{0}; string::size_type d_end; void skipSpaces(); diff --git a/pdns/serialtweaker.cc b/pdns/serialtweaker.cc index 771c308895..4bba4ea5d3 100644 --- a/pdns/serialtweaker.cc +++ b/pdns/serialtweaker.cc @@ -38,7 +38,7 @@ uint32_t localtime_format_YYYYMMDDSS(time_t t, uint32_t seq) + seq; } -uint32_t calculateEditSOA(uint32_t old_serial, const string& kind, const DNSName& zonename) +uint32_t calculateEditSOA(uint32_t old_serial, const string& kind, const ZoneName& zonename) { if(pdns_iequals(kind,"INCEPTION-INCREMENT")) { time_t inception = getStartOfWeek(); @@ -79,14 +79,14 @@ uint32_t calculateEditSOA(uint32_t old_serial, const string& kind, const DNSName return old_serial; } -uint32_t calculateEditSOA(uint32_t old_serial, DNSSECKeeper& dk, const DNSName& zonename) { +uint32_t calculateEditSOA(uint32_t old_serial, DNSSECKeeper& dk, const ZoneName& zonename) { string kind; dk.getSoaEdit(zonename, kind); return calculateEditSOA(old_serial, kind, zonename); } /** Used for SOA-EDIT-DNSUPDATE and SOA-EDIT-API. */ -static uint32_t calculateIncreaseSOA(uint32_t old_serial, const string& increaseKind, const string& editKind, const DNSName& zonename) { +static uint32_t calculateIncreaseSOA(uint32_t old_serial, const string& increaseKind, const string& editKind, const ZoneName& zonename) { if (pdns_iequals(increaseKind, "SOA-EDIT-INCREASE")) { uint32_t new_serial = old_serial; if (!editKind.empty()) { diff --git a/pdns/signingpipe.cc b/pdns/signingpipe.cc index f2464c11b0..5d081532d9 100644 --- a/pdns/signingpipe.cc +++ b/pdns/signingpipe.cc @@ -59,7 +59,7 @@ catch(...) { return nullptr; } -ChunkedSigningPipe::ChunkedSigningPipe(DNSName signerName, bool mustSign, unsigned int workers, unsigned int maxChunkRecords) : +ChunkedSigningPipe::ChunkedSigningPipe(ZoneName signerName, bool mustSign, unsigned int workers, unsigned int maxChunkRecords) : d_signed(0), d_numworkers(workers), d_signer(std::move(signerName)), d_maxchunkrecords(maxChunkRecords), d_threads(d_numworkers), d_mustSign(mustSign) { d_rrsetToSign = make_unique(); @@ -287,7 +287,7 @@ try if(res < 0) unixDie("reading object pointer to sign from pdns"); try { - set authSet; + set authSet; authSet.insert(d_signer); addRRSigs(dk, db, authSet, *chunk); ++d_signed; diff --git a/pdns/signingpipe.hh b/pdns/signingpipe.hh index d76ebda730..47403be98a 100644 --- a/pdns/signingpipe.hh +++ b/pdns/signingpipe.hh @@ -42,7 +42,7 @@ public: ChunkedSigningPipe(const ChunkedSigningPipe&) = delete; void operator=(const ChunkedSigningPipe&) = delete; - ChunkedSigningPipe(DNSName signerName, bool mustSign, unsigned int numWorkers, unsigned int maxChunkRecords); + ChunkedSigningPipe(ZoneName signerName, bool mustSign, unsigned int numWorkers, unsigned int maxChunkRecords); ~ChunkedSigningPipe(); bool submit(const DNSZoneRecord& rr); chunk_t getChunk(bool final=false); @@ -67,7 +67,7 @@ private: std::unique_ptr d_rrsetToSign; std::deque< std::vector > d_chunks; - DNSName d_signer; + ZoneName d_signer; chunk_t::size_type d_maxchunkrecords; diff --git a/pdns/tcpreceiver.cc b/pdns/tcpreceiver.cc index d8cb2cad97..f507f7c337 100644 --- a/pdns/tcpreceiver.cc +++ b/pdns/tcpreceiver.cc @@ -688,7 +688,7 @@ int TCPNameserver::doAXFR(const DNSName &target, std::unique_ptr& q, DNSZoneRecord soa = makeEditedDNSZRFromSOAData(dk, sd); outpacket->addRecord(DNSZoneRecord(soa)); if(securedZone && !presignedZone) { - set authSet; + set authSet; authSet.insert(target); addRRSigs(dk, db, authSet, outpacket->getRRS()); } @@ -1261,7 +1261,7 @@ int TCPNameserver::doIXFR(std::unique_ptr& q, int outsock) } if (serialPermitsIXFR) { - DNSName target = q->qdomain; + ZoneName target = q->qdomain; TSIGRecordContent trc; DNSName tsigkeyname; string tsigsecret; @@ -1291,7 +1291,7 @@ int TCPNameserver::doIXFR(std::unique_ptr& q, int outsock) DNSZoneRecord soa = makeEditedDNSZRFromSOAData(dk, sd); outpacket->addRecord(std::move(soa)); if(securedZone && outpacket->d_dnssecOk) { - set authSet; + set authSet; authSet.insert(target); addRRSigs(dk, db, authSet, outpacket->getRRS()); } diff --git a/pdns/test-auth-zonecache_cc.cc b/pdns/test-auth-zonecache_cc.cc index 692a491750..8466892c7c 100644 --- a/pdns/test-auth-zonecache_cc.cc +++ b/pdns/test-auth-zonecache_cc.cc @@ -42,14 +42,14 @@ BOOST_AUTO_TEST_CASE(test_replace) AuthZoneCache cache; cache.setRefreshInterval(3600); - vector> zone_indices{ - {DNSName("example.org."), 1}, + vector> zone_indices{ + {ZoneName("example.org."), 1}, }; cache.setReplacePending(); cache.replace(zone_indices); int zoneId = 0; - bool found = cache.getEntry(DNSName("example.org."), zoneId); + bool found = cache.getEntry(ZoneName("example.org."), zoneId); if (!found || zoneId != 1) { BOOST_FAIL("zone added in replace() not found"); } @@ -60,14 +60,14 @@ BOOST_AUTO_TEST_CASE(test_add_while_pending_replace) AuthZoneCache cache; cache.setRefreshInterval(3600); - vector> zone_indices{ - {DNSName("powerdns.org."), 1}}; + vector> zone_indices{ + {ZoneName("powerdns.org."), 1}}; cache.setReplacePending(); - cache.add(DNSName("example.org."), 2); + cache.add(ZoneName("example.org."), 2); cache.replace(zone_indices); int zoneId = 0; - bool found = cache.getEntry(DNSName("example.org."), zoneId); + bool found = cache.getEntry(ZoneName("example.org."), zoneId); if (!found || zoneId != 2) { BOOST_FAIL("zone added while replace was pending not found"); } @@ -78,14 +78,14 @@ BOOST_AUTO_TEST_CASE(test_remove_while_pending_replace) AuthZoneCache cache; cache.setRefreshInterval(3600); - vector> zone_indices{ - {DNSName("powerdns.org."), 1}}; + vector> zone_indices{ + {ZoneName("powerdns.org."), 1}}; cache.setReplacePending(); - cache.remove(DNSName("powerdns.org.")); + cache.remove(ZoneName("powerdns.org.")); cache.replace(zone_indices); int zoneId = 0; - bool found = cache.getEntry(DNSName("example.org."), zoneId); + bool found = cache.getEntry(ZoneName("example.org."), zoneId); if (found) { BOOST_FAIL("zone removed while replace was pending is found"); } @@ -97,16 +97,16 @@ BOOST_AUTO_TEST_CASE(test_add_while_pending_replace_duplicate) AuthZoneCache cache; cache.setRefreshInterval(3600); - vector> zone_indices{ - {DNSName("powerdns.org."), 1}, - {DNSName("example.org."), 2}, + vector> zone_indices{ + {ZoneName("powerdns.org."), 1}, + {ZoneName("example.org."), 2}, }; cache.setReplacePending(); - cache.add(DNSName("example.org."), 3); + cache.add(ZoneName("example.org."), 3); cache.replace(zone_indices); int zoneId = 0; - bool found = cache.getEntry(DNSName("example.org."), zoneId); + bool found = cache.getEntry(ZoneName("example.org."), zoneId); if (!found || zoneId == 0) { BOOST_FAIL("zone added while replace was pending not found"); } diff --git a/pdns/test-bindparser_cc.cc b/pdns/test-bindparser_cc.cc index ff37fcf117..e7d98330ee 100644 --- a/pdns/test-bindparser_cc.cc +++ b/pdns/test-bindparser_cc.cc @@ -41,7 +41,7 @@ BOOST_AUTO_TEST_CASE(test_parser) #define checkzone(i, dname, fname, ztype, nprimaries) \ { \ - BOOST_CHECK(domains[i].name == DNSName(dname)); \ + BOOST_CHECK(domains[i].name == ZoneName(dname)); \ BOOST_CHECK_EQUAL(domains[i].filename, fname); \ BOOST_CHECK_EQUAL(domains[i].type, #ztype); \ BOOST_CHECK_EQUAL(domains[i].primaries.size(), nprimaries); \ diff --git a/pdns/test-communicator_hh.cc b/pdns/test-communicator_hh.cc index 9d389bcf3b..aca5a47d5c 100644 --- a/pdns/test-communicator_hh.cc +++ b/pdns/test-communicator_hh.cc @@ -16,11 +16,11 @@ BOOST_AUTO_TEST_SUITE(test_communicator_hh) BOOST_AUTO_TEST_CASE(test_axfr_queue_priority_order) { SuckRequest sr[5] = { - {DNSName("test1.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::SignaturesRefresh, 0}}, - {DNSName("test2.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::SerialRefresh, 1}}, - {DNSName("test3.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Notify, 2}}, - {DNSName("test4.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 3}}, - {DNSName("test5.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::PdnsControl, 4}}, + {ZoneName("test1.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::SignaturesRefresh, 0}}, + {ZoneName("test2.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::SerialRefresh, 1}}, + {ZoneName("test3.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Notify, 2}}, + {ZoneName("test4.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 3}}, + {ZoneName("test5.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::PdnsControl, 4}}, }; UniQueue suckDomains; @@ -42,11 +42,11 @@ BOOST_AUTO_TEST_CASE(test_axfr_queue_priority_order) BOOST_AUTO_TEST_CASE(test_axfr_queue_insert_and_priority_order) { SuckRequest sr[5] = { - {DNSName("test1.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 2}}, - {DNSName("test2.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 1}}, - {DNSName("test3.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 0}}, - {DNSName("test4.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::PdnsControl, 4}}, - {DNSName("test5.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::PdnsControl, 3}}, + {ZoneName("test1.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 2}}, + {ZoneName("test2.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 1}}, + {ZoneName("test3.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 0}}, + {ZoneName("test4.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::PdnsControl, 4}}, + {ZoneName("test5.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::PdnsControl, 3}}, }; UniQueue suckDomains; @@ -68,14 +68,14 @@ BOOST_AUTO_TEST_CASE(test_axfr_queue_insert_and_priority_order) BOOST_AUTO_TEST_CASE(test_axfr_queue_insert_and_priority_order_after_modify) { SuckRequest sr[5] = { - {DNSName("test1.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 1}}, - {DNSName("test2.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 0}}, - {DNSName("test3.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 2}}, - {DNSName("test4.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::PdnsControl, 4}}, - {DNSName("test5.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::PdnsControl, 3}}, + {ZoneName("test1.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 1}}, + {ZoneName("test2.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 0}}, + {ZoneName("test3.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 2}}, + {ZoneName("test4.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::PdnsControl, 4}}, + {ZoneName("test5.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::PdnsControl, 3}}, }; - SuckRequest rr = {DNSName("test3.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::PdnsControl, 5}}; - SuckRequest rr2 = {DNSName("test4.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 6}}; + SuckRequest rr = {ZoneName("test3.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::PdnsControl, 5}}; + SuckRequest rr2 = {ZoneName("test4.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 6}}; UniQueue suckDomains; diff --git a/pdns/test-ueberbackend_cc.cc b/pdns/test-ueberbackend_cc.cc index 2627e58f30..ae94432f98 100644 --- a/pdns/test-ueberbackend_cc.cc +++ b/pdns/test-ueberbackend_cc.cc @@ -55,11 +55,11 @@ public: struct SimpleDNSZone { - SimpleDNSZone(const DNSName& name, uint64_t id): d_records(std::make_shared()), d_name(name), d_id(id) + SimpleDNSZone(const ZoneName& name, uint64_t id): d_records(std::make_shared()), d_name(name), d_id(id) { } std::shared_ptr d_records; - DNSName d_name; + ZoneName d_name; uint64_t d_id; }; @@ -70,17 +70,17 @@ public: SimpleDNSZone, indexed_by < ordered_unique, member >, - hashed_unique, member > + hashed_unique, member > > > ZoneStorage; struct SimpleMetaData { - SimpleMetaData(const DNSName& name, const std::string& kind, const std::vector& values): d_name(name), d_kind(kind), d_values(values) + SimpleMetaData(const ZoneName& name, const std::string& kind, const std::vector& values): d_name(name), d_kind(kind), d_values(values) { } - DNSName d_name; + ZoneName d_name; std::string d_kind; std::vector d_values; }; @@ -93,10 +93,10 @@ public: ordered_unique, composite_key< SimpleMetaData, - member, + member, member >, - composite_key_compare > + composite_key_compare > > > > MetaDataStorage; @@ -109,7 +109,7 @@ public: unsigned int getCapabilities() override { return CAP_LIST; } - bool findZone(const DNSName& qdomain, int zoneId, std::shared_ptr& records, uint64_t& currentZoneId) const + bool findZone(const ZoneName& qdomain, int zoneId, std::shared_ptr& records, uint64_t& currentZoneId) const { currentZoneId = -1; records.reset(); @@ -189,7 +189,7 @@ public: return true; } - bool list(const DNSName& target, int zoneId, bool /* include_disabled */ = false) override + bool list(const ZoneName& target, int zoneId, bool /* include_disabled */ = false) override { findZone(target, zoneId, d_records, d_currentZone); @@ -202,7 +202,7 @@ public: return false; } - bool getDomainMetadata(const DNSName& name, const std::string& kind, std::vector& meta) override + bool getDomainMetadata(const ZoneName& name, const std::string& kind, std::vector& meta) override { const auto& idx = boost::multi_index::get(s_metadata.at(d_backendId)); auto it = idx.find(std::tuple(name, kind)); @@ -215,7 +215,7 @@ public: return true; } - bool setDomainMetadata(const DNSName& name, const std::string& kind, const std::vector& meta) override + bool setDomainMetadata(const ZoneName& name, const std::string& kind, const std::vector& meta) override { auto& idx = boost::multi_index::get(s_metadata.at(d_backendId)); auto it = idx.find(std::tuple(name, kind)); @@ -248,9 +248,9 @@ public: { } - bool getAuth(const DNSName& target, SOAData* sd) override + bool getAuth(const ZoneName& target, SOAData* sd) override { - static const DNSName best("d.0.1.0.0.2.ip6.arpa."); + static const ZoneName best("d.0.1.0.0.2.ip6.arpa."); ++d_authLookupCount; @@ -288,12 +288,12 @@ public: { } - bool getDomainMetadata(const DNSName& /* name */, const std::string& /* kind */, std::vector& /* meta */) override + bool getDomainMetadata(const ZoneName& /* name */, const std::string& /* kind */, std::vector& /* meta */) override { return false; } - bool setDomainMetadata(const DNSName& /* name */, const std::string& /* kind */, const std::vector& /* meta */) override + bool setDomainMetadata(const ZoneName& /* name */, const std::string& /* kind */, const std::vector& /* meta */) override { return false; } @@ -462,7 +462,7 @@ static void checkRecordExists(const std::vector& records, const D BOOST_AUTO_TEST_CASE(test_simple) { try { - SimpleBackend::SimpleDNSZone zoneA(DNSName("powerdns.com."), 1); + SimpleBackend::SimpleDNSZone zoneA(ZoneName("powerdns.com."), 1); zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::SOA, "ns1.powerdns.com. powerdns.com. 3 600 600 3600000 604800", 3600)); zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::AAAA, "2001:db8::1", 60)); zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("www.powerdns.com."), QType::A, "192.168.0.1", 60)); @@ -568,14 +568,14 @@ BOOST_AUTO_TEST_CASE(test_multi_backends_separate_zones) { // no overlap try { - SimpleBackend::SimpleDNSZone zoneA(DNSName("powerdns.com."), 1); + SimpleBackend::SimpleDNSZone zoneA(ZoneName("powerdns.com."), 1); zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::SOA, "ns1.powerdns.com. powerdns.com. 3 600 600 3600000 604800", 3600)); zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::AAAA, "2001:db8::1", 60)); zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("www.powerdns.com."), QType::A, "192.168.0.1", 60)); zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("geo.powerdns.com."), QType::A, "192.168.0.42", 60)); SimpleBackend::s_zones[1].insert(zoneA); - SimpleBackend::SimpleDNSZone zoneB(DNSName("powerdns.org."), 2); + SimpleBackend::SimpleDNSZone zoneB(ZoneName("powerdns.org."), 2); zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.org."), QType::SOA, "ns1.powerdns.org. powerdns.org. 3 600 600 3600000 604800", 3600)); zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.org."), QType::AAAA, "2001:db8::2", 60)); zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("www.powerdns.org."), QType::AAAA, "2001:db8::2", 60)); @@ -714,13 +714,13 @@ BOOST_AUTO_TEST_CASE(test_multi_backends_overlay) { // one backend holds the SOA, NS and one A // a second backend holds another A and AAAA try { - SimpleBackend::SimpleDNSZone zoneA(DNSName("powerdns.com."), 1); + SimpleBackend::SimpleDNSZone zoneA(ZoneName("powerdns.com."), 1); zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::SOA, "ns1.powerdns.com. powerdns.com. 3 600 600 3600000 604800", 3600)); zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::NS, "ns1.powerdns.com.", 3600)); zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::A, "192.168.0.1", 60)); SimpleBackend::s_zones[1].insert(zoneA); - SimpleBackend::SimpleDNSZone zoneB(DNSName("powerdns.com."), 1); + SimpleBackend::SimpleDNSZone zoneB(ZoneName("powerdns.com."), 1); zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::A, "192.168.0.2", 60)); zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::AAAA, "2001:db8::1", 60)); zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("www.powerdns.com."), QType::A, "192.168.0.1", 60)); @@ -840,7 +840,7 @@ BOOST_AUTO_TEST_CASE(test_multi_backends_overlay_name) { // one backend holds the apex with SOA, NS and one A // a second backend holds others names try { - SimpleBackend::SimpleDNSZone zoneA(DNSName("powerdns.com."), 1); + SimpleBackend::SimpleDNSZone zoneA(ZoneName("powerdns.com."), 1); zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::SOA, "ns1.powerdns.com. powerdns.com. 3 600 600 3600000 604800", 3600)); zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::NS, "ns1.powerdns.com.", 3600)); zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::A, "192.168.0.1", 60)); @@ -848,7 +848,7 @@ BOOST_AUTO_TEST_CASE(test_multi_backends_overlay_name) { zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::AAAA, "2001:db8::1", 60)); SimpleBackend::s_zones[1].insert(zoneA); - SimpleBackend::SimpleDNSZone zoneB(DNSName("powerdns.com."), 1); + SimpleBackend::SimpleDNSZone zoneB(ZoneName("powerdns.com."), 1); zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("www.powerdns.com."), QType::A, "192.168.0.1", 60)); zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("www.powerdns.com."), QType::AAAA, "192.168.0.1", 60)); zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("geo.powerdns.com."), QType::A, "192.168.0.42", 60)); @@ -964,14 +964,14 @@ BOOST_AUTO_TEST_CASE(test_child_zone) { // Check that DS queries are correctly handled try { - SimpleBackend::SimpleDNSZone zoneA(DNSName("com."), 1); + SimpleBackend::SimpleDNSZone zoneA(ZoneName("com."), 1); zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("com."), QType::SOA, "a.gtld-servers.net. nstld.verisign-grs.com. 3 600 600 3600000 604800", 3600)); zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::NS, "ns1.powerdns.com.", 3600)); zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::DS, "44030 8 3 7DD75AE1565051F9563CF8DF976AC99CDCA51E3463019C81BD2BB083 82F3854E", 3600)); zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("ns1.powerdns.com."), QType::A, "192.0.2.1", 3600)); SimpleBackend::s_zones[1].insert(zoneA); - SimpleBackend::SimpleDNSZone zoneB(DNSName("powerdns.com."), 2); + SimpleBackend::SimpleDNSZone zoneB(ZoneName("powerdns.com."), 2); zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::SOA, "ns1.powerdns.com. powerdns.com. 3 600 600 3600000 604800", 3600)); zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::AAAA, "2001:db8::2", 60)); zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::NS, "ns1.powerdns.com.", 3600)); @@ -1006,7 +1006,7 @@ BOOST_AUTO_TEST_CASE(test_child_zone) { { // test getAuth() for DS SOAData sd; - BOOST_REQUIRE(ub.getAuth(DNSName("powerdns.com."), QType::DS, &sd)); + BOOST_REQUIRE(ub.getAuth(ZoneName("powerdns.com."), QType::DS, &sd)); BOOST_CHECK_EQUAL(sd.qname.toString(), "com."); BOOST_CHECK_EQUAL(sd.domain_id, 1); } @@ -1014,7 +1014,7 @@ BOOST_AUTO_TEST_CASE(test_child_zone) { { // test getAuth() for A SOAData sd; - BOOST_REQUIRE(ub.getAuth(DNSName("powerdns.com."), QType::A, &sd)); + BOOST_REQUIRE(ub.getAuth(ZoneName("powerdns.com."), QType::A, &sd)); BOOST_CHECK_EQUAL(sd.qname.toString(), "powerdns.com."); BOOST_CHECK_EQUAL(sd.domain_id, 2); } @@ -1042,12 +1042,12 @@ BOOST_AUTO_TEST_CASE(test_multi_backends_best_soa) { // while the others do simple lookups try { - SimpleBackend::SimpleDNSZone zoneA(DNSName("d.0.1.0.0.2.ip6.arpa."), 1); + SimpleBackend::SimpleDNSZone zoneA(ZoneName("d.0.1.0.0.2.ip6.arpa."), 1); zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("d.0.1.0.0.2.ip6.arpa."), QType::SOA, "ns.apnic.net. read-txt-record-of-zone-first-dns-admin.apnic.net. 3005126844 7200 1800 604800 3600", 3600)); zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("2.4.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa."), QType::PTR, "a.reverse.", 3600)); SimpleBackend::s_zones[1].insert(zoneA); - SimpleBackend::SimpleDNSZone zoneB(DNSName("0.1.0.0.2.ip6.arpa."), 2); + SimpleBackend::SimpleDNSZone zoneB(ZoneName("0.1.0.0.2.ip6.arpa."), 2); zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("0.1.0.0.2.ip6.arpa."), QType::SOA, "ns.apnic.net. read-txt-record-of-zone-first-dns-admin.apnic.net. 3005126844 7200 1800 604800 3600", 3600)); SimpleBackend::s_zones[2].insert(zoneB); @@ -1066,7 +1066,7 @@ BOOST_AUTO_TEST_CASE(test_multi_backends_best_soa) { // test getAuth() SOAData sd; - BOOST_REQUIRE(ub.getAuth(DNSName("2.4.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa."), QType::PTR, &sd)); + BOOST_REQUIRE(ub.getAuth(ZoneName("2.4.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa."), QType::PTR, &sd)); BOOST_CHECK_EQUAL(sd.qname.toString(), "d.0.1.0.0.2.ip6.arpa."); BOOST_CHECK_EQUAL(sd.domain_id, 1); @@ -1098,21 +1098,21 @@ BOOST_AUTO_TEST_CASE(test_multi_backends_metadata) { // Updating will insert into the first backend, leaving the first one untouched try { - SimpleBackend::SimpleDNSZone zoneA(DNSName("powerdns.com."), 1); + SimpleBackend::SimpleDNSZone zoneA(ZoneName("powerdns.com."), 1); zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::SOA, "ns1.powerdns.com. powerdns.com. 3 600 600 3600000 604800", 3600)); zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::AAAA, "2001:db8::1", 60)); zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("www.powerdns.com."), QType::A, "192.168.0.1", 60)); zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("geo.powerdns.com."), QType::A, "192.168.0.42", 60)); SimpleBackend::s_zones[1].insert(zoneA); - SimpleBackend::s_metadata[1].insert(SimpleBackend::SimpleMetaData(DNSName("powerdns.com."), "test-data-a", { "value1", "value2"})); + SimpleBackend::s_metadata[1].insert(SimpleBackend::SimpleMetaData(ZoneName("powerdns.com."), "test-data-a", { "value1", "value2"})); - SimpleBackend::SimpleDNSZone zoneB(DNSName("powerdns.org."), 2); + SimpleBackend::SimpleDNSZone zoneB(ZoneName("powerdns.org."), 2); zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.org."), QType::SOA, "ns1.powerdns.org. powerdns.org. 3 600 600 3600000 604800", 3600)); zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.org."), QType::AAAA, "2001:db8::2", 60)); zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("www.powerdns.org."), QType::AAAA, "2001:db8::2", 60)); zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("geo.powerdns.org."), QType::AAAA, "2001:db8::42", 60)); SimpleBackend::s_zones[2].insert(zoneB); - SimpleBackend::s_metadata[2].insert(SimpleBackend::SimpleMetaData(DNSName("powerdns.org."), "test-data-b", { "value1", "value2"})); + SimpleBackend::s_metadata[2].insert(SimpleBackend::SimpleMetaData(ZoneName("powerdns.org."), "test-data-b", { "value1", "value2"})); BackendMakers().report(std::make_unique()); BackendMakers().launch("SimpleBackend:1, SimpleBackend:2"); @@ -1122,47 +1122,47 @@ BOOST_AUTO_TEST_CASE(test_multi_backends_metadata) { { // check the initial values std::vector values; - BOOST_CHECK(ub.getDomainMetadata(DNSName("powerdns.com."), "test-data-a", values)); + BOOST_CHECK(ub.getDomainMetadata(ZoneName("powerdns.com."), "test-data-a", values)); BOOST_REQUIRE_EQUAL(values.size(), 2U); BOOST_CHECK_EQUAL(values.at(0), "value1"); BOOST_CHECK_EQUAL(values.at(1), "value2"); values.clear(); - BOOST_CHECK(ub.getDomainMetadata(DNSName("powerdns.com."), "test-data-b", values)); + BOOST_CHECK(ub.getDomainMetadata(ZoneName("powerdns.com."), "test-data-b", values)); BOOST_CHECK_EQUAL(values.size(), 0U); values.clear(); - BOOST_CHECK(ub.getDomainMetadata(DNSName("powerdns.org."), "test-data-a", values)); + BOOST_CHECK(ub.getDomainMetadata(ZoneName("powerdns.org."), "test-data-a", values)); BOOST_CHECK_EQUAL(values.size(), 0U); values.clear(); - BOOST_CHECK(ub.getDomainMetadata(DNSName("powerdns.org."), "test-data-b", values)); + BOOST_CHECK(ub.getDomainMetadata(ZoneName("powerdns.org."), "test-data-b", values)); BOOST_CHECK_EQUAL(values.size(), 0U); } { // update the values - BOOST_CHECK(ub.setDomainMetadata(DNSName("powerdns.com."), "test-data-a", std::vector({"value3"}))); - BOOST_CHECK(ub.setDomainMetadata(DNSName("powerdns.org."), "test-data-a", std::vector({"value4"}))); - BOOST_CHECK(ub.setDomainMetadata(DNSName("powerdns.org."), "test-data-b", std::vector({"value5"}))); + BOOST_CHECK(ub.setDomainMetadata(ZoneName("powerdns.com."), "test-data-a", std::vector({"value3"}))); + BOOST_CHECK(ub.setDomainMetadata(ZoneName("powerdns.org."), "test-data-a", std::vector({"value4"}))); + BOOST_CHECK(ub.setDomainMetadata(ZoneName("powerdns.org."), "test-data-b", std::vector({"value5"}))); } // check the updated values { std::vector values; - BOOST_CHECK(ub.getDomainMetadata(DNSName("powerdns.com."), "test-data-a", values)); + BOOST_CHECK(ub.getDomainMetadata(ZoneName("powerdns.com."), "test-data-a", values)); BOOST_REQUIRE_EQUAL(values.size(), 1U); BOOST_CHECK_EQUAL(values.at(0), "value3"); values.clear(); - BOOST_CHECK(ub.getDomainMetadata(DNSName("powerdns.org."), "test-data-a", values)); + BOOST_CHECK(ub.getDomainMetadata(ZoneName("powerdns.org."), "test-data-a", values)); BOOST_REQUIRE_EQUAL(values.size(), 1U); BOOST_CHECK_EQUAL(values.at(0), "value4"); values.clear(); - BOOST_CHECK(ub.getDomainMetadata(DNSName("powerdns.org."), "test-data-b", values)); + BOOST_CHECK(ub.getDomainMetadata(ZoneName("powerdns.org."), "test-data-b", values)); BOOST_REQUIRE_EQUAL(values.size(), 1U); BOOST_CHECK_EQUAL(values.at(0), "value5"); } { // check that it has not been updated in the second backend - const auto& it = SimpleBackend::s_metadata[2].find(std::tuple(DNSName("powerdns.org."), "test-data-b")); + const auto& it = SimpleBackend::s_metadata[2].find(std::tuple(ZoneName("powerdns.org."), "test-data-b")); BOOST_REQUIRE(it != SimpleBackend::s_metadata[2].end()); BOOST_REQUIRE_EQUAL(it->d_values.size(), 2U); BOOST_CHECK_EQUAL(it->d_values.at(0), "value1"); diff --git a/pdns/test-zonemd_cc.cc b/pdns/test-zonemd_cc.cc index 3743dd17e7..0e1a6eff9b 100644 --- a/pdns/test-zonemd_cc.cc +++ b/pdns/test-zonemd_cc.cc @@ -17,7 +17,7 @@ static void testZoneMD(const std::string& zone, const std::string& file, bool ex if (!p) { p = "."; } - DNSName z(zone); + ZoneName z(zone); std::ostringstream pathbuf; pathbuf << p << "/../regression-tests/zones/" + file; ZoneParserTNG zpt(pathbuf.str(), z); diff --git a/pdns/test-zoneparser_tng_cc.cc b/pdns/test-zoneparser_tng_cc.cc index 8551ec27d2..6f9db38686 100644 --- a/pdns/test-zoneparser_tng_cc.cc +++ b/pdns/test-zoneparser_tng_cc.cc @@ -26,7 +26,7 @@ BOOST_AUTO_TEST_CASE(test_tng_record_types) { if(!p) p = "."; pathbuf << p << "/../regression-tests/zones/unit.test"; - ZoneParserTNG zp(pathbuf.str(), DNSName("unit.test")); + ZoneParserTNG zp(pathbuf.str(), ZoneName("unit.test")); DNSResourceRecord rr; ifstream ifs(pathbuf.str()); @@ -63,7 +63,7 @@ BOOST_AUTO_TEST_CASE(test_tng_record_generate) { { /* simple case */ - ZoneParserTNG zp(pathbuf.str(), DNSName("unit2.test")); + ZoneParserTNG zp(pathbuf.str(), ZoneName("unit2.test")); const vector expected = { "0.01.0003.000005.00000007.unit2.test.", @@ -98,7 +98,7 @@ BOOST_AUTO_TEST_CASE(test_tng_record_generate) { { /* GENERATE with a step of 2, and the template radix defaulting to 'd' */ - ZoneParserTNG zp(std::vector({"$GENERATE 0-4/2 $.${1,2,o}.${3,4}.${5,6,X}.${7,8,x} 86400 IN A 1.2.3.4"}), DNSName("unit2.test")); + ZoneParserTNG zp(std::vector({"$GENERATE 0-4/2 $.${1,2,o}.${3,4}.${5,6,X}.${7,8,x} 86400 IN A 1.2.3.4"}), ZoneName("unit2.test")); const vector expected = { "0.01.0003.000005.00000007.unit2.test.", @@ -123,7 +123,7 @@ BOOST_AUTO_TEST_CASE(test_tng_record_generate) { { /* GENERATE with a larger initial counter and a large stop */ - ZoneParserTNG zp(std::vector({"$GENERATE 4294967294-4294967295/2 $ 86400 IN A 1.2.3.4"}), DNSName("unit2.test")); + ZoneParserTNG zp(std::vector({"$GENERATE 4294967294-4294967295/2 $ 86400 IN A 1.2.3.4"}), ZoneName("unit2.test")); const vector expected = { "4294967294.unit2.test.", @@ -146,76 +146,76 @@ BOOST_AUTO_TEST_CASE(test_tng_record_generate) { { /* test invalid generate parameters: stop greater than start */ - ZoneParserTNG zp(std::vector({"$GENERATE 5-4 $.${1,2,o}.${3,4,d}.${5,6,X}.${7,8,x} 86400 IN A 1.2.3.4"}), DNSName("test")); + ZoneParserTNG zp(std::vector({"$GENERATE 5-4 $.${1,2,o}.${3,4,d}.${5,6,X}.${7,8,x} 86400 IN A 1.2.3.4"}), ZoneName("test")); DNSResourceRecord rr; BOOST_CHECK_THROW(zp.get(rr), std::exception); } { /* test invalid generate parameters: no stop */ - ZoneParserTNG zp(std::vector({"$GENERATE 5 $.${1,2,o}.${3,4,d}.${5,6,X}.${7,8,x} 86400 IN A 1.2.3.4"}), DNSName("test")); + ZoneParserTNG zp(std::vector({"$GENERATE 5 $.${1,2,o}.${3,4,d}.${5,6,X}.${7,8,x} 86400 IN A 1.2.3.4"}), ZoneName("test")); DNSResourceRecord rr; BOOST_CHECK_THROW(zp.get(rr), std::exception); } { /* test invalid generate parameters: invalid step */ - ZoneParserTNG zp(std::vector({"$GENERATE 0-4/0 $.${1,2,o}.${3,4,d}.${5,6,X}.${7,8,x} 86400 IN A 1.2.3.4"}), DNSName("test")); + ZoneParserTNG zp(std::vector({"$GENERATE 0-4/0 $.${1,2,o}.${3,4,d}.${5,6,X}.${7,8,x} 86400 IN A 1.2.3.4"}), ZoneName("test")); DNSResourceRecord rr; BOOST_CHECK_THROW(zp.get(rr), std::exception); } { /* test invalid generate parameters: negative counter */ - ZoneParserTNG zp(std::vector({"$GENERATE -1-4/1 $.${1,2,o}.${3,4,d}.${5,6,X}.${7,8,x} 86400 IN A 1.2.3.4"}), DNSName("test")); + ZoneParserTNG zp(std::vector({"$GENERATE -1-4/1 $.${1,2,o}.${3,4,d}.${5,6,X}.${7,8,x} 86400 IN A 1.2.3.4"}), ZoneName("test")); DNSResourceRecord rr; BOOST_CHECK_THROW(zp.get(rr), std::exception); } { /* test invalid generate parameters: counter out of bounds */ - ZoneParserTNG zp(std::vector({"$GENERATE 4294967296-4/1 $.${1,2,o}.${3,4,d}.${5,6,X}.${7,8,x} 86400 IN A 1.2.3.4"}), DNSName("test")); + ZoneParserTNG zp(std::vector({"$GENERATE 4294967296-4/1 $.${1,2,o}.${3,4,d}.${5,6,X}.${7,8,x} 86400 IN A 1.2.3.4"}), ZoneName("test")); DNSResourceRecord rr; BOOST_CHECK_THROW(zp.get(rr), std::exception); } { /* test invalid generate parameters: negative stop */ - ZoneParserTNG zp(std::vector({"$GENERATE 0--4/1 $.${1,2,o}.${3,4,d}.${5,6,X}.${7,8,x} 86400 IN A 1.2.3.4"}), DNSName("test")); + ZoneParserTNG zp(std::vector({"$GENERATE 0--4/1 $.${1,2,o}.${3,4,d}.${5,6,X}.${7,8,x} 86400 IN A 1.2.3.4"}), ZoneName("test")); DNSResourceRecord rr; BOOST_CHECK_THROW(zp.get(rr), std::exception); } { /* test invalid generate parameters: stop out of bounds */ - ZoneParserTNG zp(std::vector({"$GENERATE 0-4294967296/1 $.${1,2,o}.${3,4,d}.${5,6,X}.${7,8,x} 86400 IN A 1.2.3.4"}), DNSName("test")); + ZoneParserTNG zp(std::vector({"$GENERATE 0-4294967296/1 $.${1,2,o}.${3,4,d}.${5,6,X}.${7,8,x} 86400 IN A 1.2.3.4"}), ZoneName("test")); DNSResourceRecord rr; BOOST_CHECK_THROW(zp.get(rr), std::exception); } { /* test invalid generate parameters: negative step */ - ZoneParserTNG zp(std::vector({"$GENERATE 0-4/-1 $.${1,2,o}.${3,4,d}.${5,6,X}.${7,8,x} 86400 IN A 1.2.3.4"}), DNSName("test")); + ZoneParserTNG zp(std::vector({"$GENERATE 0-4/-1 $.${1,2,o}.${3,4,d}.${5,6,X}.${7,8,x} 86400 IN A 1.2.3.4"}), ZoneName("test")); DNSResourceRecord rr; BOOST_CHECK_THROW(zp.get(rr), std::exception); } { /* test invalid generate parameters: no offset */ - ZoneParserTNG zp(std::vector({"$GENERATE 0-4/1 $.${}.${3,4,d}.${5,6,X}.${7,8,x} 86400 IN A 1.2.3.4"}), DNSName("test")); + ZoneParserTNG zp(std::vector({"$GENERATE 0-4/1 $.${}.${3,4,d}.${5,6,X}.${7,8,x} 86400 IN A 1.2.3.4"}), ZoneName("test")); DNSResourceRecord rr; BOOST_CHECK_THROW(zp.get(rr), PDNSException); } { /* test invalid generate parameters: invalid offset */ - ZoneParserTNG zp(std::vector({"$GENERATE 0-4/1 $.${a,2,o}.${3,4,d}.${5,6,X}.${7,8,x} 86400 IN A 1.2.3.4"}), DNSName("test")); + ZoneParserTNG zp(std::vector({"$GENERATE 0-4/1 $.${a,2,o}.${3,4,d}.${5,6,X}.${7,8,x} 86400 IN A 1.2.3.4"}), ZoneName("test")); DNSResourceRecord rr; BOOST_CHECK_THROW(zp.get(rr), PDNSException); } } BOOST_AUTO_TEST_CASE(test_tng_upgrade) { - ZoneParserTNG zp(std::vector({"foo.test. 86400 IN TYPE1 \\# 4 c0000304"}), DNSName("test"), true); + ZoneParserTNG zp(std::vector({"foo.test. 86400 IN TYPE1 \\# 4 c0000304"}), ZoneName("test"), true); DNSResourceRecord rr; zp.get(rr); diff --git a/pdns/tkey.cc b/pdns/tkey.cc index 2132f20756..13a0436f22 100644 --- a/pdns/tkey.cc +++ b/pdns/tkey.cc @@ -40,7 +40,7 @@ void PacketHandler::tkeyHandler(const DNSPacket& p, std::unique_ptr& if (g_doGssTSIG) { if (tkey_in.d_algo == DNSName("gss-tsig.")) { std::vector meta; - DNSName tmpName(name); + ZoneName tmpName(name); do { if (B.getDomainMetadata(tmpName, "GSS-ACCEPTOR-PRINCIPAL", meta) && meta.size()>0) { break; diff --git a/pdns/tsig-tests.cc b/pdns/tsig-tests.cc index e63e29ebc5..5b1c86965c 100644 --- a/pdns/tsig-tests.cc +++ b/pdns/tsig-tests.cc @@ -64,7 +64,7 @@ try tt.name=keyname; tt.algo=DNSName("hmac-md5"); tt.secret=key; - AXFRRetriever axfr(dest, DNSName("b.aa"), tt); + AXFRRetriever axfr(dest, ZoneName("b.aa"), tt); vector res; while(axfr.getChunk(res)) { } diff --git a/pdns/ueberbackend.cc b/pdns/ueberbackend.cc index dbeb04ee9c..c0f957a53d 100644 --- a/pdns/ueberbackend.cc +++ b/pdns/ueberbackend.cc @@ -119,7 +119,7 @@ void UeberBackend::go() d_cond.notify_all(); } -bool UeberBackend::getDomainInfo(const DNSName& domain, DomainInfo& domainInfo, bool getSerial) +bool UeberBackend::getDomainInfo(const ZoneName& domain, DomainInfo& domainInfo, bool getSerial) { for (auto& backend : backends) { if (backend->getDomainInfo(domain, domainInfo, getSerial)) { @@ -129,7 +129,7 @@ bool UeberBackend::getDomainInfo(const DNSName& domain, DomainInfo& domainInfo, return false; } -bool UeberBackend::createDomain(const DNSName& domain, const DomainInfo::DomainKind kind, const vector& primaries, const string& account) +bool UeberBackend::createDomain(const ZoneName& domain, const DomainInfo::DomainKind kind, const vector& primaries, const string& account) { for (auto& backend : backends) { if (backend->createDomain(domain, kind, primaries, account)) { @@ -149,7 +149,7 @@ bool UeberBackend::doesDNSSEC() return false; } -bool UeberBackend::addDomainKey(const DNSName& name, const DNSBackend::KeyData& key, int64_t& keyID) +bool UeberBackend::addDomainKey(const ZoneName& name, const DNSBackend::KeyData& key, int64_t& keyID) { keyID = -1; for (auto& backend : backends) { @@ -159,7 +159,7 @@ bool UeberBackend::addDomainKey(const DNSName& name, const DNSBackend::KeyData& } return false; } -bool UeberBackend::getDomainKeys(const DNSName& name, std::vector& keys) +bool UeberBackend::getDomainKeys(const ZoneName& name, std::vector& keys) { for (auto& backend : backends) { if (backend->getDomainKeys(name, keys)) { @@ -169,7 +169,7 @@ bool UeberBackend::getDomainKeys(const DNSName& name, std::vector>& meta) +bool UeberBackend::getAllDomainMetadata(const ZoneName& name, std::map>& meta) { for (auto& backend : backends) { if (backend->getAllDomainMetadata(name, meta)) { @@ -179,7 +179,7 @@ bool UeberBackend::getAllDomainMetadata(const DNSName& name, std::map& meta) +bool UeberBackend::getDomainMetadata(const ZoneName& name, const std::string& kind, std::vector& meta) { for (auto& backend : backends) { if (backend->getDomainMetadata(name, kind, meta)) { @@ -189,7 +189,7 @@ bool UeberBackend::getDomainMetadata(const DNSName& name, const std::string& kin return false; } -bool UeberBackend::getDomainMetadata(const DNSName& name, const std::string& kind, std::string& meta) +bool UeberBackend::getDomainMetadata(const ZoneName& name, const std::string& kind, std::string& meta) { meta.clear(); std::vector tmp; @@ -200,7 +200,7 @@ bool UeberBackend::getDomainMetadata(const DNSName& name, const std::string& kin return ret; } -bool UeberBackend::setDomainMetadata(const DNSName& name, const std::string& kind, const std::vector& meta) +bool UeberBackend::setDomainMetadata(const ZoneName& name, const std::string& kind, const std::vector& meta) { for (auto& backend : backends) { if (backend->setDomainMetadata(name, kind, meta)) { @@ -210,7 +210,7 @@ bool UeberBackend::setDomainMetadata(const DNSName& name, const std::string& kin return false; } -bool UeberBackend::setDomainMetadata(const DNSName& name, const std::string& kind, const std::string& meta) +bool UeberBackend::setDomainMetadata(const ZoneName& name, const std::string& kind, const std::string& meta) { std::vector tmp; if (!meta.empty()) { @@ -219,7 +219,7 @@ bool UeberBackend::setDomainMetadata(const DNSName& name, const std::string& kin return setDomainMetadata(name, kind, tmp); } -bool UeberBackend::activateDomainKey(const DNSName& name, unsigned int keyID) +bool UeberBackend::activateDomainKey(const ZoneName& name, unsigned int keyID) { for (auto& backend : backends) { if (backend->activateDomainKey(name, keyID)) { @@ -229,7 +229,7 @@ bool UeberBackend::activateDomainKey(const DNSName& name, unsigned int keyID) return false; } -bool UeberBackend::deactivateDomainKey(const DNSName& name, unsigned int keyID) +bool UeberBackend::deactivateDomainKey(const ZoneName& name, unsigned int keyID) { for (auto& backend : backends) { if (backend->deactivateDomainKey(name, keyID)) { @@ -239,7 +239,7 @@ bool UeberBackend::deactivateDomainKey(const DNSName& name, unsigned int keyID) return false; } -bool UeberBackend::publishDomainKey(const DNSName& name, unsigned int keyID) +bool UeberBackend::publishDomainKey(const ZoneName& name, unsigned int keyID) { for (auto& backend : backends) { if (backend->publishDomainKey(name, keyID)) { @@ -249,7 +249,7 @@ bool UeberBackend::publishDomainKey(const DNSName& name, unsigned int keyID) return false; } -bool UeberBackend::unpublishDomainKey(const DNSName& name, unsigned int keyID) +bool UeberBackend::unpublishDomainKey(const ZoneName& name, unsigned int keyID) { for (auto& backend : backends) { if (backend->unpublishDomainKey(name, keyID)) { @@ -259,7 +259,7 @@ bool UeberBackend::unpublishDomainKey(const DNSName& name, unsigned int keyID) return false; } -bool UeberBackend::removeDomainKey(const DNSName& name, unsigned int keyID) +bool UeberBackend::removeDomainKey(const ZoneName& name, unsigned int keyID) { for (auto& backend : backends) { if (backend->removeDomainKey(name, keyID)) { @@ -282,7 +282,7 @@ void UeberBackend::updateZoneCache() return; } - vector> zone_indices; + vector> zone_indices; g_zoneCache.setReplacePending(); for (auto& backend : backends) { @@ -332,7 +332,7 @@ bool UeberBackend::inTransaction() return false; } -bool UeberBackend::fillSOAFromZoneRecord(DNSName& shorter, const int zoneId, SOAData* const soaData) +bool UeberBackend::fillSOAFromZoneRecord(ZoneName& shorter, const int zoneId, SOAData* const soaData) { // Zone exists in zone cache, directly look up SOA. lookup(QType(QType::SOA), shorter, zoneId, nullptr); @@ -373,7 +373,7 @@ bool UeberBackend::fillSOAFromZoneRecord(DNSName& shorter, const int zoneId, SOA return true; } -UeberBackend::CacheResult UeberBackend::fillSOAFromCache(SOAData* soaData, DNSName& shorter) +UeberBackend::CacheResult UeberBackend::fillSOAFromCache(SOAData* soaData, ZoneName& shorter) { auto cacheResult = cacheHas(d_question, d_answers); @@ -391,7 +391,7 @@ UeberBackend::CacheResult UeberBackend::fillSOAFromCache(SOAData* soaData, DNSNa return cacheResult; } -static std::vector>::iterator findBestMatchingBackend(std::vector>& backends, std::vector>& bestMatches, const DNSName& shorter, SOAData* soaData) +static std::vector>::iterator findBestMatchingBackend(std::vector>& backends, std::vector>& bestMatches, const ZoneName& shorter, SOAData* soaData) { auto backend = backends.begin(); for (auto bestMatch = bestMatches.begin(); backend != backends.end() && bestMatch != bestMatches.end(); ++backend, ++bestMatch) { @@ -444,7 +444,7 @@ static bool foundTarget(const DNSName& target, const DNSName& shorter, const QTy return false; } -bool UeberBackend::getAuth(const DNSName& target, const QType& qtype, SOAData* soaData, bool cachedOk) +bool UeberBackend::getAuth(const ZoneName& target, const QType& qtype, SOAData* soaData, bool cachedOk) { // A backend can respond to our authority request with the 'best' match it // has. For example, when asked for a.b.c.example.com. it might respond with @@ -454,7 +454,7 @@ bool UeberBackend::getAuth(const DNSName& target, const QType& qtype, SOAData* s // If a backend has no match it may respond with an empty qname. bool found = false; - DNSName shorter(target); + ZoneName shorter(target); vector> bestMatches(backends.size(), pair(target.wirelength() + 1, SOAData())); bool first = true; @@ -544,7 +544,7 @@ bool UeberBackend::getAuth(const DNSName& target, const QType& qtype, SOAData* s return found; } -bool UeberBackend::getSOAUncached(const DNSName& domain, SOAData& soaData) +bool UeberBackend::getSOAUncached(const ZoneName& domain, SOAData& soaData) { d_question.qtype = QType::SOA; d_question.qname = domain; @@ -605,7 +605,7 @@ bool UeberBackend::autoPrimariesList(std::vector& primaries) return false; } -bool UeberBackend::autoPrimaryBackend(const string& ipAddr, const DNSName& domain, const vector& nsset, string* nameserver, string* account, DNSBackend** dnsBackend) +bool UeberBackend::autoPrimaryBackend(const string& ipAddr, const ZoneName& domain, const vector& nsset, string* nameserver, string* account, DNSBackend** dnsBackend) { for (auto& backend : backends) { if (backend->autoPrimaryBackend(ipAddr, domain, nsset, nameserver, account, dnsBackend)) { @@ -678,7 +678,7 @@ void UeberBackend::addCache(const Question& question, vector&& rr QC.insert(question.qname, question.qtype, std::move(rrs), d_cache_ttl, question.zoneId); } -void UeberBackend::alsoNotifies(const DNSName& domain, set* ips) +void UeberBackend::alsoNotifies(const ZoneName& domain, set* ips) { for (auto& backend : backends) { backend->alsoNotifies(domain, ips); diff --git a/pdns/ueberbackend.hh b/pdns/ueberbackend.hh index 2e403c9003..df21e07169 100644 --- a/pdns/ueberbackend.hh +++ b/pdns/ueberbackend.hh @@ -47,7 +47,7 @@ public: UeberBackend(const string& pname = "default"); ~UeberBackend(); - bool autoPrimaryBackend(const string& ip, const DNSName& domain, const vector& nsset, string* nameserver, string* account, DNSBackend** dnsBackend); + bool autoPrimaryBackend(const string& ip, const ZoneName& domain, const vector& nsset, string* nameserver, string* account, DNSBackend** dnsBackend); bool autoPrimaryAdd(const AutoPrimary& primary); bool autoPrimaryRemove(const struct AutoPrimary& primary); @@ -100,32 +100,32 @@ public: void lookupEnd(); /** Determines if we are authoritative for a zone, and at what level */ - bool getAuth(const DNSName& target, const QType& qtype, SOAData* soaData, bool cachedOk = true); + bool getAuth(const ZoneName& target, const QType& qtype, SOAData* soaData, bool cachedOk = true); /** Load SOA info from backends, ignoring the cache.*/ - bool getSOAUncached(const DNSName& domain, SOAData& soaData); + bool getSOAUncached(const ZoneName& domain, SOAData& soaData); void getAllDomains(vector* domains, bool getSerial, bool include_disabled); void getUnfreshSecondaryInfos(vector* domains); void getUpdatedPrimaries(vector& domains, std::unordered_set& catalogs, CatalogHashMap& catalogHashes); - bool getDomainInfo(const DNSName& domain, DomainInfo& domainInfo, bool getSerial = true); - bool createDomain(const DNSName& domain, DomainInfo::DomainKind kind, const vector& primaries, const string& account); + bool getDomainInfo(const ZoneName& domain, DomainInfo& domainInfo, bool getSerial = true); + bool createDomain(const ZoneName& domain, DomainInfo::DomainKind kind, const vector& primaries, const string& account); bool doesDNSSEC(); - bool addDomainKey(const DNSName& name, const DNSBackend::KeyData& key, int64_t& keyID); - bool getDomainKeys(const DNSName& name, std::vector& keys); - bool getAllDomainMetadata(const DNSName& name, std::map>& meta); - bool getDomainMetadata(const DNSName& name, const std::string& kind, std::vector& meta); - bool getDomainMetadata(const DNSName& name, const std::string& kind, std::string& meta); - bool setDomainMetadata(const DNSName& name, const std::string& kind, const std::vector& meta); - bool setDomainMetadata(const DNSName& name, const std::string& kind, const std::string& meta); - - bool removeDomainKey(const DNSName& name, unsigned int keyID); - bool activateDomainKey(const DNSName& name, unsigned int keyID); - bool deactivateDomainKey(const DNSName& name, unsigned int keyID); - bool publishDomainKey(const DNSName& name, unsigned int keyID); - bool unpublishDomainKey(const DNSName& name, unsigned int keyID); - - void alsoNotifies(const DNSName& domain, set* ips); + bool addDomainKey(const ZoneName& name, const DNSBackend::KeyData& key, int64_t& keyID); + bool getDomainKeys(const ZoneName& name, std::vector& keys); + bool getAllDomainMetadata(const ZoneName& name, std::map>& meta); + bool getDomainMetadata(const ZoneName& name, const std::string& kind, std::vector& meta); + bool getDomainMetadata(const ZoneName& name, const std::string& kind, std::string& meta); + bool setDomainMetadata(const ZoneName& name, const std::string& kind, const std::vector& meta); + bool setDomainMetadata(const ZoneName& name, const std::string& kind, const std::string& meta); + + bool removeDomainKey(const ZoneName& name, unsigned int keyID); + bool activateDomainKey(const ZoneName& name, unsigned int keyID); + bool deactivateDomainKey(const ZoneName& name, unsigned int keyID); + bool publishDomainKey(const ZoneName& name, unsigned int keyID); + bool unpublishDomainKey(const ZoneName& name, unsigned int keyID); + + void alsoNotifies(const ZoneName& domain, set* ips); void rediscover(string* status = nullptr); void reload(); @@ -181,6 +181,6 @@ private: void addNegCache(const Question& question) const; void addCache(const Question& question, vector&& rrs) const; - bool fillSOAFromZoneRecord(DNSName& shorter, int zoneId, SOAData* soaData); - CacheResult fillSOAFromCache(SOAData* soaData, DNSName& shorter); + bool fillSOAFromZoneRecord(ZoneName& shorter, int zoneId, SOAData* soaData); + CacheResult fillSOAFromCache(SOAData* soaData, ZoneName& shorter); }; diff --git a/pdns/ws-api.cc b/pdns/ws-api.cc index 3c204ae31e..b3549fc164 100644 --- a/pdns/ws-api.cc +++ b/pdns/ws-api.cc @@ -266,7 +266,7 @@ DNSName apiNameToDNSName(const string& name) } } -DNSName apiZoneIdToName(const string& identifier) +ZoneName apiZoneIdToName(const string& identifier) { string zonename; ostringstream outputStringStream; @@ -314,14 +314,14 @@ DNSName apiZoneIdToName(const string& identifier) zonename = outputStringStream.str(); try { - return DNSName(zonename); + return ZoneName(zonename); } catch (...) { throw ApiException("Unable to parse DNS Name '" + zonename + "'"); } } -string apiZoneNameToId(const DNSName& dname) +string apiZoneNameToId(const ZoneName& dname) { string name = dname.toString(); ostringstream outputStringStream; diff --git a/pdns/ws-api.hh b/pdns/ws-api.hh index 7c3059382c..4f97e302f1 100644 --- a/pdns/ws-api.hh +++ b/pdns/ws-api.hh @@ -32,8 +32,8 @@ void apiServerConfig(HttpRequest* req, HttpResponse* resp); void apiServerStatistics(HttpRequest* req, HttpResponse* resp); // helpers -DNSName apiZoneIdToName(const string& identifier); -string apiZoneNameToId(const DNSName& name); +ZoneName apiZoneIdToName(const string& identifier); +string apiZoneNameToId(const ZoneName& name); void apiCheckNameAllowedCharacters(const string& name); void apiCheckQNameAllowedCharacters(const string& name); DNSName apiNameToDNSName(const string& name); diff --git a/pdns/ws-auth.cc b/pdns/ws-auth.cc index 3d7037dfc3..8e4e085057 100644 --- a/pdns/ws-auth.cc +++ b/pdns/ws-auth.cc @@ -90,7 +90,7 @@ double Ewma::getMax() const return d_max; } -static void patchZone(UeberBackend& backend, const DNSName& zonename, DomainInfo& domainInfo, HttpRequest* req, HttpResponse* resp); +static void patchZone(UeberBackend& backend, const ZoneName& zonename, DomainInfo& domainInfo, HttpRequest* req, HttpResponse* resp); // QTypes that MUST NOT have multiple records of the same type in a given RRset. static const std::set onlyOneEntryTypes = {QType::CNAME, QType::DNAME, QType::SOA}; @@ -385,7 +385,7 @@ static bool shouldDoRRSets(HttpRequest* req) throw ApiException("'rrsets' request parameter value '" + req->getvars["rrsets"] + "' is not supported"); } -static void fillZone(UeberBackend& backend, const DNSName& zonename, HttpResponse* resp, HttpRequest* req) +static void fillZone(UeberBackend& backend, const ZoneName& zonename, HttpResponse* resp, HttpRequest* req) { DomainInfo domainInfo; @@ -668,7 +668,7 @@ static void checkDefaultDNSSECAlgos() } } -static void throwUnableToSecure(const DNSName& zonename) +static void throwUnableToSecure(const ZoneName& zonename) { throw ApiException("No backend was able to secure '" + zonename.toString() + "', most likely because no DNSSEC" + "capable backends are loaded, or because the backends have DNSSEC disabled. Check your configuration."); @@ -677,7 +677,7 @@ static void throwUnableToSecure(const DNSName& zonename) /* * Add KSK and ZSK to an existing zone. Algorithms and sizes will be chosen per configuration. */ -static void addDefaultDNSSECKeys(DNSSECKeeper& dnssecKeeper, const DNSName& zonename) +static void addDefaultDNSSECKeys(DNSSECKeeper& dnssecKeeper, const ZoneName& zonename) { checkDefaultDNSSECAlgos(); int k_algo = DNSSECKeeper::shorthand2algorithm(::arg()["default-ksk-algorithm"]); @@ -710,7 +710,7 @@ static bool isZoneApiRectifyEnabled(const DomainInfo& domainInfo) return api_rectify == "1"; } -static void extractDomainInfoFromDocument(const Json& document, std::optional& kind, std::optional>& primaries, std::optional& catalog, std::optional& account) +static void extractDomainInfoFromDocument(const Json& document, std::optional& kind, std::optional>& primaries, std::optional& catalog, std::optional& account) { if (document["kind"].is_string()) { kind = DomainInfo::stringToKind(stringFromJson(document, "kind")); @@ -740,7 +740,7 @@ static void extractDomainInfoFromDocument(const Json& document, std::optional kind; std::optional> primaries; - std::optional catalog; + std::optional catalog; std::optional account; extractDomainInfoFromDocument(document, kind, primaries, catalog, account); @@ -1013,7 +1013,7 @@ public: } } - DNSName zoneName; + ZoneName zoneName; UeberBackend backend{}; DNSSECKeeper dnssecKeeper; DomainInfo domainInfo{}; @@ -1192,7 +1192,7 @@ static void apiZoneMetadataKindDELETE(HttpRequest* req, HttpResponse* resp) } // Throws 404 if the key with inquireKeyId does not exist -static void apiZoneCryptoKeysCheckKeyExists(const DNSName& zonename, int inquireKeyId, DNSSECKeeper* dnssecKeeper) +static void apiZoneCryptoKeysCheckKeyExists(const ZoneName& zonename, int inquireKeyId, DNSSECKeeper* dnssecKeeper) { DNSSECKeeper::keyset_t keyset = dnssecKeeper->getKeys(zonename, false); bool found = false; @@ -1207,7 +1207,7 @@ static void apiZoneCryptoKeysCheckKeyExists(const DNSName& zonename, int inquire } } -static inline int getInquireKeyId(HttpRequest* req, const DNSName& zonename, DNSSECKeeper* dnsseckeeper) +static inline int getInquireKeyId(HttpRequest* req, const ZoneName& zonename, DNSSECKeeper* dnsseckeeper) { int inquireKeyId = -1; if (req->parameters.count("key_id") == 1) { @@ -1217,7 +1217,7 @@ static inline int getInquireKeyId(HttpRequest* req, const DNSName& zonename, DNS return inquireKeyId; } -static void apiZoneCryptokeysExport(const DNSName& zonename, int64_t inquireKeyId, HttpResponse* resp, DNSSECKeeper* dnssec_dk) +static void apiZoneCryptokeysExport(const ZoneName& zonename, int64_t inquireKeyId, HttpResponse* resp, DNSSECKeeper* dnssec_dk) { DNSSECKeeper::keyset_t keyset = dnssec_dk->getKeys(zonename, false); @@ -1538,7 +1538,7 @@ static void apiZoneCryptokeysPUT(HttpRequest* req, HttpResponse* resp) resp->status = 204; } -static void gatherRecordsFromZone(const std::string& zonestring, vector& new_records, const DNSName& zonename) +static void gatherRecordsFromZone(const std::string& zonestring, vector& new_records, const ZoneName& zonename) { DNSResourceRecord resourceRecord; vector zonedata; @@ -1578,7 +1578,7 @@ static void gatherRecordsFromZone(const std::string& zonestring, vector& records, const DNSName& zone) +static void checkNewRecords(vector& records, const ZoneName& zone) { sort(records.begin(), records.end(), [](const DNSResourceRecord& rec_a, const DNSResourceRecord& rec_b) -> bool { @@ -1843,7 +1843,7 @@ static void apiServerZonesPOST(HttpRequest* req, HttpResponse* resp) DNSSECKeeper dnssecKeeper(&backend); DomainInfo domainInfo; const auto& document = req->json(); - DNSName zonename = apiNameToDNSName(stringFromJson(document, "name")); + ZoneName zonename = apiNameToDNSName(stringFromJson(document, "name")); apiCheckNameAllowedCharacters(zonename.toString()); zonename.makeUsLowerCase(); @@ -1854,7 +1854,7 @@ static void apiServerZonesPOST(HttpRequest* req, HttpResponse* resp) std::optional kind; std::optional> primaries; - std::optional catalog; + std::optional catalog; std::optional account; extractDomainInfoFromDocument(document, kind, primaries, catalog, account); @@ -2039,7 +2039,7 @@ static void apiServerZonesGET(HttpRequest* req, HttpResponse* resp) if (req->getvars.count("zone") != 0) { string zone = req->getvars["zone"]; apiCheckNameAllowedCharacters(zone); - DNSName zonename = apiNameToDNSName(zone); + ZoneName zonename = apiNameToDNSName(zone); zonename.makeUsLowerCase(); DomainInfo domainInfo; if (backend.getDomainInfo(zonename, domainInfo)) { @@ -2284,7 +2284,7 @@ static void apiServerZoneRectify(HttpRequest* req, HttpResponse* resp) } // NOLINTNEXTLINE(readability-function-cognitive-complexity): TODO Refactor this function. -static void patchZone(UeberBackend& backend, const DNSName& zonename, DomainInfo& domainInfo, HttpRequest* req, HttpResponse* resp) +static void patchZone(UeberBackend& backend, const ZoneName& zonename, DomainInfo& domainInfo, HttpRequest* req, HttpResponse* resp) { bool zone_disabled = false; SOAData soaData; @@ -2309,11 +2309,11 @@ static void patchZone(UeberBackend& backend, const DNSName& zonename, DomainInfo domainInfo.backend->getDomainMetadataOne(zonename, "SOA-EDIT", soa_edit_kind); bool soa_edit_done = false; - set> seen; + set> seen; for (const auto& rrset : rrsets.array_items()) { string changetype = toUpper(stringFromJson(rrset, "changetype")); - DNSName qname = apiNameToDNSName(stringFromJson(rrset, "name")); + ZoneName qname = apiNameToDNSName(stringFromJson(rrset, "name")); apiCheckQNameAllowedCharacters(qname.toString()); QType qtype; qtype = stringFromJson(rrset, "type"); @@ -2587,7 +2587,7 @@ static void apiServerSearchData(HttpRequest* req, HttpResponse* resp) static void apiServerCacheFlush(HttpRequest* req, HttpResponse* resp) { - DNSName canon = apiNameToDNSName(req->getvars["domain"]); + ZoneName canon = apiNameToDNSName(req->getvars["domain"]); if (g_zoneCache.isEnabled()) { DomainInfo domainInfo; diff --git a/pdns/zone2json.cc b/pdns/zone2json.cc index 51e76fa03b..669645aa01 100644 --- a/pdns/zone2json.cc +++ b/pdns/zone2json.cc @@ -203,7 +203,7 @@ try cerr<<"\r100% done\033\133\113"< g_objects; map g_entries; map g_recorddata; @@ -345,7 +345,7 @@ int main( int argc, char* argv[] ) return 1; } - g_zonename = DNSName(args["zone-name"]); + g_zonename = ZoneName(args["zone-name"]); ZoneParserTNG zpt(args["zone-file"], g_zonename); zpt.setMaxGenerateSteps(args.asNum("max-generate-steps")); DNSResourceRecord rr; diff --git a/pdns/zone2sql.cc b/pdns/zone2sql.cc index 4dfa32ed84..aff21524e1 100644 --- a/pdns/zone2sql.cc +++ b/pdns/zone2sql.cc @@ -111,7 +111,7 @@ static void startNewTransaction() cout<<"BEGIN TRANSACTION;"<* primaries = nullptr) +static void emitDomain(const ZoneName& domain, const vector* primaries = nullptr) { string iDomain = domain.toStringRootDot(); if (!::arg().mustDo("secondary")) { @@ -134,7 +134,7 @@ static void emitDomain(const DNSName& domain, const vector* primar } bool g_doJSONComments; -static void emitRecord(const DNSName& zoneName, const DNSName &DNSqname, const string &qtype, const string &ocontent, int ttl, const string& comment="") +static void emitRecord(const ZoneName& zoneName, const DNSName &DNSqname, const string &qtype, const string &ocontent, int ttl, const string& comment="") { string qname = DNSqname.toStringRootDot(); string zname = zoneName.toStringRootDot(); @@ -331,9 +331,9 @@ try cerr<<"\r100% done\033\133\113"< d_nsec3s; DNSName d_nsec3label; - const DNSName d_zone; + const ZoneName d_zone; const ContentSigPair empty; }; diff --git a/pdns/zoneparser-tng.cc b/pdns/zoneparser-tng.cc index 41bd5e5683..93587d9020 100644 --- a/pdns/zoneparser-tng.cc +++ b/pdns/zoneparser-tng.cc @@ -38,7 +38,7 @@ const static string g_INstr("IN"); -ZoneParserTNG::ZoneParserTNG(const string& fname, DNSName zname, string reldir, bool upgradeContent): +ZoneParserTNG::ZoneParserTNG(const string& fname, ZoneName zname, string reldir, bool upgradeContent): d_reldir(std::move(reldir)), d_zonename(std::move(zname)), d_defaultttl(3600), d_templatecounter(0), d_templatestop(0), d_templatestep(0), d_havedollarttl(false), d_fromfile(true), d_upgradeContent(upgradeContent) @@ -46,7 +46,7 @@ ZoneParserTNG::ZoneParserTNG(const string& fname, DNSName zname, string reldir stackFile(fname); } -ZoneParserTNG::ZoneParserTNG(const vector& zonedata, DNSName zname, bool upgradeContent): +ZoneParserTNG::ZoneParserTNG(const vector& zonedata, ZoneName zname, bool upgradeContent): d_zonename(std::move(zname)), d_zonedata(zonedata), d_defaultttl(3600), d_templatecounter(0), d_templatestop(0), d_templatestep(0), d_havedollarttl(false), d_fromfile(false), d_upgradeContent(upgradeContent) @@ -314,7 +314,7 @@ static bool findAndElide(string& line, char c) return false; } -DNSName ZoneParserTNG::getZoneName() +ZoneName ZoneParserTNG::getZoneName() { return d_zonename; } @@ -372,7 +372,7 @@ bool ZoneParserTNG::get(DNSResourceRecord& rr, std::string* comment) stackFile(fname); } else if(pdns_iequals(command, "$ORIGIN") && d_parts.size() > 1) { - d_zonename = DNSName(makeString(d_line, d_parts[1])); + d_zonename = ZoneName(makeString(d_line, d_parts[1])); } else if(pdns_iequals(command, "$GENERATE") && d_parts.size() > 2) { if (!d_generateEnabled) { diff --git a/pdns/zoneparser-tng.hh b/pdns/zoneparser-tng.hh index 977fcb7682..7a2961957e 100644 --- a/pdns/zoneparser-tng.hh +++ b/pdns/zoneparser-tng.hh @@ -31,14 +31,14 @@ class ZoneParserTNG { public: - ZoneParserTNG(const string& fname, DNSName zname=g_rootdnsname, string reldir="", bool upgradeContent=false); - ZoneParserTNG(const vector& zonedata, DNSName zname, bool upgradeContent=false); + ZoneParserTNG(const string& fname, ZoneName zname=g_rootdnsname, string reldir="", bool upgradeContent=false); + ZoneParserTNG(const vector& zonedata, ZoneName zname, bool upgradeContent=false); ~ZoneParserTNG(); bool get(DNSResourceRecord& rr, std::string* comment=0); typedef runtime_error exception; typedef std::deque > parts_t; - DNSName getZoneName(); + ZoneName getZoneName(); string getLineOfFile(); // for error reporting purposes pair getLineNumAndFile(); // idem void disableGenerate() @@ -71,7 +71,7 @@ private: string d_reldir; string d_line; DNSName d_prevqname; - DNSName d_zonename; + ZoneName d_zonename; string d_templateline; vector d_zonedata; vector::iterator d_zonedataline;