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) {
}
}
-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 (...) {
}
/** 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<recordstorage_t>& 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<recordstorage_t>& 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;
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);
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<BBResourceRecords>
- d_handle.id = id;
+ d_handle.id = domainId;
d_handle.domain = bbd.d_name;
d_handle.d_list = true;
return true;
return true;
}
-bool Bind2Backend::autoPrimaryBackend(const string& ip, const ZoneName& /* domain */, const vector<DNSResourceRecord>& /* nsset */, string* /* nameserver */, string* account, DNSBackend** db)
+bool Bind2Backend::autoPrimaryBackend(const string& ipAddress, const ZoneName& /* domain */, const vector<DNSResourceRecord>& /* nsset */, string* /* nameserver */, string* account, DNSBackend** backend)
{
// Check whether we have a configfile available.
if (getArg("autoprimary-config").empty())
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();
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<std::mutex> l2(s_autosecondary_config_lock);
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);
unsigned int getCapabilities() override;
void getUnfreshSecondaryInfos(vector<DomainInfo>* unfreshDomains) override;
void getUpdatedPrimaries(vector<DomainInfo>& changedDomains, std::unordered_set<DNSName>& 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<DomainInfo>* domains, bool getSerial, bool include_disabled = false) override;
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;
bool getDomainMetadata(const ZoneName& name, const std::string& kind, std::vector<std::string>& meta) override;
bool setDomainMetadata(const ZoneName& name, const std::string& kind, const std::vector<std::string>& meta) override;
bool getDomainKeys(const ZoneName& name, std::vector<KeyData>& 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;
// for autoprimary support
bool autoPrimariesList(std::vector<AutoPrimary>& primaries) override;
- bool autoPrimaryBackend(const string& ip, const ZoneName& domain, const vector<DNSResourceRecord>& nsset, string* nameserver, string* account, DNSBackend** db) override;
+ bool autoPrimaryBackend(const string& ipAddress, const ZoneName& domain, const vector<DNSResourceRecord>& 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();
void queueReloadAndStore(unsigned int id);
static bool findBeforeAndAfterUnhashed(std::shared_ptr<const recordstorage_t>& records, const DNSName& qname, DNSName& unhashed, DNSName& before, DNSName& after);
- static void insertRecord(std::shared_ptr<recordstorage_t>& 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<recordstorage_t>& 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<string>& parts, Utility::pid_t ppid);
static string DLDomExtendedStatusHandler(const vector<string>& parts, Utility::pid_t ppid);
return caps;
}
+// NOLINTNEXTLINE(readability-convert-member-functions-to-static)
bool Bind2Backend::getNSEC3PARAM(const ZoneName& name, NSEC3PARAMRecordContent* ns3p)
{
BB2DomainInfo bbd;
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());
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;
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());
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());
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());
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());
return false;
}
-bool GeoIPBackend::removeDomainKey(const ZoneName& name, unsigned int id)
+bool GeoIPBackend::removeDomainKey(const ZoneName& name, unsigned int keyId)
{
if (!d_dnssec)
return false;
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<unsigned int>(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;
}
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;
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;
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<unsigned int>(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<unsigned int>(glob_result.gl_pathv[i] + regm[2].rm_so) << "." << kid << ".1.key";
if (rename(glob_result.gl_pathv[i], newpath.str().c_str())) {
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;
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<unsigned int>(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<unsigned int>(glob_result.gl_pathv[i] + regm[2].rm_so) << "." << kid << ".0.key";
if (rename(glob_result.gl_pathv[i], newpath.str().c_str())) {
bool getAllDomainMetadata(const ZoneName& name, std::map<std::string, std::vector<std::string>>& meta) override;
bool getDomainMetadata(const ZoneName& name, const std::string& kind, std::vector<std::string>& meta) override;
bool getDomainKeys(const ZoneName& name, std::vector<DNSBackend::KeyData>& 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;
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<DomainInfo>& domains, std::unordered_set<DNSName>& catalogs, CatalogHashMap& catalogHashes) override;
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;
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");
}
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;
}
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);
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();
// 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;
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 "<<name<<" with id "<<id<<", could not find it"<<endl;
+ // cout << "??? wanted to remove domain key for domain "<<name<<" with id "<<keyId<<", could not find it"<<endl;
return true;
}
-bool LMDBBackend::addDomainKey(const ZoneName& name, const KeyData& key, int64_t& id)
+bool LMDBBackend::addDomainKey(const ZoneName& name, const KeyData& key, int64_t& keyId)
{
auto txn = d_tkdb->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();
}
}
- // cout << "??? wanted to activate domain key for domain "<<name<<" with id "<<id<<", could not find it"<<endl;
+ // cout << "??? wanted to activate domain key for domain "<<name<<" with id "<<keyId<<", could not find it"<<endl;
return true;
}
-bool LMDBBackend::deactivateDomainKey(const ZoneName& name, unsigned int id)
+bool LMDBBackend::deactivateDomainKey(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 = false;
});
txn.commit();
return true;
}
}
- // cout << "??? wanted to deactivate domain key for domain "<<name<<" with id "<<id<<", could not find it"<<endl;
+ // cout << "??? wanted to deactivate domain key for domain "<<name<<" with id "<<keyId<<", could not find it"<<endl;
return true;
}
-bool LMDBBackend::publishDomainKey(const ZoneName& name, unsigned int id)
+bool LMDBBackend::publishDomainKey(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.published = true;
});
txn.commit();
}
}
- // cout << "??? wanted to hide domain key for domain "<<name<<" with id "<<id<<", could not find it"<<endl;
+ // cout << "??? wanted to hide domain key for domain "<<name<<" with id "<<keyId<<", could not find it"<<endl;
return true;
}
-bool LMDBBackend::unpublishDomainKey(const ZoneName& name, unsigned int id)
+bool LMDBBackend::unpublishDomainKey(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.published = false;
});
txn.commit();
return true;
}
}
- // cout << "??? wanted to unhide domain key for domain "<<name<<" with id "<<id<<", could not find it"<<endl;
+ // cout << "??? wanted to unhide domain key for domain "<<name<<" with id "<<keyId<<", could not find it"<<endl;
return true;
}
return true;
}
-bool LMDBBackend::getBeforeAndAfterNames(uint32_t id, const ZoneName& zonenameU, const DNSName& qname, DNSName& before, DNSName& after)
+bool LMDBBackend::getBeforeAndAfterNames(uint32_t domainId, const ZoneName& zonenameU, const DNSName& qname, DNSName& before, DNSName& after)
{
ZoneName zonename = zonenameU.makeLowerCase();
- // cout << __PRETTY_FUNCTION__<< ": "<<id <<", "<<zonename << ", '"<<qname<<"'"<<endl;
+ // cout << __PRETTY_FUNCTION__<< ": "<<domainId <<", "<<zonename << ", '"<<qname<<"'"<<endl;
- auto txn = getRecordsROTransaction(id);
+ auto txn = getRecordsROTransaction(domainId);
compoundOrdername co;
DNSName qname2 = qname.makeRelative(zonename);
- string matchkey = co(id, qname2);
+ string matchkey = co(domainId, qname2);
auto cursor = txn->txn->getCursor(txn->db->dbi);
MDBOutVal key, val;
// cout<<"Lower_bound for "<<qname2<<endl;
if (cursor.lower_bound(matchkey, key, val)) {
// cout << "Hit end of database, bummer"<<endl;
cursor.last(key, val);
- if (co.getDomainID(key.getNoStripHeader<string_view>()) == id) {
+ if (co.getDomainID(key.getNoStripHeader<string_view>()) == domainId) {
before = co.getQName(key.getNoStripHeader<string_view>()) + zonename;
after = zonename;
}
}
// cout<<"Cursor is at "<<co.getQName(key.get<string_view>()) <<", in zone id "<<co.getDomainID(key.get<string_view>())<< endl;
- if (co.getQType(key.getNoStripHeader<string_view>()).getCode() && co.getDomainID(key.getNoStripHeader<string_view>()) == id && co.getQName(key.getNoStripHeader<string_view>()) == qname2) { // don't match ENTs
+ if (co.getQType(key.getNoStripHeader<string_view>()).getCode() && co.getDomainID(key.getNoStripHeader<string_view>()) == domainId && co.getQName(key.getNoStripHeader<string_view>()) == qname2) { // don't match ENTs
// cout << "Had an exact match!"<<endl;
before = qname2 + zonename;
int rc;
if (rc)
break;
- if (co.getDomainID(key.getNoStripHeader<string_view>()) == id && key.getNoStripHeader<StringView>().rfind(matchkey, 0) == 0)
+ if (co.getDomainID(key.getNoStripHeader<string_view>()) == domainId && key.getNoStripHeader<StringView>().rfind(matchkey, 0) == 0)
continue;
LMDBResourceRecord lrr;
deserializeFromBuffer(val.get<StringView>(), lrr);
if (co.getQType(key.getNoStripHeader<string_view>()).getCode() && (lrr.auth || co.getQType(key.getNoStripHeader<string_view>()).getCode() == QType::NS))
break;
}
- if (rc || co.getDomainID(key.getNoStripHeader<string_view>()) != id) {
+ if (rc || co.getDomainID(key.getNoStripHeader<string_view>()) != domainId) {
// cout << "We hit the end of the zone or database. 'after' is apex" << endl;
after = zonename;
return false;
return true;
}
- if (co.getDomainID(key.getNoStripHeader<string_view>()) != id) {
+ if (co.getDomainID(key.getNoStripHeader<string_view>()) != domainId) {
// cout << "Ended up in next zone, 'after' is zonename" <<endl;
after = zonename;
// cout << "Now hunting for previous" << endl;
return false;
}
- if (co.getDomainID(key.getNoStripHeader<string_view>()) != id) {
- // cout<<"Reversed into zone, but found wrong zone id " << co.getDomainID(key.getNoStripHeader<string_view>()) << " != "<<id<<endl;
+ if (co.getDomainID(key.getNoStripHeader<string_view>()) != domainId) {
+ // cout<<"Reversed into zone, but found wrong zone id " << co.getDomainID(key.getNoStripHeader<string_view>()) << " != "<<domainId<<endl;
// "this can't happen"
return false;
}
int rc = cursor.next(key, val);
if (!rc)
++skips;
- if (rc || co.getDomainID(key.getNoStripHeader<string_view>()) != id) {
+ if (rc || co.getDomainID(key.getNoStripHeader<string_view>()) != domainId) {
// cout << " oops, hit end of database or zone. This means after is apex" <<endl;
after = zonename;
break;
for (;;) {
int rc = cursor.prev(key, val);
- if (rc || co.getDomainID(key.getNoStripHeader<string_view>()) != id) {
+ if (rc || co.getDomainID(key.getNoStripHeader<string_view>()) != 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;
~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<ComboAddress>& primaries, const string& account) override;
bool startTransaction(const ZoneName& domain, int domain_id = -1) override;
// catalog zones
bool getCatalogMembers(const ZoneName& catalog, vector<CatalogInfo>& 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<ComboAddress>& primaries) override;
bool setKind(const ZoneName& domain, const DomainInfo::DomainKind kind) override;
bool deleteDomain(const ZoneName& domain) override;
bool getDomainKeys(const ZoneName& name, std::vector<KeyData>& 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;
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;
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();
// 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;
}
return true;
}
-bool RemoteBackend::removeDomainKey(const ZoneName& name, unsigned int id)
+bool RemoteBackend::removeDomainKey(const ZoneName& name, unsigned int keyId)
{
// no point doing dnssec if it's not supported
if (!d_dnssec) {
Json query = Json::object{
{"method", "removeDomainKey"},
- {"parameters", Json::object{{"name", name.toString()}, {"id", static_cast<int>(id)}}}};
+ {"parameters", Json::object{{"name", name.toString()}, {"id", static_cast<int>(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) {
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) {
Json query = Json::object{
{"method", "activateDomainKey"},
- {"parameters", Json::object{{"name", name.toString()}, {"id", static_cast<int>(id)}}}};
+ {"parameters", Json::object{{"name", name.toString()}, {"id", static_cast<int>(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) {
Json query = Json::object{
{"method", "deactivateDomainKey"},
- {"parameters", Json::object{{"name", name.toString()}, {"id", static_cast<int>(id)}}}};
+ {"parameters", Json::object{{"name", name.toString()}, {"id", static_cast<int>(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) {
Json query = Json::object{
{"method", "publishDomainKey"},
- {"parameters", Json::object{{"name", name.toString()}, {"id", static_cast<int>(id)}}}};
+ {"parameters", Json::object{{"name", name.toString()}, {"id", static_cast<int>(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) {
Json query = Json::object{
{"method", "unpublishDomainKey"},
- {"parameters", Json::object{{"name", name.toString()}, {"id", static_cast<int>(id)}}}};
+ {"parameters", Json::object{{"name", name.toString()}, {"id", static_cast<int>(keyId)}}}};
Json answer;
return this->send(query) && this->recv(answer);
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;
return false;
}
- this->parseDomainInfo(answer["result"], di);
+ this->parseDomainInfo(answer["result"], info);
return true;
}
}
}
-bool RemoteBackend::autoPrimaryBackend(const string& ip, const ZoneName& domain, const vector<DNSResourceRecord>& nsset, string* nameserver, string* account, DNSBackend** ddb)
+bool RemoteBackend::autoPrimaryBackend(const string& ipAddress, const ZoneName& domain, const vector<DNSResourceRecord>& nsset, string* nameserver, string* account, DNSBackend** ddb)
{
Json::array rrset;
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;
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},
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<std::basic_string<char>>& 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<DNSResourceRecord>& 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<DNSResourceRecord>& 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<DNSResourceRecord>& rrset) override;
bool feedRecord(const DNSResourceRecord& r, const DNSName& ordername, bool ordernameIsNSEC3 = false) override;
bool feedEnts(int domain_id, map<DNSName, bool>& nonterm) override;
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);
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) {
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<string> meta;
DNSName tsigkeyname;
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<uint8_t> 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;
}
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;
}
}
-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;
}
}
-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);
}
return catalogDiff(di, fromXFR, fromDB, logPrefix);
}
-void CommunicatorClass::ixfrSuck(const ZoneName& domain, const TSIGTriplet& tt, const ComboAddress& laddr, const ComboAddress& remote, ZoneStatus& zs, vector<DNSRecord>* axfr)
+void CommunicatorClass::ixfrSuck(const ZoneName& domain, const TSIGTriplet& tsig, const ComboAddress& laddr, const ComboAddress& remote, ZoneStatus& status, vector<DNSRecord>* axfr)
{
string logPrefix = "IXFR-in zone '" + domain.toLogString() + "', primary '" + remote.toString() + "', ";
soatimes drsoa_soatimes = {di.serial, 0, 0, 0, 0};
DNSRecord drsoa;
drsoa.setContent(std::make_shared<SOARecordContent>(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 "<<deltas.size()<<" deltas from serial "<<di.serial<<", applying.."<<endl;
for (const auto& d : deltas) {
if (dr.d_type == QType::SOA) {
// cout<<"New SOA: "<<x.d_content->getZoneRepresentation()<<endl;
auto sr = getRR<SOARecordContent>(dr);
- zs.soa_serial = sr->d_st.serial;
+ status.soa_serial = sr->d_st.serial;
}
replacement.push_back(rr);
logPrefix = "I" + logPrefix; // XFR -> IXFR
vector<DNSRecord> 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
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 */
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<string> 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<<Logger::Notice<<"No serial for '"<<domain<<"' found - zone is missing?"<<endl;
else
- di.serial = sd.serial;
+ info.serial = sd.serial;
}
catch(PDNSException &ae){
g_log<<Logger::Error<<"Error retrieving serial for '"<<domain<<"': "<<ae.reason<<endl;
return true;
}
-bool GSQLBackend::addDomainKey(const ZoneName& name, const KeyData& key, int64_t& id)
+bool GSQLBackend::addDomainKey(const ZoneName& name, const KeyData& key, int64_t& keyId)
{
if(!d_dnssecQueries)
return false;
if (d_AddDomainKeyQuery_stmt->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 {
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;
// 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;
// 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;
// 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;
// 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;
// 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;
}
return true;
}
-bool GSQLBackend::autoPrimaryBackend(const string& ip, const ZoneName& domain, const vector<DNSResourceRecord>& nsset, string* nameserver, string* account, DNSBackend** ddb)
+bool GSQLBackend::autoPrimaryBackend(const string& ipAddress, const ZoneName& domain, const vector<DNSResourceRecord>& nsset, string* nameserver, string* account, DNSBackend** ddb)
{
// check if we know the ip/ns couple in the database
for(const auto & i : nsset) {
// clang-format off
d_AutoPrimaryInfoQuery_stmt->
- bind("ip", ip)->
+ bind("ip", ipAddress)->
bind("nameserver", i.content)->
execute()->
getResult(d_result)->
// 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);
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<ComboAddress> primaries({ComboAddress(ip, 53)});
+ vector<ComboAddress> primaries({ComboAddress(ipAddress, 53)});
try {
if (!nameserver.empty()) {
// figure out all IP addresses for the primary
bool feedEnts(int domain_id, map<DNSName,bool>& nonterm) override;
bool feedEnts3(int domain_id, const DNSName &domain, map<DNSName,bool> &nonterm, const NSEC3PARAMRecordContent& ns3prc, bool narrow) override;
bool createDomain(const ZoneName& domain, const DomainInfo::DomainKind kind, const vector<ComboAddress>& 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<AutoPrimary>& primaries) override;
- bool autoPrimaryBackend(const string& ip, const ZoneName& domain, const vector<DNSResourceRecord>& nsset, string* nameserver, string* account, DNSBackend** db) override;
+ bool autoPrimaryBackend(const string& ipAddress, const ZoneName& domain, const vector<DNSResourceRecord>& 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<DomainInfo>* domains) override;
void getUpdatedPrimaries(vector<DomainInfo>& updatedDomains, std::unordered_set<DNSName>& catalogs, CatalogHashMap& catalogHashes) override;
bool getCatalogMembers(const ZoneName& catalog, vector<CatalogInfo>& 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<ComboAddress>& primaries) override;
bool setKind(const ZoneName &domain, const DomainInfo::DomainKind kind) override;
bool getDomainMetadata(const ZoneName& name, const std::string& kind, std::vector<std::string>& meta) override;
bool setDomainMetadata(const ZoneName& name, const std::string& kind, const std::vector<std::string>& 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;
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<pair<ZoneName, ComboAddress>> getSuckRequests();
size_t getSuckRequestsWaiting();
LockGuarded<map<pair<ZoneName, string>, 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<DNSRecord>* axfr);
+ static void ixfrSuck(const ZoneName& domain, const TSIGTriplet& tsig, const ComboAddress& laddr, const ComboAddress& remote, ZoneStatus& status, vector<DNSRecord>* axfr);
void secondaryRefresh(PacketHandler* P);
void primaryUpdateCheck(PacketHandler* P);
}
-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)
}
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() {
(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
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);
}
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<DNSBackend::KeyData> keys;
d_keymetadb->getDomainKeys(zname, keys);
for(const DNSBackend::KeyData& kd : keys) {
- if(kd.id != id)
+ if(kd.id != keyId)
continue;
DNSKEYRecordContent dkrc;
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)
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;
void incrementHash(std::string& raw);
void decrementHash(std::string& raw);
-void addRRSigs(DNSSECKeeper& dk, UeberBackend& db, const std::set<ZoneName>& authSet, vector<DNSZoneRecord>& rrs, DNSPacket* packet=nullptr);
+void addRRSigs(DNSSECKeeper& dsk, UeberBackend& ueber, const std::set<ZoneName>& authSet, vector<DNSZoneRecord>& 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);
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<std::reference_wrapper<std::vector<std::string>>> 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<std::reference_wrapper<std::vector<std::string>>> 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<DNSZoneRecord>& rrs, uint32_t signTTL, DNSPacket* p=nullptr);
bool isPresigned(const ZoneName& zname, bool useCache=true);
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);
/* 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<RRSIGRecordContent>& rrcs)
{
if(toSign.empty())
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)
}
// 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<DNSZoneRecord>& outsigned, uint32_t origTTL, DNSPacket* packet)
{
if(toSign.empty())
return;
vector<RRSIGRecordContent> rrcs;
- if(dk.isPresigned(signer) || (directDNSKEYSignature && signQType == QType::DNSKEY)) {
+ if(dsk.isPresigned(signer) || (directDNSKEYSignature && signQType == QType::DNSKEY)) {
//cerr<<"Doing presignatures"<<endl;
- dk.getPreRRSIGs(db, outsigned, origTTL, packet); // does it all
+ dsk.getPreRRSIGs(ueber, outsigned, origTTL, packet); // does it all
}
else {
- if(getRRSIGsForRRSET(dk, signer, wildcardname.countLabels() ? wildcardname : signQName, signQType, signTTL, toSign, rrcs) < 0) {
+ if(getRRSIGsForRRSET(dsk, signer, wildcardname.countLabels() ? wildcardname : signQName, signQType, signTTL, toSign, rrcs) < 0) {
// cerr<<"Error signing a record!"<<endl;
return;
}
return std::tie(a.dr.d_place, a.dr.d_type) < std::tie(b.dr.d_place, b.dr.d_type);
}
-static bool getBestAuthFromSet(const set<ZoneName>& authSet, const DNSName& name, ZoneName& auth)
+static bool getBestAuthFromSet(const set<ZoneName>& 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;
}
}
return false;
}
-void addRRSigs(DNSSECKeeper& dk, UeberBackend& db, const set<ZoneName>& authSet, vector<DNSZoneRecord>& rrs, DNSPacket* packet)
+void addRRSigs(DNSSECKeeper& dsk, UeberBackend& ueber, const set<ZoneName>& authSet, vector<DNSZoneRecord>& rrs, DNSPacket* packet)
{
stable_sort(rrs.begin(), rrs.end(), rrsigncomp);
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();
}
}
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);
}
} 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";
}
}
#include "zoneparser-tng.hh"
#include "dnsparser.hh"
-uint32_t getSerialFromPrimary(const ComboAddress& primary, const ZoneName& zone, shared_ptr<const SOARecordContent>& sr, const TSIGTriplet& tt, const uint16_t timeout)
+uint32_t getSerialFromPrimary(const ComboAddress& primary, const ZoneName& zone, shared_ptr<const SOARecordContent>& soarecord, const TSIGTriplet& tsig, const uint16_t timeout)
{
vector<uint8_t> 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);
}
for(const auto& r: mdp.d_answers) {
if(r.d_type == QType::SOA) {
- sr = getRR<SOARecordContent>(r);
- if(sr != nullptr) {
- return sr->d_st.serial;
+ soarecord = getRR<SOARecordContent>(r);
+ if(soarecord != nullptr) {
+ return soarecord->d_st.serial;
}
}
}
> /* indexed_by */
> /* multi_index_container */ records_t;
-uint32_t getSerialFromPrimary(const ComboAddress& primary, const ZoneName& zone, shared_ptr<const SOARecordContent>& sr, const TSIGTriplet& tt = TSIGTriplet(), const uint16_t timeout = 2);
+uint32_t getSerialFromPrimary(const ComboAddress& primary, const ZoneName& zone, shared_ptr<const SOARecordContent>& 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);
}
if(command=="diff") {
records_t before, after;
+ // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
ZoneName zone(argv[2]);
cout<<"Loading before from "<<argv[3]<<endl;
loadZoneFromDisk(before, argv[3], zone);
Next up, loop this every REFRESH seconds */
+ // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
ZoneName zone(argv[4]);
ComboAddress primary(argv[2], atoi(argv[3]));
string directory(argv[5]);
return EXIT_FAILURE;
}
-static bool rectifyZone(DNSSECKeeper& dk, const ZoneName& zone, bool quiet = false, bool rectifyTransaction = true)
+static bool rectifyZone(DNSSECKeeper& dsk, const ZoneName& zone, bool quiet = false, bool rectifyTransaction = true)
{
string output;
string error;
- bool ret = dk.rectifyZone(zone, error, output, rectifyTransaction);
+ bool ret = dsk.rectifyZone(zone, error, output, rectifyTransaction);
if (!quiet || !ret) {
// When quiet, only print output if there was an error
if (!output.empty()) {
return EXIT_FAILURE;
}
-static int increaseSerial(const ZoneName& zone, DNSSECKeeper &dk)
+static int increaseSerial(const ZoneName& zone, DNSSECKeeper &dsk)
{
UtilBackend B("default"); //NOLINT(readability-identifier-length)
SOAData sd;
return -1;
}
- if (dk.isPresigned(zone)) {
+ if (dsk.isPresigned(zone)) {
cerr<<"Serial increase of presigned zone '"<<zone<<"' is not allowed."<<endl;
return -1;
}
}
string soaEditKind;
- dk.getSoaEdit(zone, soaEditKind);
+ dsk.getSoaEdit(zone, soaEditKind);
DNSResourceRecord rr;
makeIncreasedSOARecord(sd, "SOA-EDIT-INCREASE", soaEditKind, rr);
if (sd.db->doesDNSSEC()) {
NSEC3PARAMRecordContent ns3pr;
bool narrow = false;
- bool haveNSEC3=dk.getNSEC3PARAM(zone, &ns3pr, &narrow);
+ bool haveNSEC3=dsk.getNSEC3PARAM(zone, &ns3pr, &narrow);
DNSName ordername;
if(haveNSEC3) {
}
}
-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;
}
string error, info;
- bool ret = dk.unSecureZone(zone, error);
+ bool ret = dsk.unSecureZone(zone, error);
if (!ret) {
cerr << error << endl;
}
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};
throw runtime_error("ZSK key size must be equal to or greater than 0");
}
- if(dk.isSecuredZone(zone)) {
+ if(dsk.isSecuredZone(zone)) {
cerr << "Zone '"<<zone<<"' already secure, remove keys with pdnsutil remove-zone-key if needed"<<endl;
return false;
}
int k_real_algo = DNSSECKeeper::shorthand2algorithm(k_algo);
- if (!dk.addKey(zone, true, k_real_algo, id, k_size, true, true)) {
+ if (!dsk.addKey(zone, true, k_real_algo, id, k_size, true, true)) {
cerr<<"No backend was able to secure '"<<zone<<"', most likely because no DNSSEC"<<endl;
cerr<<"capable backends are loaded, or because the backends have DNSSEC disabled."<<endl;
cerr<<"For the Generic SQL backends, set the 'gsqlite3-dnssec', 'gmysql-dnssec' or"<<endl;
int z_real_algo = DNSSECKeeper::shorthand2algorithm(z_algo);
- if (!dk.addKey(zone, false, z_real_algo, id, z_size, true, true)) {
+ if (!dsk.addKey(zone, false, z_real_algo, id, z_size, true, true)) {
cerr<<"No backend was able to secure '"<<zone<<"', most likely because no DNSSEC"<<endl;
cerr<<"capable backends are loaded, or because the backends have DNSSEC disabled."<<endl;
cerr<<"For the Generic SQL backends, set the 'gsqlite3-dnssec', 'gmysql-dnssec' or"<<endl;
}
}
- if(!dk.isSecuredZone(zone)) {
+ if(!dsk.isSecuredZone(zone)) {
cerr<<"Failed to secure zone. Is your backend dnssec enabled? (set "<<endl;
cerr<<"gsqlite3-dnssec, or gmysql-dnssec etc). Check this first."<<endl;
cerr<<"If you run with the BIND backend, make sure you have configured"<<endl;
return false;
}
- // rectifyZone(dk, zone);
- // showZone(dk, zone);
+ // rectifyZone(dsk, zone);
+ // showZone(dsk, zone);
cout<<"Zone "<<zone<<" secured"<<endl;
return true;
}
-static int testSchema(DNSSECKeeper& dk, const ZoneName& zone)
+static int testSchema(DNSSECKeeper& dsk, const ZoneName& zone)
{
cout<<"Note: test-schema will try to create the zone, but it will not remove it."<<endl;
cout<<"Please clean up after this."<<endl;
db->commitTransaction();
cout<<"Securing zone"<<endl;
- secureZone(dk, zone);
+ secureZone(dsk, zone);
cout<<"Rectifying zone"<<endl;
- rectifyZone(dk, zone);
+ rectifyZone(dsk, zone);
cout<<"Checking underscore ordering"<<endl;
DNSName before, after;
db->getBeforeAndAfterNames(di.id, zone, DNSName("z")+zone, before, after);
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);
}
{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;
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;
}
struct SimpleDNSZone
{
- SimpleDNSZone(const ZoneName& name, uint64_t id): d_records(std::make_shared<RecordStorage>()), d_name(name), d_id(id)
+ SimpleDNSZone(ZoneName name, uint64_t domainId): d_records(std::make_shared<RecordStorage>()), d_name(std::move(name)), d_id(domainId)
{
}
std::shared_ptr<RecordStorage> d_records;
struct SimpleMetaData
{
- SimpleMetaData(const ZoneName& name, const std::string& kind, const std::vector<std::string>& values): d_name(name), d_kind(kind), d_values(values)
+ SimpleMetaData(ZoneName name, std::string kind, std::vector<std::string> values): d_name(std::move(name)), d_kind(std::move(kind)), d_values(std::move(values))
{
}
member<SimpleMetaData, ZoneName, &SimpleMetaData::d_name>,
member<SimpleMetaData, std::string, &SimpleMetaData::d_kind>
>,
- composite_key_compare<CanonZoneNameCompare, std::less<std::string> >
+ composite_key_compare<CanonZoneNameCompare, std::less<> >
>
>
> MetaDataStorage;
{
}
- 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.");
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};
{
// 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");
}
};
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);
}
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;
{
/* simple case */
- ZoneParserTNG zp(pathbuf.str(), ZoneName("unit2.test"));
+ ZoneParserTNG zoneparser(pathbuf.str(), ZoneName("unit2.test"));
const vector<string> expected = {
"0.01.0003.000005.00000007.unit2.test.",
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);
{
/* GENERATE with a step of 2, and the template radix defaulting to 'd' */
- ZoneParserTNG zp(std::vector<std::string>({"$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<std::string>({"$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<string> expected = {
"0.01.0003.000005.00000007.unit2.test.",
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);
}
{
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<std::string>({"$GENERATE 4294967294-4294967295/2 $ 86400 IN A 1.2.3.4"}), ZoneName("unit2.test"));
+ ZoneParserTNG zoneparser(std::vector<std::string>({"$GENERATE 4294967294-4294967295/2 $ 86400 IN A 1.2.3.4"}), ZoneName("unit2.test"));
const vector<string> expected = {
"4294967294.unit2.test.",
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);
}
{
DNSResourceRecord rr;
- BOOST_CHECK(!zp.get(rr));
+ BOOST_CHECK(!zoneparser.get(rr));
}
}
{
/* test invalid generate parameters: stop greater than start */
- ZoneParserTNG zp(std::vector<std::string>({"$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<std::string>({"$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<std::string>({"$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<std::string>({"$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<std::string>({"$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<std::string>({"$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<std::string>({"$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<std::string>({"$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<std::string>({"$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<std::string>({"$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<std::string>({"$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<std::string>({"$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<std::string>({"$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<std::string>({"$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<std::string>({"$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<std::string>({"$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<std::string>({"$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<std::string>({"$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<std::string>({"$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<std::string>({"$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<std::string>({"foo.test. 86400 IN TYPE1 \\# 4 c0000304"}), ZoneName("test"), true);
+ ZoneParserTNG zoneparser(std::vector<std::string>({"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"));