From: Miod Vallat Date: Fri, 11 Apr 2025 09:29:05 +0000 (+0200) Subject: Appease clang-tidy. X-Git-Tag: dnsdist-2.0.0-alpha2~80^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e2daa61c9e2f007c42f3e0f774492be581aa1956;p=thirdparty%2Fpdns.git Appease clang-tidy. --- diff --git a/modules/bindbackend/bindbackend2.cc b/modules/bindbackend/bindbackend2.cc index 7caf87b500..77525b7aa7 100644 --- a/modules/bindbackend/bindbackend2.cc +++ b/modules/bindbackend/bindbackend2.cc @@ -202,21 +202,21 @@ void Bind2Backend::setFresh(uint32_t domain_id) setLastCheck(domain_id, time(nullptr)); } -bool Bind2Backend::startTransaction(const ZoneName& qname, int id) +bool Bind2Backend::startTransaction(const ZoneName& qname, int domainId) { - if (id < 0) { + if (domainId < 0) { d_transaction_tmpname.clear(); - d_transaction_id = id; + d_transaction_id = domainId; return false; } - if (id == 0) { + if (domainId == 0) { throw DBException("domain_id 0 is invalid for this backend."); } - d_transaction_id = id; + d_transaction_id = domainId; d_transaction_qname = qname; BB2DomainInfo bbd; - if (safeGetBBDomainInfo(id, &bbd)) { + if (safeGetBBDomainInfo(domainId, &bbd)) { d_transaction_tmpname = bbd.d_filename + "XXXXXX"; int fd = mkstemp(&d_transaction_tmpname.at(0)); if (fd == -1) { @@ -436,26 +436,26 @@ void Bind2Backend::getUnfreshSecondaryInfos(vector* unfreshDomains) } } -bool Bind2Backend::getDomainInfo(const ZoneName& domain, DomainInfo& di, bool getSerial) +bool Bind2Backend::getDomainInfo(const ZoneName& domain, DomainInfo& info, bool getSerial) { BB2DomainInfo bbd; if (!safeGetBBDomainInfo(domain, &bbd)) return false; - di.id = bbd.d_id; - di.zone = domain; - di.primaries = bbd.d_primaries; - di.last_check = bbd.d_lastcheck; - di.backend = this; - di.kind = bbd.d_kind; - di.serial = 0; + info.id = bbd.d_id; + info.zone = domain; + info.primaries = bbd.d_primaries; + info.last_check = bbd.d_lastcheck; + info.backend = this; + info.kind = bbd.d_kind; + info.serial = 0; if (getSerial) { try { SOAData sd; sd.serial = 0; getSOA(bbd.d_name, sd); // we might not *have* a SOA yet - di.serial = sd.serial; + info.serial = sd.serial; } catch (...) { } @@ -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 ZoneName& 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, const bool* auth) { Bind2DNSRecord bdr; bdr.qname = qname; @@ -1291,15 +1291,15 @@ bool Bind2Backend::handle::get_normal(DNSResourceRecord& r) return true; } -bool Bind2Backend::list(const ZoneName& /* target */, int id, bool /* include_disabled */) +bool Bind2Backend::list(const ZoneName& /* target */, int domainId, bool /* include_disabled */) { BB2DomainInfo bbd; - if (!safeGetBBDomainInfo(id, &bbd)) + if (!safeGetBBDomainInfo(domainId, &bbd)) return false; d_handle.reset(); - DLOG(g_log << "Bind2Backend constructing handle for list of " << id << endl); + DLOG(g_log << "Bind2Backend constructing handle for list of " << domainId << endl); if (!bbd.d_loaded) { throw PDNSException("zone was not loaded, perhaps because of: " + bbd.d_status); @@ -1309,7 +1309,7 @@ bool Bind2Backend::list(const ZoneName& /* target */, int id, bool /* include_di d_handle.d_qname_iter = d_handle.d_records->begin(); d_handle.d_qname_end = d_handle.d_records->end(); // iter now points to a vector of pointers to vector - d_handle.id = id; + d_handle.id = domainId; d_handle.domain = bbd.d_name; d_handle.d_list = true; return true; @@ -1355,7 +1355,7 @@ bool Bind2Backend::autoPrimariesList(std::vector& primaries) return true; } -bool Bind2Backend::autoPrimaryBackend(const string& ip, const ZoneName& /* domain */, const vector& /* nsset */, string* /* nameserver */, string* account, DNSBackend** db) +bool Bind2Backend::autoPrimaryBackend(const string& ipAddress, const ZoneName& /* domain */, const vector& /* nsset */, string* /* nameserver */, string* account, DNSBackend** backend) { // Check whether we have a configfile available. if (getArg("autoprimary-config").empty()) @@ -1373,18 +1373,18 @@ bool Bind2Backend::autoPrimaryBackend(const string& ip, const ZoneName& /* domai while (getline(c_if, line)) { std::istringstream ii(line); ii >> sip; - if (sip == ip) { + if (sip == ipAddress) { ii >> saccount; break; } } c_if.close(); - if (sip != ip) // ip not found in authorization list - reject + if (sip != ipAddress) // ip not found in authorization list - reject return false; // ip authorized as autoprimary - accept - *db = this; + *backend = this; if (saccount.length() > 0) *account = saccount.c_str(); @@ -1414,13 +1414,13 @@ BB2DomainInfo Bind2Backend::createDomainEntry(const ZoneName& domain, const stri return bbd; } -bool Bind2Backend::createSecondaryDomain(const string& ip, const ZoneName& domain, const string& /* nameserver */, const string& account) +bool Bind2Backend::createSecondaryDomain(const string& ipAddress, const ZoneName& domain, const string& /* nameserver */, const string& account) { string filename = getArg("autoprimary-destdir") + '/' + domain.toStringNoDot(); g_log << Logger::Warning << d_logprefix << " Writing bind config zone statement for superslave zone '" << domain - << "' from autoprimary " << ip << endl; + << "' from autoprimary " << ipAddress << endl; { std::lock_guard l2(s_autosecondary_config_lock); @@ -1436,14 +1436,14 @@ bool Bind2Backend::createSecondaryDomain(const string& ip, const ZoneName& domai c_of << "zone \"" << domain.toStringNoDot() << "\" {" << endl; c_of << "\ttype secondary;" << endl; c_of << "\tfile \"" << filename << "\";" << endl; - c_of << "\tprimaries { " << ip << "; };" << endl; + c_of << "\tprimaries { " << ipAddress << "; };" << endl; c_of << "};" << endl; c_of.close(); } BB2DomainInfo bbd = createDomainEntry(domain, filename); bbd.d_kind = DomainInfo::Secondary; - bbd.d_primaries.push_back(ComboAddress(ip, 53)); + bbd.d_primaries.push_back(ComboAddress(ipAddress, 53)); bbd.setCtime(); safePutBBDomainInfo(bbd); diff --git a/modules/bindbackend/bindbackend2.hh b/modules/bindbackend/bindbackend2.hh index 8b0adb2d8c..f4ba903d1b 100644 --- a/modules/bindbackend/bindbackend2.hh +++ b/modules/bindbackend/bindbackend2.hh @@ -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 ZoneName& domain, DomainInfo& di, bool getSerial = true) override; + bool getDomainInfo(const ZoneName& domain, DomainInfo& info, 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 ZoneName& target, int id, bool include_disabled = false) override; + bool list(const ZoneName& target, int domainId, bool include_disabled = false) override; bool get(DNSResourceRecord&) override; void getAllDomains(vector* domains, bool getSerial, bool include_disabled = false) override; @@ -199,7 +199,7 @@ 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 ZoneName& qname, int id) override; + bool startTransaction(const ZoneName& qname, int domainId) override; bool feedRecord(const DNSResourceRecord& rr, const DNSName& ordername, bool ordernameIsNSEC3 = false) override; bool commitTransaction() override; bool abortTransaction() override; @@ -211,12 +211,12 @@ public: 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 removeDomainKey(const ZoneName& name, unsigned int keyId) override; + bool addDomainKey(const ZoneName& name, const KeyData& key, int64_t& keyId) override; + bool activateDomainKey(const ZoneName& name, unsigned int keyId) override; + bool deactivateDomainKey(const ZoneName& name, unsigned int keyId) override; + bool publishDomainKey(const ZoneName& name, unsigned int keyId) override; + bool unpublishDomainKey(const ZoneName& name, unsigned int keyId) 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; @@ -234,9 +234,9 @@ public: // for autoprimary support bool autoPrimariesList(std::vector& primaries) override; - bool autoPrimaryBackend(const string& ip, const ZoneName& domain, const vector& nsset, string* nameserver, string* account, DNSBackend** db) override; + bool autoPrimaryBackend(const string& ipAddress, const ZoneName& domain, const vector& nsset, string* nameserver, string* account, DNSBackend** backend) override; static std::mutex s_autosecondary_config_lock; - bool createSecondaryDomain(const string& ip, const ZoneName& domain, const string& nameserver, const string& account) override; + bool createSecondaryDomain(const string& ipAddress, const ZoneName& domain, const string& nameserver, const string& account) override; private: void setupDNSSEC(); @@ -313,7 +313,7 @@ private: 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 ZoneName& 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(), const 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); diff --git a/modules/bindbackend/binddnssec.cc b/modules/bindbackend/binddnssec.cc index 4e3ce26072..20f00691cd 100644 --- a/modules/bindbackend/binddnssec.cc +++ b/modules/bindbackend/binddnssec.cc @@ -210,6 +210,7 @@ unsigned int Bind2Backend::getCapabilities() return caps; } +// NOLINTNEXTLINE(readability-convert-member-functions-to-static) bool Bind2Backend::getNSEC3PARAM(const ZoneName& name, NSEC3PARAMRecordContent* ns3p) { BB2DomainInfo bbd; @@ -346,13 +347,13 @@ bool Bind2Backend::getDomainKeys(const ZoneName& name, std::vector& key return true; } -bool Bind2Backend::removeDomainKey(const ZoneName& name, unsigned int id) +bool Bind2Backend::removeDomainKey(const ZoneName& name, unsigned int keyId) { if (!d_dnssecdb || d_hybrid) return false; try { - d_deleteDomainKeyQuery_stmt->bind("domain", name)->bind("key_id", id)->execute()->reset(); + d_deleteDomainKeyQuery_stmt->bind("domain", name)->bind("key_id", keyId)->execute()->reset(); } catch (SSqlException& se) { throw PDNSException("Error accessing DNSSEC database in BIND backend, removeDomainKeys(): " + se.txtReason()); @@ -360,7 +361,7 @@ bool Bind2Backend::removeDomainKey(const ZoneName& name, unsigned int id) return true; } -bool Bind2Backend::addDomainKey(const ZoneName& name, const KeyData& key, int64_t& id) +bool Bind2Backend::addDomainKey(const ZoneName& name, const KeyData& key, int64_t& keyId) { if (!d_dnssecdb || d_hybrid) return false; @@ -375,33 +376,33 @@ bool Bind2Backend::addDomainKey(const ZoneName& name, const KeyData& key, int64_ try { d_GetLastInsertedKeyIdQuery_stmt->execute(); if (!d_GetLastInsertedKeyIdQuery_stmt->hasNextRow()) { - id = -2; + keyId = -2; return true; } SSqlStatement::row_t row; d_GetLastInsertedKeyIdQuery_stmt->nextRow(row); ASSERT_ROW_COLUMNS("get-last-inserted-key-id-query", row, 1); - id = std::stoi(row[0]); + keyId = std::stoi(row[0]); d_GetLastInsertedKeyIdQuery_stmt->reset(); - if (id == 0) { + if (keyId == 0) { // No insert took place, report as error. - id = -1; + keyId = -1; } return true; } catch (SSqlException& e) { - id = -2; + keyId = -2; return true; } } -bool Bind2Backend::activateDomainKey(const ZoneName& name, unsigned int id) +bool Bind2Backend::activateDomainKey(const ZoneName& name, unsigned int keyId) { if (!d_dnssecdb || d_hybrid) return false; try { - d_activateDomainKeyQuery_stmt->bind("domain", name)->bind("key_id", id)->execute()->reset(); + d_activateDomainKeyQuery_stmt->bind("domain", name)->bind("key_id", keyId)->execute()->reset(); } catch (SSqlException& se) { throw PDNSException("Error accessing DNSSEC database in BIND backend, activateDomainKey(): " + se.txtReason()); @@ -409,13 +410,13 @@ bool Bind2Backend::activateDomainKey(const ZoneName& name, unsigned int id) return true; } -bool Bind2Backend::deactivateDomainKey(const ZoneName& name, unsigned int id) +bool Bind2Backend::deactivateDomainKey(const ZoneName& name, unsigned int keyId) { if (!d_dnssecdb || d_hybrid) return false; try { - d_deactivateDomainKeyQuery_stmt->bind("domain", name)->bind("key_id", id)->execute()->reset(); + d_deactivateDomainKeyQuery_stmt->bind("domain", name)->bind("key_id", keyId)->execute()->reset(); } catch (SSqlException& se) { throw PDNSException("Error accessing DNSSEC database in BIND backend, deactivateDomainKey(): " + se.txtReason()); @@ -423,13 +424,13 @@ bool Bind2Backend::deactivateDomainKey(const ZoneName& name, unsigned int id) return true; } -bool Bind2Backend::publishDomainKey(const ZoneName& name, unsigned int id) +bool Bind2Backend::publishDomainKey(const ZoneName& name, unsigned int keyId) { if (!d_dnssecdb || d_hybrid) return false; try { - d_publishDomainKeyQuery_stmt->bind("domain", name)->bind("key_id", id)->execute()->reset(); + d_publishDomainKeyQuery_stmt->bind("domain", name)->bind("key_id", keyId)->execute()->reset(); } catch (SSqlException& se) { throw PDNSException("Error accessing DNSSEC database in BIND backend, publishDomainKey(): " + se.txtReason()); @@ -437,13 +438,13 @@ bool Bind2Backend::publishDomainKey(const ZoneName& name, unsigned int id) return true; } -bool Bind2Backend::unpublishDomainKey(const ZoneName& name, unsigned int id) +bool Bind2Backend::unpublishDomainKey(const ZoneName& name, unsigned int keyId) { if (!d_dnssecdb || d_hybrid) return false; try { - d_unpublishDomainKeyQuery_stmt->bind("domain", name)->bind("key_id", id)->execute()->reset(); + d_unpublishDomainKeyQuery_stmt->bind("domain", name)->bind("key_id", keyId)->execute()->reset(); } catch (SSqlException& se) { throw PDNSException("Error accessing DNSSEC database in BIND backend, unpublishDomainKey(): " + se.txtReason()); diff --git a/modules/geoipbackend/geoipbackend.cc b/modules/geoipbackend/geoipbackend.cc index 60e9b23611..b096ec012b 100644 --- a/modules/geoipbackend/geoipbackend.cc +++ b/modules/geoipbackend/geoipbackend.cc @@ -1021,7 +1021,7 @@ bool GeoIPBackend::getDomainKeys(const ZoneName& name, std::vector(glob_result.gl_pathv[i] + regm[3].rm_so); - if (kid == id) { + if (kid == keyId) { if (unlink(glob_result.gl_pathv[i])) { cerr << "Cannot delete key:" << strerror(errno) << endl; } @@ -1057,7 +1057,7 @@ bool GeoIPBackend::removeDomainKey(const ZoneName& name, unsigned int id) return false; } -bool GeoIPBackend::addDomainKey(const ZoneName& name, const KeyData& key, int64_t& id) +bool GeoIPBackend::addDomainKey(const ZoneName& name, const KeyData& key, int64_t& keyId) { if (!d_dnssec) return false; @@ -1088,14 +1088,14 @@ bool GeoIPBackend::addDomainKey(const ZoneName& name, const KeyData& key, int64_ ofstream ofs(pathname.str().c_str()); ofs.write(key.content.c_str(), key.content.size()); ofs.close(); - id = nextid; + keyId = nextid; return true; } } return false; } -bool GeoIPBackend::activateDomainKey(const ZoneName& name, unsigned int id) +bool GeoIPBackend::activateDomainKey(const ZoneName& name, unsigned int keyId) { if (!d_dnssec) return false; @@ -1112,7 +1112,7 @@ bool GeoIPBackend::activateDomainKey(const ZoneName& name, unsigned int id) for (size_t i = 0; i < glob_result.gl_pathc; i++) { if (regexec(®, glob_result.gl_pathv[i], 5, regm, 0) == 0) { auto kid = pdns::checked_stoi(glob_result.gl_pathv[i] + regm[3].rm_so); - if (kid == id && !strcmp(glob_result.gl_pathv[i] + regm[4].rm_so, "0")) { + if (kid == keyId && !strcmp(glob_result.gl_pathv[i] + regm[4].rm_so, "0")) { ostringstream newpath; newpath << getArg("dnssec-keydir") << "/" << dom.domain.toStringNoDot() << "." << pdns::checked_stoi(glob_result.gl_pathv[i] + regm[2].rm_so) << "." << kid << ".1.key"; if (rename(glob_result.gl_pathv[i], newpath.str().c_str())) { @@ -1130,7 +1130,7 @@ bool GeoIPBackend::activateDomainKey(const ZoneName& name, unsigned int id) return false; } -bool GeoIPBackend::deactivateDomainKey(const ZoneName& name, unsigned int id) +bool GeoIPBackend::deactivateDomainKey(const ZoneName& name, unsigned int keyId) { if (!d_dnssec) return false; @@ -1147,7 +1147,7 @@ bool GeoIPBackend::deactivateDomainKey(const ZoneName& name, unsigned int id) for (size_t i = 0; i < glob_result.gl_pathc; i++) { if (regexec(®, glob_result.gl_pathv[i], 5, regm, 0) == 0) { auto kid = pdns::checked_stoi(glob_result.gl_pathv[i] + regm[3].rm_so); - if (kid == id && !strcmp(glob_result.gl_pathv[i] + regm[4].rm_so, "1")) { + if (kid == keyId && !strcmp(glob_result.gl_pathv[i] + regm[4].rm_so, "1")) { ostringstream newpath; newpath << getArg("dnssec-keydir") << "/" << dom.domain.toStringNoDot() << "." << pdns::checked_stoi(glob_result.gl_pathv[i] + regm[2].rm_so) << "." << kid << ".0.key"; if (rename(glob_result.gl_pathv[i], newpath.str().c_str())) { diff --git a/modules/geoipbackend/geoipbackend.hh b/modules/geoipbackend/geoipbackend.hh index 9275d05f0c..0203d4bf41 100644 --- a/modules/geoipbackend/geoipbackend.hh +++ b/modules/geoipbackend/geoipbackend.hh @@ -76,12 +76,12 @@ public: 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; + bool removeDomainKey(const ZoneName& name, unsigned int keyId) override; + bool addDomainKey(const ZoneName& name, const KeyData& key, int64_t& keyId) override; + bool activateDomainKey(const ZoneName& name, unsigned int keyId) override; + bool deactivateDomainKey(const ZoneName& name, unsigned int keyId) override; + bool publishDomainKey(const ZoneName& name, unsigned int keyId) override; + bool unpublishDomainKey(const ZoneName& name, unsigned int keyId) override; private: static ReadWriteLock s_state_lock; diff --git a/modules/ldapbackend/ldapbackend.hh b/modules/ldapbackend/ldapbackend.hh index b6209b2496..a64a673fbb 100644 --- a/modules/ldapbackend/ldapbackend.hh +++ b/modules/ldapbackend/ldapbackend.hh @@ -175,7 +175,7 @@ public: void lookup(const QType& qtype, const DNSName& qdomain, int zoneid, DNSPacket* p = nullptr) override; bool get(DNSResourceRecord& rr) override; - bool getDomainInfo(const ZoneName& domain, DomainInfo& di, bool getSerial = true) override; + bool getDomainInfo(const ZoneName& domain, DomainInfo& info, 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 6373b7c64b..0875fa39ba 100644 --- a/modules/ldapbackend/native.cc +++ b/modules/ldapbackend/native.cc @@ -318,7 +318,7 @@ bool LdapBackend::get(DNSResourceRecord& rr) return true; } -bool LdapBackend::getDomainInfo(const ZoneName& domain, DomainInfo& di, bool /* getSerial */) +bool LdapBackend::getDomainInfo(const ZoneName& domain, DomainInfo& info, bool /* getSerial */) { string filter; SOAData sd; @@ -347,7 +347,7 @@ bool LdapBackend::getDomainInfo(const ZoneName& domain, DomainInfo& di, bool /* catch (LDAPNoConnection& lnc) { g_log << Logger::Warning << d_myname << " Connection to LDAP lost, trying to reconnect" << endl; if (reconnect()) - this->getDomainInfo(domain, di); + this->getDomainInfo(domain, info); else throw PDNSException("Failed to reconnect to LDAP server"); } @@ -364,42 +364,42 @@ bool LdapBackend::getDomainInfo(const ZoneName& domain, DomainInfo& di, bool /* fillSOAData(result["sOARecord"][0], sd); if (result.count("PdnsDomainId") && !result["PdnsDomainId"].empty()) - di.id = std::stoi(result["PdnsDomainId"][0]); + info.id = std::stoi(result["PdnsDomainId"][0]); else - di.id = 0; + info.id = 0; - di.serial = sd.serial; - di.zone = domain; + info.serial = sd.serial; + info.zone = domain; if (result.count("PdnsDomainLastCheck") && !result["PdnsDomainLastCheck"].empty()) - pdns::checked_stoi_into(di.last_check, result["PdnsDomainLastCheck"][0]); + pdns::checked_stoi_into(info.last_check, result["PdnsDomainLastCheck"][0]); else - di.last_check = 0; + info.last_check = 0; if (result.count("PdnsDomainNotifiedSerial") && !result["PdnsDomainNotifiedSerial"].empty()) - pdns::checked_stoi_into(di.notified_serial, result["PdnsDomainNotifiedSerial"][0]); + pdns::checked_stoi_into(info.notified_serial, result["PdnsDomainNotifiedSerial"][0]); else - di.notified_serial = 0; + info.notified_serial = 0; if (result.count("PdnsDomainMaster") && !result["PdnsDomainMaster"].empty()) { for (const auto& m : result["PdnsDomainMaster"]) - di.primaries.emplace_back(m, 53); + info.primaries.emplace_back(m, 53); } if (result.count("PdnsDomainType") && !result["PdnsDomainType"].empty()) { string kind = result["PdnsDomainType"][0]; if (kind == "master") - di.kind = DomainInfo::Primary; + info.kind = DomainInfo::Primary; else if (kind == "slave") - di.kind = DomainInfo::Secondary; + info.kind = DomainInfo::Secondary; else - di.kind = DomainInfo::Native; + info.kind = DomainInfo::Native; } else { - di.kind = DomainInfo::Native; + info.kind = DomainInfo::Native; } - di.backend = this; + info.backend = this; return true; } diff --git a/modules/ldapbackend/primary.cc b/modules/ldapbackend/primary.cc index ddee33b611..5f21acf890 100644 --- a/modules/ldapbackend/primary.cc +++ b/modules/ldapbackend/primary.cc @@ -62,8 +62,9 @@ void LdapBackend::getUpdatedPrimaries(vector& domains, std::unordere continue; DomainInfo di; - if (!getDomainInfo(ZoneName(result["associatedDomain"][0]), di)) + if (!getDomainInfo(ZoneName(result["associatedDomain"][0]), di)) { continue; + } if (di.notified_serial < di.serial) domains.push_back(di); diff --git a/modules/lmdbbackend/lmdbbackend.cc b/modules/lmdbbackend/lmdbbackend.cc index da492110fe..69143e4cd6 100644 --- a/modules/lmdbbackend/lmdbbackend.cc +++ b/modules/lmdbbackend/lmdbbackend.cc @@ -1655,7 +1655,7 @@ bool LMDBBackend::getSerial(DomainInfo& di) return false; } -bool LMDBBackend::getDomainInfo(const ZoneName& domain, DomainInfo& di, bool getserial) +bool LMDBBackend::getDomainInfo(const ZoneName& domain, DomainInfo& info, bool getserial) { { auto txn = d_tdomains->getROTransaction(); @@ -1665,22 +1665,22 @@ bool LMDBBackend::getDomainInfo(const ZoneName& domain, DomainInfo& di, bool get // for (auto& iter = range.first ; iter != range.second; ++iter) { // found = true; - // di.id = iter.getID(); - // di.backend = this; + // info.id = iter.getID(); + // info.backend = this; // } // if (!found) { // return false; // } - if (!(di.id = txn.get<0>(domain, di))) { + if (!(info.id = txn.get<0>(domain, info))) { return false; } - di.backend = this; + info.backend = this; } if (getserial) { - getSerial(di); + getSerial(info); } return true; @@ -2017,38 +2017,38 @@ bool LMDBBackend::getDomainKeys(const ZoneName& name, std::vector& keys return true; } -bool LMDBBackend::removeDomainKey(const ZoneName& name, unsigned int id) +bool LMDBBackend::removeDomainKey(const ZoneName& name, unsigned int keyId) { auto txn = d_tkdb->getRWTransaction(); KeyDataDB kdb; - if (txn.get(id, kdb)) { + if (txn.get(keyId, kdb)) { if (kdb.domain == name) { - txn.del(id); + txn.del(keyId); txn.commit(); return true; } } - // cout << "??? wanted to remove domain key for domain "<getRWTransaction(); KeyDataDB kdb{name, key.content, key.flags, key.active, key.published}; - id = txn.put(kdb, 0, d_random_ids); + keyId = txn.put(kdb, 0, d_random_ids); txn.commit(); return true; } -bool LMDBBackend::activateDomainKey(const ZoneName& name, unsigned int id) +bool LMDBBackend::activateDomainKey(const ZoneName& name, unsigned int keyId) { auto txn = d_tkdb->getRWTransaction(); KeyDataDB kdb; - if (txn.get(id, kdb)) { + if (txn.get(keyId, kdb)) { if (kdb.domain == name) { - txn.modify(id, [](KeyDataDB& kdbarg) { + txn.modify(keyId, [](KeyDataDB& kdbarg) { kdbarg.active = true; }); txn.commit(); @@ -2056,34 +2056,34 @@ bool LMDBBackend::activateDomainKey(const ZoneName& name, unsigned int id) } } - // cout << "??? wanted to activate domain key for domain "<getRWTransaction(); KeyDataDB kdb; - if (txn.get(id, kdb)) { + if (txn.get(keyId, kdb)) { if (kdb.domain == name) { - txn.modify(id, [](KeyDataDB& kdbarg) { + txn.modify(keyId, [](KeyDataDB& kdbarg) { kdbarg.active = false; }); txn.commit(); return true; } } - // cout << "??? wanted to deactivate domain key for domain "<getRWTransaction(); KeyDataDB kdb; - if (txn.get(id, kdb)) { + if (txn.get(keyId, kdb)) { if (kdb.domain == name) { - txn.modify(id, [](KeyDataDB& kdbarg) { + txn.modify(keyId, [](KeyDataDB& kdbarg) { kdbarg.published = true; }); txn.commit(); @@ -2091,24 +2091,24 @@ bool LMDBBackend::publishDomainKey(const ZoneName& name, unsigned int id) } } - // cout << "??? wanted to hide domain key for domain "<getRWTransaction(); KeyDataDB kdb; - if (txn.get(id, kdb)) { + if (txn.get(keyId, kdb)) { if (kdb.domain == name) { - txn.modify(id, [](KeyDataDB& kdbarg) { + txn.modify(keyId, [](KeyDataDB& kdbarg) { kdbarg.published = false; }); txn.commit(); return true; } } - // cout << "??? wanted to unhide domain key for domain "<txn->getCursor(txn->db->dbi); MDBOutVal key, val; // cout<<"Lower_bound for "<()) == id) { + if (co.getDomainID(key.getNoStripHeader()) == domainId) { before = co.getQName(key.getNoStripHeader()) + zonename; after = zonename; } @@ -2356,7 +2356,7 @@ bool LMDBBackend::getBeforeAndAfterNames(uint32_t id, const ZoneName& zonenameU, } // cout<<"Cursor is at "<()) <<", in zone id "<())<< endl; - if (co.getQType(key.getNoStripHeader()).getCode() && co.getDomainID(key.getNoStripHeader()) == id && co.getQName(key.getNoStripHeader()) == qname2) { // don't match ENTs + if (co.getQType(key.getNoStripHeader()).getCode() && co.getDomainID(key.getNoStripHeader()) == domainId && co.getQName(key.getNoStripHeader()) == qname2) { // don't match ENTs // cout << "Had an exact match!"<()) == id && key.getNoStripHeader().rfind(matchkey, 0) == 0) + if (co.getDomainID(key.getNoStripHeader()) == domainId && key.getNoStripHeader().rfind(matchkey, 0) == 0) continue; LMDBResourceRecord lrr; deserializeFromBuffer(val.get(), lrr); if (co.getQType(key.getNoStripHeader()).getCode() && (lrr.auth || co.getQType(key.getNoStripHeader()).getCode() == QType::NS)) break; } - if (rc || co.getDomainID(key.getNoStripHeader()) != id) { + if (rc || co.getDomainID(key.getNoStripHeader()) != domainId) { // cout << "We hit the end of the zone or database. 'after' is apex" << endl; after = zonename; return false; @@ -2381,7 +2381,7 @@ bool LMDBBackend::getBeforeAndAfterNames(uint32_t id, const ZoneName& zonenameU, return true; } - if (co.getDomainID(key.getNoStripHeader()) != id) { + if (co.getDomainID(key.getNoStripHeader()) != domainId) { // cout << "Ended up in next zone, 'after' is zonename" <()) != id) { - // cout<<"Reversed into zone, but found wrong zone id " << co.getDomainID(key.getNoStripHeader()) << " != "<()) != domainId) { + // cout<<"Reversed into zone, but found wrong zone id " << co.getDomainID(key.getNoStripHeader()) << " != "<()) != id) { + if (rc || co.getDomainID(key.getNoStripHeader()) != domainId) { // cout << " oops, hit end of database or zone. This means after is apex" <()) != id) { + if (rc || co.getDomainID(key.getNoStripHeader()) != domainId) { // XX I don't think this case can happen // cout << "We hit the beginning of the zone or database.. now what" << endl; return false; diff --git a/modules/lmdbbackend/lmdbbackend.hh b/modules/lmdbbackend/lmdbbackend.hh index eb1ae68ea3..65fa274644 100644 --- a/modules/lmdbbackend/lmdbbackend.hh +++ b/modules/lmdbbackend/lmdbbackend.hh @@ -63,9 +63,9 @@ public: ~LMDBBackend(); unsigned int getCapabilities() override { return CAP_DNSSEC | CAP_DIRECT | CAP_LIST | CAP_CREATE; } - bool list(const ZoneName& target, int id, bool include_disabled) override; + bool list(const ZoneName& target, int domainId, bool include_disabled) override; - bool getDomainInfo(const ZoneName& domain, DomainInfo& di, bool getserial = true) override; + bool getDomainInfo(const ZoneName& domain, DomainInfo& info, bool getserial = true) override; bool createDomain(const ZoneName& domain, const DomainInfo::DomainKind kind, const vector& primaries, const string& account) override; bool startTransaction(const ZoneName& domain, int domain_id = -1) override; @@ -94,7 +94,7 @@ public: // catalog zones 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 setCatalog(const ZoneName& domain, const ZoneName& catalog) override; bool setPrimaries(const ZoneName& domain, const vector& primaries) override; bool setKind(const ZoneName& domain, const DomainInfo::DomainKind kind) override; @@ -121,12 +121,12 @@ public: bool deleteDomain(const ZoneName& domain) 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 removeDomainKey(const ZoneName& name, unsigned int keyId) override; + bool addDomainKey(const ZoneName& name, const KeyData& key, int64_t& keyId) override; + bool activateDomainKey(const ZoneName& name, unsigned int keyId) override; + bool deactivateDomainKey(const ZoneName& name, unsigned int keyId) override; + bool publishDomainKey(const ZoneName& name, unsigned int keyId) override; + bool unpublishDomainKey(const ZoneName& name, unsigned int keyId) 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 ZoneName& zonename, const DNSName& qname, DNSName& before, DNSName& after) override; + bool getBeforeAndAfterNames(uint32_t domainId, 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; diff --git a/modules/pipebackend/pipebackend.cc b/modules/pipebackend/pipebackend.cc index 5a7b74d2ab..0f80cc916b 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 ZoneName& target, int inZoneId, bool /* include_disabled */) +bool PipeBackend::list(const ZoneName& target, int domain_id, bool /* include_disabled */) { try { launch(); @@ -205,16 +205,16 @@ bool PipeBackend::list(const ZoneName& target, int inZoneId, bool /* include_dis // type qname qclass qtype id ip-address if (d_abiVersion >= 4) - query << "AXFR\t" << inZoneId << "\t" << target.toStringRootDot(); + query << "AXFR\t" << domain_id << "\t" << target.toStringRootDot(); else - query << "AXFR\t" << inZoneId; + query << "AXFR\t" << domain_id; d_coproc->send(query.str()); } catch (PDNSException& ae) { g_log << Logger::Error << kBackendId << " Error from coprocess: " << ae.reason << endl; } - d_qname = DNSName(std::to_string(inZoneId)); // why do we store a number here?? + d_qname = DNSName(std::to_string(domain_id)); // why do we store a number here?? return true; } diff --git a/modules/remotebackend/remotebackend.cc b/modules/remotebackend/remotebackend.cc index b035dccae2..61f1633028 100644 --- a/modules/remotebackend/remotebackend.cc +++ b/modules/remotebackend/remotebackend.cc @@ -411,7 +411,7 @@ bool RemoteBackend::getDomainKeys(const ZoneName& name, std::vector(id)}}}}; + {"parameters", Json::object{{"name", name.toString()}, {"id", static_cast(keyId)}}}}; Json answer; return this->send(query) && this->recv(answer); } -bool RemoteBackend::addDomainKey(const ZoneName& name, const KeyData& key, int64_t& id) +bool RemoteBackend::addDomainKey(const ZoneName& name, const KeyData& key, int64_t& keyId) { // no point doing dnssec if it's not supported if (!d_dnssec) { @@ -442,11 +442,11 @@ bool RemoteBackend::addDomainKey(const ZoneName& name, const KeyData& key, int64 return false; } - id = answer["result"].int_value(); - return id >= 0; + keyId = answer["result"].int_value(); + return keyId >= 0; } -bool RemoteBackend::activateDomainKey(const ZoneName& name, unsigned int id) +bool RemoteBackend::activateDomainKey(const ZoneName& name, unsigned int keyId) { // no point doing dnssec if it's not supported if (!d_dnssec) { @@ -455,13 +455,13 @@ bool RemoteBackend::activateDomainKey(const ZoneName& name, unsigned int id) Json query = Json::object{ {"method", "activateDomainKey"}, - {"parameters", Json::object{{"name", name.toString()}, {"id", static_cast(id)}}}}; + {"parameters", Json::object{{"name", name.toString()}, {"id", static_cast(keyId)}}}}; Json answer; return this->send(query) && this->recv(answer); } -bool RemoteBackend::deactivateDomainKey(const ZoneName& name, unsigned int id) +bool RemoteBackend::deactivateDomainKey(const ZoneName& name, unsigned int keyId) { // no point doing dnssec if it's not supported if (!d_dnssec) { @@ -470,13 +470,13 @@ bool RemoteBackend::deactivateDomainKey(const ZoneName& name, unsigned int id) Json query = Json::object{ {"method", "deactivateDomainKey"}, - {"parameters", Json::object{{"name", name.toString()}, {"id", static_cast(id)}}}}; + {"parameters", Json::object{{"name", name.toString()}, {"id", static_cast(keyId)}}}}; Json answer; return this->send(query) && this->recv(answer); } -bool RemoteBackend::publishDomainKey(const ZoneName& name, unsigned int id) +bool RemoteBackend::publishDomainKey(const ZoneName& name, unsigned int keyId) { // no point doing dnssec if it's not supported if (!d_dnssec) { @@ -485,13 +485,13 @@ bool RemoteBackend::publishDomainKey(const ZoneName& name, unsigned int id) Json query = Json::object{ {"method", "publishDomainKey"}, - {"parameters", Json::object{{"name", name.toString()}, {"id", static_cast(id)}}}}; + {"parameters", Json::object{{"name", name.toString()}, {"id", static_cast(keyId)}}}}; Json answer; return this->send(query) && this->recv(answer); } -bool RemoteBackend::unpublishDomainKey(const ZoneName& name, unsigned int id) +bool RemoteBackend::unpublishDomainKey(const ZoneName& name, unsigned int keyId) { // no point doing dnssec if it's not supported if (!d_dnssec) { @@ -500,7 +500,7 @@ bool RemoteBackend::unpublishDomainKey(const ZoneName& name, unsigned int id) Json query = Json::object{ {"method", "unpublishDomainKey"}, - {"parameters", Json::object{{"name", name.toString()}, {"id", static_cast(id)}}}}; + {"parameters", Json::object{{"name", name.toString()}, {"id", static_cast(keyId)}}}}; Json answer; return this->send(query) && this->recv(answer); @@ -620,7 +620,7 @@ void RemoteBackend::parseDomainInfo(const Json& obj, DomainInfo& di) di.backend = this; } -bool RemoteBackend::getDomainInfo(const ZoneName& domain, DomainInfo& di, bool /* getSerial */) +bool RemoteBackend::getDomainInfo(const ZoneName& domain, DomainInfo& info, bool /* getSerial */) { if (domain.empty()) { return false; @@ -635,7 +635,7 @@ bool RemoteBackend::getDomainInfo(const ZoneName& domain, DomainInfo& di, bool / return false; } - this->parseDomainInfo(answer["result"], di); + this->parseDomainInfo(answer["result"], info); return true; } @@ -651,7 +651,7 @@ void RemoteBackend::setNotified(uint32_t id, uint32_t serial) } } -bool RemoteBackend::autoPrimaryBackend(const string& ip, const ZoneName& domain, const vector& nsset, string* nameserver, string* account, DNSBackend** ddb) +bool RemoteBackend::autoPrimaryBackend(const string& ipAddress, const ZoneName& domain, const vector& nsset, string* nameserver, string* account, DNSBackend** ddb) { Json::array rrset; @@ -667,7 +667,7 @@ bool RemoteBackend::autoPrimaryBackend(const string& ip, const ZoneName& domain, Json query = Json::object{ {"method", "superMasterBackend"}, - {"parameters", Json::object{{"ip", ip}, {"domain", domain.toString()}, {"nsset", rrset}}}}; + {"parameters", Json::object{{"ip", ipAddress}, {"domain", domain.toString()}, {"nsset", rrset}}}}; *ddb = nullptr; @@ -688,12 +688,12 @@ bool RemoteBackend::autoPrimaryBackend(const string& ip, const ZoneName& domain, return true; } -bool RemoteBackend::createSecondaryDomain(const string& ip, const ZoneName& domain, const string& nameserver, const string& account) +bool RemoteBackend::createSecondaryDomain(const string& ipAddress, const ZoneName& domain, const string& nameserver, const string& account) { Json query = Json::object{ {"method", "createSlaveDomain"}, {"parameters", Json::object{ - {"ip", ip}, + {"ip", ipAddress}, {"domain", domain.toString()}, {"nameserver", nameserver}, {"account", account}, diff --git a/modules/remotebackend/remotebackend.hh b/modules/remotebackend/remotebackend.hh index 5aa7b5b73a..b91f373eea 100644 --- a/modules/remotebackend/remotebackend.hh +++ b/modules/remotebackend/remotebackend.hh @@ -178,16 +178,16 @@ public: 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 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; + bool removeDomainKey(const ZoneName& name, unsigned int keyId) override; + bool addDomainKey(const ZoneName& name, const KeyData& key, int64_t& keyId) override; + bool activateDomainKey(const ZoneName& name, unsigned int keyId) override; + bool deactivateDomainKey(const ZoneName& name, unsigned int keyId) override; + bool publishDomainKey(const ZoneName& name, unsigned int keyId) override; + bool unpublishDomainKey(const ZoneName& name, unsigned int keyId) override; + bool getDomainInfo(const ZoneName& domain, DomainInfo& info, bool getSerial = true) override; void setNotified(uint32_t id, uint32_t serial) 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 autoPrimaryBackend(const string& ipAddress, const ZoneName& domain, const vector& nsset, string* nameserver, string* account, DNSBackend** ddb) override; + bool createSecondaryDomain(const string& ipAddress, 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; diff --git a/pdns/auth-primarycommunicator.cc b/pdns/auth-primarycommunicator.cc index a52ea89771..577ace0d84 100644 --- a/pdns/auth-primarycommunicator.cc +++ b/pdns/auth-primarycommunicator.cc @@ -111,14 +111,14 @@ 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 ZoneName& domain, UeberBackend* B) +bool CommunicatorClass::notifyDomain(const ZoneName& domain, UeberBackend* ueber) { DomainInfo di; - if (!B->getDomainInfo(domain, di)) { + if (!ueber->getDomainInfo(domain, di)) { g_log << Logger::Warning << "No such domain '" << domain << "' in our database" << endl; return false; } - queueNotifyDomain(di, B); + queueNotifyDomain(di, ueber); // call backend and tell them we sent out the notification - even though that is premature if (di.serial != di.notified_serial) di.backend->setNotified(di.id, di.serial); @@ -265,7 +265,7 @@ time_t CommunicatorClass::doNotifications(PacketHandler* P) continue; } - sendNotification(remote.sin4.sin_family == AF_INET ? d_nsock4 : d_nsock6, domain, remote, id, B); + CommunicatorClass::sendNotification(remote.sin4.sin_family == AF_INET ? d_nsock4 : d_nsock6, domain, remote, id, B); drillHole(domain, ip); } catch (ResolverException& re) { @@ -280,7 +280,7 @@ time_t CommunicatorClass::doNotifications(PacketHandler* P) return d_nq.earliest(); } -void CommunicatorClass::sendNotification(int sock, const ZoneName& domain, const ComboAddress& remote, uint16_t id, UeberBackend* B) +void CommunicatorClass::sendNotification(int sock, const ZoneName& domain, const ComboAddress& remote, uint16_t notificationId, UeberBackend* ueber) { vector meta; DNSName tsigkeyname; @@ -288,17 +288,17 @@ void CommunicatorClass::sendNotification(int sock, const ZoneName& domain, const string tsigsecret64; string tsigsecret; - if (::arg().mustDo("send-signed-notify") && B->getDomainMetadata(domain, "TSIG-ALLOW-AXFR", meta) && meta.size() > 0) { + if (::arg().mustDo("send-signed-notify") && ueber->getDomainMetadata(domain, "TSIG-ALLOW-AXFR", meta) && meta.size() > 0) { tsigkeyname = DNSName(meta[0]); } vector packet; DNSPacketWriter pw(packet, domain, QType::SOA, 1, Opcode::Notify); - pw.getHeader()->id = id; + pw.getHeader()->id = notificationId; pw.getHeader()->aa = true; if (tsigkeyname.empty() == false) { - if (!B->getTSIGKey(tsigkeyname, tsigalgorithm, tsigsecret64)) { + if (!ueber->getTSIGKey(tsigkeyname, tsigalgorithm, tsigsecret64)) { g_log << Logger::Error << "TSIG key '" << tsigkeyname << "' for domain '" << domain << "' not found" << endl; return; } @@ -309,7 +309,7 @@ void CommunicatorClass::sendNotification(int sock, const ZoneName& domain, const trc.d_algoName = tsigalgorithm; trc.d_time = time(nullptr); trc.d_fudge = 300; - trc.d_origID = ntohs(id); + trc.d_origID = ntohs(notificationId); trc.d_eRcode = 0; if (B64Decode(tsigsecret64, tsigsecret) == -1) { g_log << Logger::Error << "Unable to Base-64 decode TSIG key '" << tsigkeyname << "' for domain '" << domain << "'" << endl; @@ -323,15 +323,15 @@ void CommunicatorClass::sendNotification(int sock, const ZoneName& domain, const } } -void CommunicatorClass::drillHole(const ZoneName& domain, const string& ip) +void CommunicatorClass::drillHole(const ZoneName& domain, const string& ipAddress) { - (*d_holes.lock())[pair(domain, ip)] = time(nullptr); + (*d_holes.lock())[pair(domain, ipAddress)] = time(nullptr); } -bool CommunicatorClass::justNotified(const ZoneName& domain, const string& ip) +bool CommunicatorClass::justNotified(const ZoneName& domain, const string& ipAddress) { auto holes = d_holes.lock(); - auto it = holes->find(pair(domain, ip)); + auto it = holes->find(pair(domain, ipAddress)); if (it == holes->end()) { // no hole return false; @@ -362,7 +362,7 @@ void CommunicatorClass::makeNotifySockets() } } -void CommunicatorClass::notify(const ZoneName& domain, const string& ip) +void CommunicatorClass::notify(const ZoneName& domain, const string& ipAddress) { - d_nq.add(domain, ip); + d_nq.add(domain, ipAddress); } diff --git a/pdns/auth-secondarycommunicator.cc b/pdns/auth-secondarycommunicator.cc index f05347dcfb..463346fbdc 100644 --- a/pdns/auth-secondarycommunicator.cc +++ b/pdns/auth-secondarycommunicator.cc @@ -425,7 +425,7 @@ static bool catalogProcess(const DomainInfo& di, vector& rrs, return catalogDiff(di, fromXFR, fromDB, logPrefix); } -void CommunicatorClass::ixfrSuck(const ZoneName& domain, const TSIGTriplet& tt, const ComboAddress& laddr, const ComboAddress& remote, ZoneStatus& zs, vector* axfr) +void CommunicatorClass::ixfrSuck(const ZoneName& domain, const TSIGTriplet& tsig, const ComboAddress& laddr, const ComboAddress& remote, ZoneStatus& status, vector* axfr) { string logPrefix = "IXFR-in zone '" + domain.toLogString() + "', primary '" + remote.toString() + "', "; @@ -451,8 +451,8 @@ void CommunicatorClass::ixfrSuck(const ZoneName& domain, const TSIGTriplet& tt, soatimes drsoa_soatimes = {di.serial, 0, 0, 0, 0}; DNSRecord drsoa; drsoa.setContent(std::make_shared(g_rootdnsname, g_rootdnsname, drsoa_soatimes)); - auto deltas = getIXFRDeltas(remote, domain, drsoa, xfrTimeout, false, tt, laddr.sin4.sin_family ? &laddr : nullptr, ((size_t)::arg().asNum("xfr-max-received-mbytes")) * 1024 * 1024); - zs.numDeltas = deltas.size(); + auto deltas = getIXFRDeltas(remote, domain, drsoa, xfrTimeout, false, tsig, laddr.sin4.sin_family ? &laddr : nullptr, ((size_t)::arg().asNum("xfr-max-received-mbytes")) * 1024 * 1024); + status.numDeltas = deltas.size(); // cout<<"Got "<getZoneRepresentation()<(dr); - zs.soa_serial = sr->d_st.serial; + status.soa_serial = sr->d_st.serial; } replacement.push_back(rr); @@ -752,7 +752,7 @@ void CommunicatorClass::suck(const ZoneName& domain, const ComboAddress& remote, logPrefix = "I" + logPrefix; // XFR -> IXFR vector axfr; g_log << Logger::Notice << logPrefix << "starting IXFR" << endl; - ixfrSuck(domain, tt, laddr, remote, zs, &axfr); + CommunicatorClass::ixfrSuck(domain, tt, laddr, remote, zs, &axfr); if (!axfr.empty()) { g_log << Logger::Notice << logPrefix << "IXFR turned into an AXFR" << endl; logPrefix[0] = 'A'; // IXFR -> AXFR diff --git a/pdns/backends/gsql/gsqlbackend.cc b/pdns/backends/gsql/gsqlbackend.cc index 1dafd5bbdc..42f6b525cd 100644 --- a/pdns/backends/gsql/gsqlbackend.cc +++ b/pdns/backends/gsql/gsqlbackend.cc @@ -351,7 +351,7 @@ bool GSQLBackend::setAccount(const ZoneName &domain, const string &account) return true; } -bool GSQLBackend::getDomainInfo(const ZoneName &domain, DomainInfo &di, bool getSerial) +bool GSQLBackend::getDomainInfo(const ZoneName &domain, DomainInfo &info, bool getSerial) { /* fill DomainInfo from database info: id,name,master IP(s),last_check,notified_serial,type,account */ @@ -376,34 +376,34 @@ bool GSQLBackend::getDomainInfo(const ZoneName &domain, DomainInfo &di, bool get ASSERT_ROW_COLUMNS("info-zone-query", d_result[0], 9); - pdns::checked_stoi_into(di.id, d_result[0][0]); + pdns::checked_stoi_into(info.id, d_result[0][0]); try { - di.zone=ZoneName(d_result[0][1]); - di.catalog = (!d_result[0][7].empty() ? ZoneName(d_result[0][7]) : ZoneName()); + info.zone=ZoneName(d_result[0][1]); + info.catalog = (!d_result[0][7].empty() ? ZoneName(d_result[0][7]) : ZoneName()); } catch (...) { return false; } string type=d_result[0][5]; - di.options = d_result[0][6]; - di.account = d_result[0][8]; - di.kind = DomainInfo::stringToKind(type); + info.options = d_result[0][6]; + info.account = d_result[0][8]; + info.kind = DomainInfo::stringToKind(type); vector primaries; stringtok(primaries, d_result[0][2], " ,\t"); for (const auto& m : primaries) - di.primaries.emplace_back(m, 53); - pdns::checked_stoi_into(di.last_check, d_result[0][3]); - pdns::checked_stoi_into(di.notified_serial, d_result[0][4]); - di.backend=this; + info.primaries.emplace_back(m, 53); + pdns::checked_stoi_into(info.last_check, d_result[0][3]); + pdns::checked_stoi_into(info.notified_serial, d_result[0][4]); + info.backend=this; - di.serial = 0; + info.serial = 0; if(getSerial) { try { SOAData sd; if(!getSOA(domain, sd)) g_log<hasNextRow()) { SSqlStatement::row_t row; d_AddDomainKeyQuery_stmt->nextRow(row); - id = std::stoi(row[0]); + keyId = std::stoi(row[0]); d_AddDomainKeyQuery_stmt->reset(); return true; } else { @@ -1026,27 +1026,27 @@ bool GSQLBackend::addDomainKey(const ZoneName& name, const KeyData& key, int64_t d_GetLastInsertedKeyIdQuery_stmt->execute(); if (!d_GetLastInsertedKeyIdQuery_stmt->hasNextRow()) { - id = -2; + keyId = -2; return true; } SSqlStatement::row_t row; d_GetLastInsertedKeyIdQuery_stmt->nextRow(row); ASSERT_ROW_COLUMNS("get-last-inserted-key-id-query", row, 1); - id = std::stoi(row[0]); + keyId = std::stoi(row[0]); d_GetLastInsertedKeyIdQuery_stmt->reset(); - if (id == 0) { + if (keyId == 0) { // No insert took place, report as error. - id = -1; + keyId = -1; } return true; } catch (SSqlException &e) { - id = -2; + keyId = -2; return true; } } -bool GSQLBackend::activateDomainKey(const ZoneName& name, unsigned int id) +bool GSQLBackend::activateDomainKey(const ZoneName& name, unsigned int keyId) { if(!d_dnssecQueries) return false; @@ -1057,18 +1057,18 @@ bool GSQLBackend::activateDomainKey(const ZoneName& name, unsigned int id) // clang-format off d_ActivateDomainKeyQuery_stmt-> bind("domain", name)-> - bind("key_id", id)-> + bind("key_id", keyId)-> execute()-> reset(); // clang-format on } catch (SSqlException &e) { - throw PDNSException("GSQLBackend unable to activate key with id "+ std::to_string(id) + " for domain '" + name.toLogString() + "': "+e.txtReason()); + throw PDNSException("GSQLBackend unable to activate key with id "+ std::to_string(keyId) + " for domain '" + name.toLogString() + "': "+e.txtReason()); } return true; } -bool GSQLBackend::deactivateDomainKey(const ZoneName& name, unsigned int id) +bool GSQLBackend::deactivateDomainKey(const ZoneName& name, unsigned int keyId) { if(!d_dnssecQueries) return false; @@ -1079,18 +1079,18 @@ bool GSQLBackend::deactivateDomainKey(const ZoneName& name, unsigned int id) // clang-format off d_DeactivateDomainKeyQuery_stmt-> bind("domain", name)-> - bind("key_id", id)-> + bind("key_id", keyId)-> execute()-> reset(); // clang-format on } catch (SSqlException &e) { - throw PDNSException("GSQLBackend unable to deactivate key with id "+ std::to_string(id) + " for domain '" + name.toLogString() + "': "+e.txtReason()); + throw PDNSException("GSQLBackend unable to deactivate key with id "+ std::to_string(keyId) + " for domain '" + name.toLogString() + "': "+e.txtReason()); } return true; } -bool GSQLBackend::publishDomainKey(const ZoneName& name, unsigned int id) +bool GSQLBackend::publishDomainKey(const ZoneName& name, unsigned int keyId) { if(!d_dnssecQueries) return false; @@ -1101,18 +1101,18 @@ bool GSQLBackend::publishDomainKey(const ZoneName& name, unsigned int id) // clang-format off d_PublishDomainKeyQuery_stmt-> bind("domain", name)-> - bind("key_id", id)-> + bind("key_id", keyId)-> execute()-> reset(); // clang-format on } catch (SSqlException &e) { - throw PDNSException("GSQLBackend unable to publish key with id "+ std::to_string(id) + " for domain '" + name.toLogString() + "': "+e.txtReason()); + throw PDNSException("GSQLBackend unable to publish key with id "+ std::to_string(keyId) + " for domain '" + name.toLogString() + "': "+e.txtReason()); } return true; } -bool GSQLBackend::unpublishDomainKey(const ZoneName& name, unsigned int id) +bool GSQLBackend::unpublishDomainKey(const ZoneName& name, unsigned int keyId) { if(!d_dnssecQueries) return false; @@ -1123,20 +1123,20 @@ bool GSQLBackend::unpublishDomainKey(const ZoneName& name, unsigned int id) // clang-format off d_UnpublishDomainKeyQuery_stmt-> bind("domain", name)-> - bind("key_id", id)-> + bind("key_id", keyId)-> execute()-> reset(); // clang-format on } catch (SSqlException &e) { - throw PDNSException("GSQLBackend unable to unpublish key with id "+ std::to_string(id) + " for domain '" + name.toLogString() + "': "+e.txtReason()); + throw PDNSException("GSQLBackend unable to unpublish key with id "+ std::to_string(keyId) + " for domain '" + name.toLogString() + "': "+e.txtReason()); } return true; } -bool GSQLBackend::removeDomainKey(const ZoneName& name, unsigned int id) +bool GSQLBackend::removeDomainKey(const ZoneName& name, unsigned int keyId) { if(!d_dnssecQueries) return false; @@ -1147,13 +1147,13 @@ bool GSQLBackend::removeDomainKey(const ZoneName& name, unsigned int id) // clang-format off d_RemoveDomainKeyQuery_stmt-> bind("domain", name)-> - bind("key_id", id)-> + bind("key_id", keyId)-> execute()-> reset(); // clang-format on } catch (SSqlException &e) { - throw PDNSException("GSQLBackend unable to remove key with id "+ std::to_string(id) + " for domain '" + name.toLogString() + "': "+e.txtReason()); + throw PDNSException("GSQLBackend unable to remove key with id "+ std::to_string(keyId) + " for domain '" + name.toLogString() + "': "+e.txtReason()); } return true; } @@ -1609,7 +1609,7 @@ bool GSQLBackend::autoPrimariesList(std::vector& primaries) return true; } -bool GSQLBackend::autoPrimaryBackend(const string& ip, const ZoneName& domain, const vector& nsset, string* nameserver, string* account, DNSBackend** ddb) +bool GSQLBackend::autoPrimaryBackend(const string& ipAddress, 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) { @@ -1618,7 +1618,7 @@ bool GSQLBackend::autoPrimaryBackend(const string& ip, const ZoneName& domain, c // clang-format off d_AutoPrimaryInfoQuery_stmt-> - bind("ip", ip)-> + bind("ip", ipAddress)-> bind("nameserver", i.content)-> execute()-> getResult(d_result)-> @@ -1626,7 +1626,7 @@ bool GSQLBackend::autoPrimaryBackend(const string& ip, const ZoneName& domain, c // clang-format on } catch (SSqlException &e) { - throw PDNSException("GSQLBackend unable to search for a autoprimary with IP " + ip + " and nameserver name '" + i.content + "' for domain '" + domain.toLogString() + "': " + e.txtReason()); + throw PDNSException("GSQLBackend unable to search for a autoprimary with IP " + ipAddress + " and nameserver name '" + i.content + "' for domain '" + domain.toLogString() + "': " + e.txtReason()); } if(!d_result.empty()) { ASSERT_ROW_COLUMNS("autoprimary-query", d_result[0], 1); @@ -1666,10 +1666,10 @@ bool GSQLBackend::createDomain(const ZoneName& domain, const DomainInfo::DomainK return true; } -bool GSQLBackend::createSecondaryDomain(const string& ip, const ZoneName& domain, const string& nameserver, const string& account) +bool GSQLBackend::createSecondaryDomain(const string& ipAddress, const ZoneName& domain, const string& nameserver, const string& account) { string name; - vector primaries({ComboAddress(ip, 53)}); + vector primaries({ComboAddress(ipAddress, 53)}); try { if (!nameserver.empty()) { // figure out all IP addresses for the primary diff --git a/pdns/backends/gsql/gsqlbackend.hh b/pdns/backends/gsql/gsqlbackend.hh index 3ee05ca7c4..5a9e51baf4 100644 --- a/pdns/backends/gsql/gsqlbackend.hh +++ b/pdns/backends/gsql/gsqlbackend.hh @@ -206,18 +206,18 @@ public: 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 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 createSecondaryDomain(const string& ipAddress, 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 ZoneName& domain, const vector& nsset, string* nameserver, string* account, DNSBackend** db) override; + bool autoPrimaryBackend(const string& ipAddress, 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 ZoneName& catalog, vector& members, CatalogInfo::CatalogType type) override; - bool getDomainInfo(const ZoneName &domain, DomainInfo &di, bool getSerial=true) override; + bool getDomainInfo(const ZoneName &domain, DomainInfo &info, bool getSerial=true) override; void setNotified(uint32_t domain_id, uint32_t serial) override; bool setPrimaries(const ZoneName& domain, const vector& primaries) override; bool setKind(const ZoneName &domain, const DomainInfo::DomainKind kind) override; @@ -238,11 +238,11 @@ public: 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 removeDomainKey(const ZoneName& name, unsigned int keyId) override; + bool activateDomainKey(const ZoneName& name, unsigned int keyId) override; + bool deactivateDomainKey(const ZoneName& name, unsigned int keyId) override; + bool publishDomainKey(const ZoneName& name, unsigned int keyId) override; + bool unpublishDomainKey(const ZoneName& name, unsigned int keyId) 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/communicator.hh b/pdns/communicator.hh index 7af12f9811..2ff0e2d56c 100644 --- a/pdns/communicator.hh +++ b/pdns/communicator.hh @@ -169,16 +169,16 @@ public: time_t doNotifications(PacketHandler* P); void go(); - void drillHole(const ZoneName& domain, const string& ip); - bool justNotified(const ZoneName& domain, const string& ip); + void drillHole(const ZoneName& domain, const string& ipAddress); + bool justNotified(const ZoneName& domain, const string& ipAddress); 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 ZoneName& domain, const string& ip); + void notify(const ZoneName& domain, const string& ipAddress); void mainloop(); void retrievalLoopThread(); - void sendNotification(int sock, const ZoneName& domain, const ComboAddress& remote, uint16_t id, UeberBackend* B); - bool notifyDomain(const ZoneName& domain, UeberBackend* B); + static void sendNotification(int sock, const ZoneName& domain, const ComboAddress& remote, uint16_t notificationId, UeberBackend* ueber); + bool notifyDomain(const ZoneName& domain, UeberBackend* ueber); vector> getSuckRequests(); size_t getSuckRequestsWaiting(); @@ -190,7 +190,7 @@ private: LockGuarded, time_t>> d_holes; 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); + static void ixfrSuck(const ZoneName& domain, const TSIGTriplet& tsig, const ComboAddress& laddr, const ComboAddress& remote, ZoneStatus& status, vector* axfr); void secondaryRefresh(PacketHandler* P); void primaryUpdateCheck(PacketHandler* P); diff --git a/pdns/dbdnsseckeeper.cc b/pdns/dbdnsseckeeper.cc index d3ce6015f8..de797a0d72 100644 --- a/pdns/dbdnsseckeeper.cc +++ b/pdns/dbdnsseckeeper.cc @@ -86,7 +86,7 @@ bool DNSSECKeeper::isPresigned(const ZoneName& name, bool useCache) } -bool DNSSECKeeper::addKey(const ZoneName& 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& keyId, int bits, bool active, bool published) { if(!bits) { if(algorithm <= 10) @@ -111,7 +111,7 @@ bool DNSSECKeeper::addKey(const ZoneName& name, bool setSEPBit, int algorithm, i } DNSSECPrivateKey dspk; dspk.setKey(dpk, setSEPBit ? 257 : 256, algorithm); - return addKey(name, dspk, id, active, published) && clearKeyCache(name); + return addKey(name, dspk, keyId, active, published) && clearKeyCache(name); } void DNSSECKeeper::clearAllCaches() { @@ -140,7 +140,7 @@ void DNSSECKeeper::clearCaches(const ZoneName& name) (void)clearMetaCache(name); } -bool DNSSECKeeper::addKey(const ZoneName& name, const DNSSECPrivateKey& dpk, int64_t& id, bool active, bool published) +bool DNSSECKeeper::addKey(const ZoneName& name, const DNSSECPrivateKey& dpk, int64_t& keyId, bool active, bool published) { DNSBackend::KeyData kd; kd.flags = dpk.getFlags(); // the dpk doesn't get stored, only they key part @@ -148,7 +148,7 @@ bool DNSSECKeeper::addKey(const ZoneName& name, const DNSSECPrivateKey& dpk, int kd.published = published; kd.content = dpk.getKey()->convertToISC(); // now store it - return d_keymetadb->addDomainKey(name, kd, id) && clearKeyCache(name); + return d_keymetadb->addDomainKey(name, kd, keyId) && clearKeyCache(name); } @@ -158,12 +158,12 @@ static bool keyCompareByKindAndID(const DNSSECKeeper::keyset_t::value_type& a, c pair(!b.second.keyType, b.second.id); } -DNSSECPrivateKey DNSSECKeeper::getKeyById(const ZoneName& zname, unsigned int id) +DNSSECPrivateKey DNSSECKeeper::getKeyById(const ZoneName& zname, unsigned int keyId) { vector keys; d_keymetadb->getDomainKeys(zname, keys); for(const DNSBackend::KeyData& kd : keys) { - if(kd.id != id) + if(kd.id != keyId) continue; DNSKEYRecordContent dkrc; @@ -173,33 +173,33 @@ DNSSECPrivateKey DNSSECKeeper::getKeyById(const ZoneName& zname, unsigned int id return dpk; } - throw runtime_error("Can't find a key with id "+std::to_string(id)+" for zone '"+zname.toLogString()+"'"); + throw runtime_error("Can't find a key with id "+std::to_string(keyId)+" for zone '"+zname.toLogString()+"'"); } -bool DNSSECKeeper::removeKey(const ZoneName& zname, unsigned int id) +bool DNSSECKeeper::removeKey(const ZoneName& zname, unsigned int keyId) { - return d_keymetadb->removeDomainKey(zname, id) && clearKeyCache(zname); + return d_keymetadb->removeDomainKey(zname, keyId) && clearKeyCache(zname); } -bool DNSSECKeeper::deactivateKey(const ZoneName& zname, unsigned int id) +bool DNSSECKeeper::deactivateKey(const ZoneName& zname, unsigned int keyId) { - return d_keymetadb->deactivateDomainKey(zname, id) && clearKeyCache(zname); + return d_keymetadb->deactivateDomainKey(zname, keyId) && clearKeyCache(zname); } -bool DNSSECKeeper::activateKey(const ZoneName& zname, unsigned int id) +bool DNSSECKeeper::activateKey(const ZoneName& zname, unsigned int keyId) { - return d_keymetadb->activateDomainKey(zname, id) && clearKeyCache(zname); + return d_keymetadb->activateDomainKey(zname, keyId) && clearKeyCache(zname); } -bool DNSSECKeeper::unpublishKey(const ZoneName& zname, unsigned int id) +bool DNSSECKeeper::unpublishKey(const ZoneName& zname, unsigned int keyId) { - return d_keymetadb->unpublishDomainKey(zname, id) && clearKeyCache(zname); + return d_keymetadb->unpublishDomainKey(zname, keyId) && clearKeyCache(zname); } -bool DNSSECKeeper::publishKey(const ZoneName& zname, unsigned int id) +bool DNSSECKeeper::publishKey(const ZoneName& zname, unsigned int keyId) { - return d_keymetadb->publishDomainKey(zname, id) && clearKeyCache(zname); + return d_keymetadb->publishDomainKey(zname, keyId) && clearKeyCache(zname); } void DNSSECKeeper::getFromMetaOrDefault(const ZoneName& zname, const std::string& key, std::string& value, const std::string& defaultvalue) diff --git a/pdns/dnsbackend.cc b/pdns/dnsbackend.cc index db5fc19af7..fe33b44940 100644 --- a/pdns/dnsbackend.cc +++ b/pdns/dnsbackend.cc @@ -300,10 +300,10 @@ bool DNSBackend::get(DNSZoneRecord& zoneRecord) return true; } -bool DNSBackend::getBeforeAndAfterNames(uint32_t id, const ZoneName& zonename, const DNSName& qname, DNSName& before, DNSName& after) +bool DNSBackend::getBeforeAndAfterNames(uint32_t domainId, const ZoneName& zonename, const DNSName& qname, DNSName& before, DNSName& after) { DNSName unhashed; - bool ret = this->getBeforeAndAfterNamesAbsolute(id, qname.makeRelative(zonename).makeLowerCase(), unhashed, before, after); + bool ret = this->getBeforeAndAfterNamesAbsolute(domainId, qname.makeRelative(zonename).makeLowerCase(), unhashed, before, after); DNSName lczonename = zonename.makeLowerCase(); before += lczonename; after += lczonename; diff --git a/pdns/dnssecinfra.hh b/pdns/dnssecinfra.hh index 3a9b8c8b01..b75b36b839 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& dsk, UeberBackend& ueber, 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 5af42115d1..05e3f76d16 100644 --- a/pdns/dnsseckeeper.hh +++ b/pdns/dnsseckeeper.hh @@ -195,19 +195,19 @@ public: 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); + DNSSECPrivateKey getKeyById(const ZoneName& zname, unsigned int keyId); + bool addKey(const ZoneName& zname, bool setSEPBit, int algorithm, int64_t& keyId, int bits=0, bool active=true, bool published=true); + bool addKey(const ZoneName& zname, const DNSSECPrivateKey& dpk, int64_t& keyId, bool active=true, bool published=true); + bool removeKey(const ZoneName& zname, unsigned int keyId); + bool activateKey(const ZoneName& zname, unsigned int keyId); + bool deactivateKey(const ZoneName& zname, unsigned int keyId); + bool publishKey(const ZoneName& zname, unsigned int keyId); + bool unpublishKey(const ZoneName& zname, unsigned int keyId); + bool checkKeys(const ZoneName& zone, std::optional>> errorMessages); + + bool getNSEC3PARAM(const ZoneName& zname, NSEC3PARAMRecordContent* ns3p=nullptr, bool* narrow=nullptr, bool useCache=true); bool checkNSEC3PARAM(const NSEC3PARAMRecordContent& ns3p, string& msg); - bool setNSEC3PARAM(const ZoneName& zname, const NSEC3PARAMRecordContent& n3p, const bool& narrow=false); + bool setNSEC3PARAM(const ZoneName& zname, const NSEC3PARAMRecordContent& ns3p, const bool& narrow=false); bool unsetNSEC3PARAM(const ZoneName& zname); void getPreRRSIGs(UeberBackend& db, vector& rrs, uint32_t signTTL, DNSPacket* p=nullptr); bool isPresigned(const ZoneName& zname, bool useCache=true); @@ -306,7 +306,7 @@ 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 ZoneName& zonename); +uint32_t calculateEditSOA(uint32_t old_serial, DNSSECKeeper& dsk, 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); diff --git a/pdns/dnssecsigner.cc b/pdns/dnssecsigner.cc index 50fe1a3b64..e092db02c6 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 ZoneName& signer, const DNSName& signQName, uint16_t signQType, uint32_t signTTL, +static int getRRSIGsForRRSET(DNSSECKeeper& dsk, const ZoneName& signer, const DNSName& signQName, uint16_t signQType, uint32_t signTTL, const sortedRecords_t& toSign, vector& rrcs) { if(toSign.empty()) @@ -122,7 +122,7 @@ static int getRRSIGsForRRSET(DNSSECKeeper& dk, const ZoneName& signer, const DNS rrc.d_signer = signer; rrc.d_tag = 0; - DNSSECKeeper::keyset_t keys = dk.getKeys(signer); + DNSSECKeeper::keyset_t keys = dsk.getKeys(signer); for(DNSSECKeeper::keyset_t::value_type& keymeta : keys) { if(!keymeta.second.active) @@ -143,7 +143,7 @@ static int getRRSIGsForRRSET(DNSSECKeeper& dk, const ZoneName& signer, const DNS } // this is the entrypoint from DNSPacket -static void addSignature(DNSSECKeeper& dk, UeberBackend& db, const ZoneName& signer, const DNSName& signQName, const DNSName& wildcardname, uint16_t signQType, +static void addSignature(DNSSECKeeper& dsk, UeberBackend& ueber, 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) { @@ -153,12 +153,12 @@ static void addSignature(DNSSECKeeper& dk, UeberBackend& db, const ZoneName& sig if(toSign.empty()) return; vector rrcs; - if(dk.isPresigned(signer) || (directDNSKEYSignature && signQType == QType::DNSKEY)) { + if(dsk.isPresigned(signer) || (directDNSKEYSignature && signQType == QType::DNSKEY)) { //cerr<<"Doing presignatures"<& authSet, const DNSName& name, ZoneName& auth) +static bool getBestAuthFromSet(const set& authSet, const DNSName& name, ZoneName& signer) { - auth.trimToLabels(0); + signer.trimToLabels(0); ZoneName sname(name); do { if(authSet.find(sname) != authSet.end()) { - auth = sname; + signer = sname; return true; } } @@ -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& dsk, UeberBackend& ueber, const set& authSet, vector& rrs, DNSPacket* packet) { stable_sort(rrs.begin(), rrs.end(), rrsigncomp); @@ -224,7 +224,7 @@ void addRRSigs(DNSSECKeeper& dk, UeberBackend& db, const set& authSet, for(auto pos = rrs.cbegin(); pos != rrs.cend(); ++pos) { if(pos != rrs.cbegin() && (signQType != pos->dr.d_type || signQName != pos->dr.d_name)) { if (getBestAuthFromSet(authSet, authQName, signer)) - addSignature(dk, db, signer, signQName, wildcardQName, signQType, signTTL, signPlace, toSign, signedRecords, origTTL, packet); + addSignature(dsk, ueber, signer, signQName, wildcardQName, signQType, signTTL, signPlace, toSign, signedRecords, origTTL, packet); } signedRecords.push_back(*pos); signQName = pos->dr.d_name.makeLowerCase(); @@ -250,6 +250,6 @@ void addRRSigs(DNSSECKeeper& dk, UeberBackend& db, const set& authSet, } } if (getBestAuthFromSet(authSet, authQName, signer)) - addSignature(dk, db, signer, signQName, wildcardQName, signQType, signTTL, signPlace, toSign, signedRecords, origTTL, packet); + addSignature(dsk, ueber, signer, signQName, wildcardQName, signQType, signTTL, signPlace, toSign, signedRecords, origTTL, packet); rrs.swap(signedRecords); } diff --git a/pdns/dynhandler.cc b/pdns/dynhandler.cc index 2fef06ac1f..074c574caa 100644 --- a/pdns/dynhandler.cc +++ b/pdns/dynhandler.cc @@ -348,8 +348,9 @@ string DLNotifyHandler(const vector& parts, Utility::pid_t /* ppid */) } catch (...) { return "Failed to parse zone as valid DNS name"; } - if(!Communicator.notifyDomain(domain, &B)) + if(!Communicator.notifyDomain(domain, &B)) { return "Failed to add to the queue - see log"; + } return "Added to queue"; } } diff --git a/pdns/ixfrutils.cc b/pdns/ixfrutils.cc index 5babad55f4..43ddadaa1e 100644 --- a/pdns/ixfrutils.cc +++ b/pdns/ixfrutils.cc @@ -31,18 +31,18 @@ #include "zoneparser-tng.hh" #include "dnsparser.hh" -uint32_t getSerialFromPrimary(const ComboAddress& primary, const ZoneName& zone, shared_ptr& sr, const TSIGTriplet& tt, const uint16_t timeout) +uint32_t getSerialFromPrimary(const ComboAddress& primary, const ZoneName& zone, shared_ptr& soarecord, const TSIGTriplet& tsig, const uint16_t timeout) { vector packet; DNSPacketWriter pw(packet, zone, QType::SOA); - if(!tt.algo.empty()) { + if(!tsig.algo.empty()) { TSIGRecordContent trc; - trc.d_algoName = tt.algo; + trc.d_algoName = tsig.algo; trc.d_time = time(nullptr); trc.d_fudge = 300; trc.d_origID=ntohs(pw.getHeader()->id); trc.d_eRcode=0; - addTSIG(pw, trc, tt.name, tt.secret, "", false); + addTSIG(pw, trc, tsig.name, tsig.secret, "", false); } Socket s(primary.sin4.sin_family, SOCK_DGRAM); @@ -66,9 +66,9 @@ uint32_t getSerialFromPrimary(const ComboAddress& primary, const ZoneName& zone, } for(const auto& r: mdp.d_answers) { if(r.d_type == QType::SOA) { - sr = getRR(r); - if(sr != nullptr) { - return sr->d_st.serial; + soarecord = getRR(r); + if(soarecord != nullptr) { + return soarecord->d_st.serial; } } } diff --git a/pdns/ixfrutils.hh b/pdns/ixfrutils.hh index 92579181b2..da22415f3e 100644 --- a/pdns/ixfrutils.hh +++ b/pdns/ixfrutils.hh @@ -56,7 +56,7 @@ typedef multi_index_container < > /* indexed_by */ > /* multi_index_container */ records_t; -uint32_t getSerialFromPrimary(const ComboAddress& primary, const ZoneName& zone, shared_ptr& sr, const TSIGTriplet& tt = TSIGTriplet(), const uint16_t timeout = 2); +uint32_t getSerialFromPrimary(const ComboAddress& primary, const ZoneName& zone, shared_ptr& soarecord, const TSIGTriplet& tsig = 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 ZoneName& zone, const std::string& directory); diff --git a/pdns/ixplore.cc b/pdns/ixplore.cc index bf8bd064af..1421b315b3 100644 --- a/pdns/ixplore.cc +++ b/pdns/ixplore.cc @@ -73,6 +73,7 @@ int main(int argc, char** argv) { } if(command=="diff") { records_t before, after; + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) ZoneName zone(argv[2]); cout<<"Loading before from "<doesDNSSEC()) { NSEC3PARAMRecordContent ns3pr; bool narrow = false; - bool haveNSEC3=dk.getNSEC3PARAM(zone, &ns3pr, &narrow); + bool haveNSEC3=dsk.getNSEC3PARAM(zone, &ns3pr, &narrow); DNSName ordername; if(haveNSEC3) { @@ -2038,7 +2038,7 @@ static void verifyCrypto(const string& zone) } } -static bool disableDNSSECOnZone(DNSSECKeeper& dk, const ZoneName& zone) +static bool disableDNSSECOnZone(DNSSECKeeper& dsk, const ZoneName& zone) { UtilBackend B("default"); //NOLINT(readability-identifier-length) DomainInfo di; @@ -2049,7 +2049,7 @@ static bool disableDNSSECOnZone(DNSSECKeeper& dk, const ZoneName& zone) } string error, info; - bool ret = dk.unSecureZone(zone, error); + bool ret = dsk.unSecureZone(zone, error); if (!ret) { cerr << error << endl; } @@ -2387,7 +2387,7 @@ static bool showZone(DNSSECKeeper& dnsseckeeper, const ZoneName& zone, bool expo return true; } -static bool secureZone(DNSSECKeeper& dk, const ZoneName& zone) +static bool secureZone(DNSSECKeeper& dsk, const ZoneName& zone) { // temp var for addKey int64_t id{-1}; @@ -2410,7 +2410,7 @@ static bool secureZone(DNSSECKeeper& dk, const ZoneName& zone) throw runtime_error("ZSK key size must be equal to or greater than 0"); } - if(dk.isSecuredZone(zone)) { + if(dsk.isSecuredZone(zone)) { cerr << "Zone '"<commitTransaction(); cout<<"Securing zone"<getBeforeAndAfterNames(di.id, zone, DNSName("z")+zone, before, after); diff --git a/pdns/serialtweaker.cc b/pdns/serialtweaker.cc index 4bba4ea5d3..834fe1adfc 100644 --- a/pdns/serialtweaker.cc +++ b/pdns/serialtweaker.cc @@ -79,9 +79,9 @@ uint32_t calculateEditSOA(uint32_t old_serial, const string& kind, const ZoneNam return old_serial; } -uint32_t calculateEditSOA(uint32_t old_serial, DNSSECKeeper& dk, const ZoneName& zonename) { +uint32_t calculateEditSOA(uint32_t old_serial, DNSSECKeeper& dsk, const ZoneName& zonename) { string kind; - dk.getSoaEdit(zonename, kind); + dsk.getSoaEdit(zonename, kind); return calculateEditSOA(old_serial, kind, zonename); } diff --git a/pdns/test-communicator_hh.cc b/pdns/test-communicator_hh.cc index aca5a47d5c..7b3eb70cc2 100644 --- a/pdns/test-communicator_hh.cc +++ b/pdns/test-communicator_hh.cc @@ -74,7 +74,7 @@ BOOST_AUTO_TEST_CASE(test_axfr_queue_insert_and_priority_order_after_modify) {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 = {ZoneName("test3.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::PdnsControl, 5}}; + SuckRequest rr1 = {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; @@ -85,9 +85,9 @@ BOOST_AUTO_TEST_CASE(test_axfr_queue_insert_and_priority_order_after_modify) suckDomains.insert(sr[3]); suckDomains.insert(sr[4]); - auto res = suckDomains.insert(rr); + auto res = suckDomains.insert(rr1); BOOST_CHECK(!res.second); - suckDomains.modify(res.first, [priorityAndOrder = rr.priorityAndOrder](SuckRequest& so) { + suckDomains.modify(res.first, [priorityAndOrder = rr1.priorityAndOrder](SuckRequest& so) { if (priorityAndOrder.first < so.priorityAndOrder.first) { so.priorityAndOrder = priorityAndOrder; } diff --git a/pdns/test-ueberbackend_cc.cc b/pdns/test-ueberbackend_cc.cc index ae94432f98..3b42baa09c 100644 --- a/pdns/test-ueberbackend_cc.cc +++ b/pdns/test-ueberbackend_cc.cc @@ -55,7 +55,7 @@ public: struct SimpleDNSZone { - SimpleDNSZone(const ZoneName& name, uint64_t id): d_records(std::make_shared()), d_name(name), d_id(id) + SimpleDNSZone(ZoneName name, uint64_t domainId): d_records(std::make_shared()), d_name(std::move(name)), d_id(domainId) { } std::shared_ptr d_records; @@ -76,7 +76,7 @@ public: struct SimpleMetaData { - SimpleMetaData(const ZoneName& name, const std::string& kind, const std::vector& values): d_name(name), d_kind(kind), d_values(values) + SimpleMetaData(ZoneName name, std::string kind, std::vector values): d_name(std::move(name)), d_kind(std::move(kind)), d_values(std::move(values)) { } @@ -96,7 +96,7 @@ public: member, member >, - composite_key_compare > + composite_key_compare > > > > MetaDataStorage; @@ -248,7 +248,7 @@ public: { } - bool getAuth(const ZoneName& target, SOAData* sd) override + bool getAuth(const ZoneName& target, SOAData* soadata) override { static const ZoneName best("d.0.1.0.0.2.ip6.arpa."); @@ -268,14 +268,14 @@ public: return false; } - fillSOAData(range.first->d_content, *sd); - sd->ttl = range.first->d_ttl; - sd->qname = best; - sd->domain_id = zoneId; + fillSOAData(range.first->d_content, *soadata); + soadata->ttl = range.first->d_ttl; + soadata->qname = best; + soadata->domain_id = zoneId; return true; } - return getSOA(target, *sd); + return getSOA(target, *soadata); } size_t d_authLookupCount{0}; @@ -1162,11 +1162,11 @@ BOOST_AUTO_TEST_CASE(test_multi_backends_metadata) { { // check that it has not been updated in the second backend - 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"); - BOOST_CHECK_EQUAL(it->d_values.at(1), "value2"); + const auto& iter = SimpleBackend::s_metadata[2].find(std::tuple(ZoneName("powerdns.org."), "test-data-b")); + BOOST_REQUIRE(iter != SimpleBackend::s_metadata[2].end()); + BOOST_REQUIRE_EQUAL(iter->d_values.size(), 2U); + BOOST_CHECK_EQUAL(iter->d_values.at(0), "value1"); + BOOST_CHECK_EQUAL(iter->d_values.at(1), "value2"); } }; diff --git a/pdns/test-zonemd_cc.cc b/pdns/test-zonemd_cc.cc index 0e1a6eff9b..a71d7815db 100644 --- a/pdns/test-zonemd_cc.cc +++ b/pdns/test-zonemd_cc.cc @@ -17,15 +17,15 @@ static void testZoneMD(const std::string& zone, const std::string& file, bool ex if (!p) { p = "."; } - ZoneName z(zone); + ZoneName zonename(zone); std::ostringstream pathbuf; pathbuf << p << "/../regression-tests/zones/" + file; - ZoneParserTNG zpt(pathbuf.str(), z); + ZoneParserTNG zpt(pathbuf.str(), zonename); bool validationDone = false, validationOK = false; try { - auto zonemd = pdns::ZoneMD(z); + auto zonemd = pdns::ZoneMD(zonename); zonemd.readRecords(zpt); zonemd.verify(validationDone, validationOK); } diff --git a/pdns/test-zoneparser_tng_cc.cc b/pdns/test-zoneparser_tng_cc.cc index 6f9db38686..8f710d0a9b 100644 --- a/pdns/test-zoneparser_tng_cc.cc +++ b/pdns/test-zoneparser_tng_cc.cc @@ -26,12 +26,12 @@ BOOST_AUTO_TEST_CASE(test_tng_record_types) { if(!p) p = "."; pathbuf << p << "/../regression-tests/zones/unit.test"; - ZoneParserTNG zp(pathbuf.str(), ZoneName("unit.test")); + ZoneParserTNG zoneparser(pathbuf.str(), ZoneName("unit.test")); DNSResourceRecord rr; ifstream ifs(pathbuf.str()); - while(zp.get(rr)) { + while(zoneparser.get(rr)) { // make sure these concur. std::string host, type, data; unsigned int ttl; @@ -63,7 +63,7 @@ BOOST_AUTO_TEST_CASE(test_tng_record_generate) { { /* simple case */ - ZoneParserTNG zp(pathbuf.str(), ZoneName("unit2.test")); + ZoneParserTNG zoneparser(pathbuf.str(), ZoneName("unit2.test")); const vector expected = { "0.01.0003.000005.00000007.unit2.test.", @@ -87,7 +87,7 @@ BOOST_AUTO_TEST_CASE(test_tng_record_generate) { for (auto const & exp : expected) { DNSResourceRecord rr; - zp.get(rr); + zoneparser.get(rr); BOOST_CHECK_EQUAL(rr.qname.toString(), exp); BOOST_CHECK_EQUAL(rr.ttl, 86400U); BOOST_CHECK_EQUAL(rr.qclass, 1U); @@ -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"}), ZoneName("unit2.test")); + ZoneParserTNG zoneparser(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.", @@ -108,7 +108,7 @@ BOOST_AUTO_TEST_CASE(test_tng_record_generate) { for (auto const & exp : expected) { DNSResourceRecord rr; - zp.get(rr); + zoneparser.get(rr); BOOST_CHECK_EQUAL(rr.qname.toString(), exp); BOOST_CHECK_EQUAL(rr.ttl, 86400U); BOOST_CHECK_EQUAL(rr.qclass, 1U); @@ -117,13 +117,13 @@ BOOST_AUTO_TEST_CASE(test_tng_record_generate) { } { DNSResourceRecord rr; - BOOST_CHECK(!zp.get(rr)); + BOOST_CHECK(!zoneparser.get(rr)); } } { /* 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"}), ZoneName("unit2.test")); + ZoneParserTNG zoneparser(std::vector({"$GENERATE 4294967294-4294967295/2 $ 86400 IN A 1.2.3.4"}), ZoneName("unit2.test")); const vector expected = { "4294967294.unit2.test.", @@ -131,7 +131,7 @@ BOOST_AUTO_TEST_CASE(test_tng_record_generate) { for (auto const & exp : expected) { DNSResourceRecord rr; - zp.get(rr); + zoneparser.get(rr); BOOST_CHECK_EQUAL(rr.qname.toString(), exp); BOOST_CHECK_EQUAL(rr.ttl, 86400U); BOOST_CHECK_EQUAL(rr.qclass, 1U); @@ -140,84 +140,84 @@ BOOST_AUTO_TEST_CASE(test_tng_record_generate) { } { DNSResourceRecord rr; - BOOST_CHECK(!zp.get(rr)); + BOOST_CHECK(!zoneparser.get(rr)); } } { /* 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"}), ZoneName("test")); + ZoneParserTNG zoneparser(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); + BOOST_CHECK_THROW(zoneparser.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"}), ZoneName("test")); + ZoneParserTNG zoneparser(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); + BOOST_CHECK_THROW(zoneparser.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"}), ZoneName("test")); + ZoneParserTNG zoneparser(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); + BOOST_CHECK_THROW(zoneparser.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"}), ZoneName("test")); + ZoneParserTNG zoneparser(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); + BOOST_CHECK_THROW(zoneparser.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"}), ZoneName("test")); + ZoneParserTNG zoneparser(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); + BOOST_CHECK_THROW(zoneparser.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"}), ZoneName("test")); + ZoneParserTNG zoneparser(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); + BOOST_CHECK_THROW(zoneparser.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"}), ZoneName("test")); + ZoneParserTNG zoneparser(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); + BOOST_CHECK_THROW(zoneparser.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"}), ZoneName("test")); + ZoneParserTNG zoneparser(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); + BOOST_CHECK_THROW(zoneparser.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"}), ZoneName("test")); + ZoneParserTNG zoneparser(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); + BOOST_CHECK_THROW(zoneparser.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"}), ZoneName("test")); + ZoneParserTNG zoneparser(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_CHECK_THROW(zoneparser.get(rr), PDNSException); } } BOOST_AUTO_TEST_CASE(test_tng_upgrade) { - ZoneParserTNG zp(std::vector({"foo.test. 86400 IN TYPE1 \\# 4 c0000304"}), ZoneName("test"), true); + ZoneParserTNG zoneparser(std::vector({"foo.test. 86400 IN TYPE1 \\# 4 c0000304"}), ZoneName("test"), true); DNSResourceRecord rr; - zp.get(rr); + zoneparser.get(rr); BOOST_CHECK_EQUAL(rr.qtype.toString(), QType(QType::A).toString()); BOOST_CHECK_EQUAL(rr.content, std::string("192.0.3.4"));