return true;
}
-bool Bind2Backend::safeGetBBDomainInfo(const DNSName& name, BB2DomainInfo* bbd)
+bool Bind2Backend::safeGetBBDomainInfo(const ZoneName& name, BB2DomainInfo* bbd)
{
auto state = s_state.read_lock();
const auto& nameindex = boost::multi_index::get<NameTag>(*state);
return true;
}
-bool Bind2Backend::safeRemoveBBDomainInfo(const DNSName& name)
+bool Bind2Backend::safeRemoveBBDomainInfo(const ZoneName& name)
{
auto state = s_state.write_lock();
using nameindex_t = state_t::index<NameTag>::type;
setLastCheck(domain_id, time(nullptr));
}
-bool Bind2Backend::startTransaction(const DNSName& qname, int id)
+bool Bind2Backend::startTransaction(const ZoneName& qname, int id)
{
if (id < 0) {
d_transaction_tmpname.clear();
}
}
-bool Bind2Backend::getDomainInfo(const DNSName& domain, DomainInfo& di, bool getSerial)
+bool Bind2Backend::getDomainInfo(const ZoneName& domain, DomainInfo& di, bool getSerial)
{
BB2DomainInfo bbd;
if (!safeGetBBDomainInfo(domain, &bbd))
return true;
}
-void Bind2Backend::alsoNotifies(const DNSName& domain, set<string>* ips)
+void Bind2Backend::alsoNotifies(const ZoneName& domain, set<string>* ips)
{
// combine global list with local list
for (const auto& i : this->alsoNotify) {
/** 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 DNSName& zoneName, const DNSName& qname, const QType& qtype, const string& content, int ttl, const std::string& hashed, bool* auth)
+void Bind2Backend::insertRecord(std::shared_ptr<recordstorage_t>& records, const ZoneName& zoneName, const DNSName& qname, const QType& qtype, const string& content, int ttl, const std::string& hashed, bool* auth)
{
Bind2DNSRecord bdr;
bdr.qname = qname;
for (auto i = parts.begin() + 1; i < parts.end(); ++i) {
BB2DomainInfo bbd;
- DNSName zone(*i);
+ ZoneName zone(*i);
if (safeGetBBDomainInfo(zone, &bbd)) {
Bind2Backend bb2;
bb2.queueReloadAndStore(bbd.d_id);
if (parts.size() > 1) {
for (auto i = parts.begin() + 1; i < parts.end(); ++i) {
BB2DomainInfo bbd;
- if (safeGetBBDomainInfo(DNSName(*i), &bbd)) {
+ if (safeGetBBDomainInfo(ZoneName(*i), &bbd)) {
ret << *i << ": " << (bbd.d_loaded ? "" : "[rejected]") << "\t" << bbd.d_status << "\n";
}
else {
if (parts.size() > 1) {
for (auto i = parts.begin() + 1; i < parts.end(); ++i) {
BB2DomainInfo bbd;
- if (safeGetBBDomainInfo(DNSName(*i), &bbd)) {
+ if (safeGetBBDomainInfo(ZoneName(*i), &bbd)) {
printDomainExtendedStatus(ret, bbd);
}
else {
if (parts.size() < 3)
return "ERROR: Domain name and zone filename are required";
- DNSName domainname(parts[1]);
+ ZoneName domainname(parts[1]);
const string& filename = parts[2];
BB2DomainInfo bbd;
if (safeGetBBDomainInfo(domainname, &bbd))
}
}
-void Bind2Backend::fixupOrderAndAuth(std::shared_ptr<recordstorage_t>& records, const DNSName& zoneName, bool nsec3zone, const NSEC3PARAMRecordContent& ns3pr)
+void Bind2Backend::fixupOrderAndAuth(std::shared_ptr<recordstorage_t>& records, const ZoneName& zoneName, bool nsec3zone, const NSEC3PARAMRecordContent& ns3pr)
{
bool skip;
DNSName shorter;
}
}
-void Bind2Backend::doEmptyNonTerminals(std::shared_ptr<recordstorage_t>& records, const DNSName& zoneName, bool nsec3zone, const NSEC3PARAMRecordContent& ns3pr)
+void Bind2Backend::doEmptyNonTerminals(std::shared_ptr<recordstorage_t>& records, const ZoneName& zoneName, bool nsec3zone, const NSEC3PARAMRecordContent& ns3pr)
{
bool auth = false;
DNSName shorter;
g_log << Logger::Warning << d_logprefix << " Parsing " << domains.size() << " domain(s), will report when done" << endl;
- set<DNSName> oldnames, newnames;
+ set<ZoneName> oldnames;
+ set<ZoneName> newnames;
{
auto state = s_state.read_lock();
for (const BB2DomainInfo& bbd : *state) {
safePutBBDomainInfo(bbd);
}
}
- vector<DNSName> diff;
+ vector<ZoneName> diff;
set_difference(oldnames.begin(), oldnames.end(), newnames.begin(), newnames.end(), back_inserter(diff));
unsigned int remdomains = diff.size();
- for (const DNSName& name : diff) {
+ for (const ZoneName& name : diff) {
safeRemoveBBDomainInfo(name);
}
static bool mustlog = ::arg().mustDo("query-logging");
bool found = false;
- DNSName domain;
+ ZoneName domain;
BB2DomainInfo bbd;
if (mustlog)
return true;
}
-bool Bind2Backend::list(const DNSName& /* target */, int id, bool /* include_disabled */)
+bool Bind2Backend::list(const ZoneName& /* target */, int id, bool /* include_disabled */)
{
BB2DomainInfo bbd;
return true;
}
-bool Bind2Backend::autoPrimaryBackend(const string& ip, const DNSName& /* domain */, const vector<DNSResourceRecord>& /* nsset */, string* /* nameserver */, string* account, DNSBackend** db)
+bool Bind2Backend::autoPrimaryBackend(const string& ip, const ZoneName& /* domain */, const vector<DNSResourceRecord>& /* nsset */, string* /* nameserver */, string* account, DNSBackend** db)
{
// Check whether we have a configfile available.
if (getArg("autoprimary-config").empty())
return true;
}
-BB2DomainInfo Bind2Backend::createDomainEntry(const DNSName& domain, const string& filename)
+BB2DomainInfo Bind2Backend::createDomainEntry(const ZoneName& domain, const string& filename)
{
int newid = 1;
{ // Find a free zone id nr.
return bbd;
}
-bool Bind2Backend::createSecondaryDomain(const string& ip, const DNSName& domain, const string& /* nameserver */, const string& account)
+bool Bind2Backend::createSecondaryDomain(const string& ip, const ZoneName& domain, const string& /* nameserver */, const string& account)
{
string filename = getArg("autoprimary-destdir") + '/' + domain.toStringNoDot();
return d_checkinterval;
}
- DNSName d_name; //!< actual name of the domain
+ ZoneName d_name; //!< actual name of the domain
DomainInfo::DomainKind d_kind{DomainInfo::Native}; //!< the kind of domain
string d_filename; //!< full absolute filename of the zone on disk
string d_status; //!< message describing status of a domain, for human consumption
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 DNSName& domain, DomainInfo& di, bool getSerial = true) override;
+ bool getDomainInfo(const ZoneName& domain, DomainInfo& di, bool getSerial = true) override;
time_t getCtime(const string& fname);
// DNSSEC
bool getBeforeAndAfterNamesAbsolute(uint32_t id, const DNSName& qname, DNSName& unhashed, DNSName& before, DNSName& after) override;
void lookup(const QType&, const DNSName& qdomain, int zoneId, DNSPacket* p = nullptr) override;
- bool list(const DNSName& target, int id, bool include_disabled = false) override;
+ bool list(const ZoneName& target, int id, bool include_disabled = false) override;
bool get(DNSResourceRecord&) override;
void getAllDomains(vector<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 DNSName& qname, int id) override;
+ bool startTransaction(const ZoneName& qname, int id) override;
bool feedRecord(const DNSResourceRecord& rr, const DNSName& ordername, bool ordernameIsNSEC3 = false) override;
bool commitTransaction() override;
bool abortTransaction() override;
- void alsoNotifies(const DNSName& domain, set<string>* ips) override;
+ void alsoNotifies(const ZoneName& domain, set<string>* ips) override;
bool searchRecords(const string& pattern, size_t maxResults, vector<DNSResourceRecord>& result) override;
// the DNSSEC related (getDomainMetadata has broader uses too)
- bool getAllDomainMetadata(const DNSName& name, std::map<std::string, std::vector<std::string>>& meta) override;
- bool getDomainMetadata(const DNSName& name, const std::string& kind, std::vector<std::string>& meta) override;
- bool setDomainMetadata(const DNSName& name, const std::string& kind, const std::vector<std::string>& meta) override;
- bool getDomainKeys(const DNSName& name, std::vector<KeyData>& keys) override;
- bool removeDomainKey(const DNSName& name, unsigned int id) override;
- bool addDomainKey(const DNSName& name, const KeyData& key, int64_t& id) override;
- bool activateDomainKey(const DNSName& name, unsigned int id) override;
- bool deactivateDomainKey(const DNSName& name, unsigned int id) override;
- bool publishDomainKey(const DNSName& name, unsigned int id) override;
- bool unpublishDomainKey(const DNSName& name, unsigned int id) override;
+ bool getAllDomainMetadata(const ZoneName& name, std::map<std::string, std::vector<std::string>>& meta) 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 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;
typedef multi_index_container<BB2DomainInfo,
indexed_by<ordered_unique<member<BB2DomainInfo, unsigned int, &BB2DomainInfo::d_id>>,
- ordered_unique<tag<NameTag>, member<BB2DomainInfo, DNSName, &BB2DomainInfo::d_name>>>>
+ ordered_unique<tag<NameTag>, member<BB2DomainInfo, ZoneName, &BB2DomainInfo::d_name>>>>
state_t;
static SharedLockGuarded<state_t> s_state;
// for autoprimary support
bool autoPrimariesList(std::vector<AutoPrimary>& primaries) override;
- bool autoPrimaryBackend(const string& ip, const DNSName& domain, const vector<DNSResourceRecord>& nsset, string* nameserver, string* account, DNSBackend** db) override;
+ bool autoPrimaryBackend(const string& ip, const ZoneName& domain, const vector<DNSResourceRecord>& nsset, string* nameserver, string* account, DNSBackend** db) override;
static std::mutex s_autosecondary_config_lock;
- bool createSecondaryDomain(const string& ip, const DNSName& domain, const string& nameserver, const string& account) override;
+ bool createSecondaryDomain(const string& ip, const ZoneName& domain, const string& nameserver, const string& account) override;
private:
void setupDNSSEC();
void freeStatements();
static bool safeGetBBDomainInfo(int id, BB2DomainInfo* bbd);
static void safePutBBDomainInfo(const BB2DomainInfo& bbd);
- static bool safeGetBBDomainInfo(const DNSName& name, BB2DomainInfo* bbd);
- static bool safeRemoveBBDomainInfo(const DNSName& name);
+ static bool safeGetBBDomainInfo(const ZoneName& name, BB2DomainInfo* bbd);
+ static bool safeRemoveBBDomainInfo(const ZoneName& name);
shared_ptr<SSQLite3> d_dnssecdb;
- bool getNSEC3PARAM(const DNSName& name, NSEC3PARAMRecordContent* ns3p);
+ bool getNSEC3PARAM(const ZoneName& name, NSEC3PARAMRecordContent* ns3p);
void setLastCheck(uint32_t domain_id, time_t lastcheck);
- bool getNSEC3PARAMuncached(const DNSName& name, NSEC3PARAMRecordContent* ns3p);
+ bool getNSEC3PARAMuncached(const ZoneName& name, NSEC3PARAMRecordContent* ns3p);
class handle
{
public:
recordstorage_t::const_iterator d_qname_iter, d_qname_end;
DNSName qname;
- DNSName domain;
+ ZoneName domain;
int id{-1};
QType qtype;
unique_ptr<SSqlStatement> d_deleteTSIGKeyQuery_stmt;
unique_ptr<SSqlStatement> d_getTSIGKeysQuery_stmt;
- DNSName d_transaction_qname;
+ ZoneName d_transaction_qname;
string d_transaction_tmpname;
string d_logprefix;
set<string> alsoNotify; //!< this is used to store the also-notify list of interested peers.
bool d_hybrid;
bool d_upgradeContent;
- BB2DomainInfo createDomainEntry(const DNSName& domain, const string& filename); //!< does not insert in s_state
+ BB2DomainInfo createDomainEntry(const ZoneName& domain, const string& filename); //!< does not insert in s_state
void queueReloadAndStore(unsigned int id);
static bool findBeforeAndAfterUnhashed(std::shared_ptr<const recordstorage_t>& records, const DNSName& qname, DNSName& unhashed, DNSName& before, DNSName& after);
- static void insertRecord(std::shared_ptr<recordstorage_t>& records, const DNSName& zoneName, const DNSName& qname, const QType& qtype, const string& content, int ttl, const std::string& hashed = string(), bool* auth = nullptr);
+ static void insertRecord(std::shared_ptr<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);
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);
static string DLListRejectsHandler(const vector<string>& parts, Utility::pid_t ppid);
static string DLReloadNowHandler(const vector<string>& parts, Utility::pid_t ppid);
static string DLAddDomainHandler(const vector<string>& parts, Utility::pid_t ppid);
- static void fixupOrderAndAuth(std::shared_ptr<recordstorage_t>& records, const DNSName& zoneName, bool nsec3zone, const NSEC3PARAMRecordContent& ns3pr);
- static void doEmptyNonTerminals(std::shared_ptr<recordstorage_t>& records, const DNSName& zoneName, bool nsec3zone, const NSEC3PARAMRecordContent& ns3pr);
+ static void fixupOrderAndAuth(std::shared_ptr<recordstorage_t>& records, const ZoneName& zoneName, bool nsec3zone, const NSEC3PARAMRecordContent& ns3pr);
+ static void doEmptyNonTerminals(std::shared_ptr<recordstorage_t>& records, const ZoneName& zoneName, bool nsec3zone, const NSEC3PARAMRecordContent& ns3pr);
void loadConfig(string* status = nullptr);
};
return caps;
}
-bool Bind2Backend::getNSEC3PARAM(const DNSName& /* name */, NSEC3PARAMRecordContent* /* ns3p */)
+bool Bind2Backend::getNSEC3PARAM(const ZoneName& /* name */, NSEC3PARAMRecordContent* /* ns3p */)
{
return false;
}
-bool Bind2Backend::getNSEC3PARAMuncached(const DNSName& /* name */, NSEC3PARAMRecordContent* /* ns3p */)
+bool Bind2Backend::getNSEC3PARAMuncached(const ZoneName& /* name */, NSEC3PARAMRecordContent* /* ns3p */)
{
return false;
}
-bool Bind2Backend::getAllDomainMetadata(const DNSName& /* name */, std::map<std::string, std::vector<std::string>>& /* meta */)
+bool Bind2Backend::getAllDomainMetadata(const ZoneName& /* name */, std::map<std::string, std::vector<std::string>>& /* meta */)
{
return false;
}
-bool Bind2Backend::getDomainMetadata(const DNSName& /* name */, const std::string& /* kind */, std::vector<std::string>& /* meta */)
+bool Bind2Backend::getDomainMetadata(const ZoneName& /* name */, const std::string& /* kind */, std::vector<std::string>& /* meta */)
{
return false;
}
-bool Bind2Backend::setDomainMetadata(const DNSName& /* name */, const std::string& /* kind */, const std::vector<std::string>& /* meta */)
+bool Bind2Backend::setDomainMetadata(const ZoneName& /* name */, const std::string& /* kind */, const std::vector<std::string>& /* meta */)
{
return false;
}
-bool Bind2Backend::getDomainKeys(const DNSName& /* name */, std::vector<KeyData>& /* keys */)
+bool Bind2Backend::getDomainKeys(const ZoneName& /* name */, std::vector<KeyData>& /* keys */)
{
return false;
}
-bool Bind2Backend::removeDomainKey(const DNSName& /* name */, unsigned int /* id */)
+bool Bind2Backend::removeDomainKey(const ZoneName& /* name */, unsigned int /* id */)
{
return false;
}
-bool Bind2Backend::addDomainKey(const DNSName& /* name */, const KeyData& /* key */, int64_t& /* id */)
+bool Bind2Backend::addDomainKey(const ZoneName& /* name */, const KeyData& /* key */, int64_t& /* id */)
{
return false;
}
-bool Bind2Backend::activateDomainKey(const DNSName& /* name */, unsigned int /* id */)
+bool Bind2Backend::activateDomainKey(const ZoneName& /* name */, unsigned int /* id */)
{
return false;
}
-bool Bind2Backend::deactivateDomainKey(const DNSName& /* name */, unsigned int /* id */)
+bool Bind2Backend::deactivateDomainKey(const ZoneName& /* name */, unsigned int /* id */)
{
return false;
}
-bool Bind2Backend::publishDomainKey(const DNSName& /* name */, unsigned int /* id */)
+bool Bind2Backend::publishDomainKey(const ZoneName& /* name */, unsigned int /* id */)
{
return false;
}
-bool Bind2Backend::unpublishDomainKey(const DNSName& /* name */, unsigned int /* id */)
+bool Bind2Backend::unpublishDomainKey(const ZoneName& /* name */, unsigned int /* id */)
{
return false;
}
return caps;
}
-bool Bind2Backend::getNSEC3PARAM(const DNSName& name, NSEC3PARAMRecordContent* ns3p)
+bool Bind2Backend::getNSEC3PARAM(const ZoneName& name, NSEC3PARAMRecordContent* ns3p)
{
BB2DomainInfo bbd;
if (!safeGetBBDomainInfo(name, &bbd))
return bbd.d_nsec3zone;
}
-bool Bind2Backend::getNSEC3PARAMuncached(const DNSName& name, NSEC3PARAMRecordContent* ns3p)
+bool Bind2Backend::getNSEC3PARAMuncached(const ZoneName& name, NSEC3PARAMRecordContent* ns3p)
{
if (!d_dnssecdb || d_hybrid)
return false;
return true;
}
-bool Bind2Backend::getAllDomainMetadata(const DNSName& name, std::map<std::string, std::vector<std::string>>& meta)
+bool Bind2Backend::getAllDomainMetadata(const ZoneName& name, std::map<std::string, std::vector<std::string>>& meta)
{
if (!d_dnssecdb || d_hybrid)
return false;
return true;
}
-bool Bind2Backend::getDomainMetadata(const DNSName& name, const std::string& kind, std::vector<std::string>& meta)
+bool Bind2Backend::getDomainMetadata(const ZoneName& name, const std::string& kind, std::vector<std::string>& meta)
{
if (!d_dnssecdb || d_hybrid)
return false;
return true;
}
-bool Bind2Backend::setDomainMetadata(const DNSName& name, const std::string& kind, const std::vector<std::string>& meta)
+bool Bind2Backend::setDomainMetadata(const ZoneName& name, const std::string& kind, const std::vector<std::string>& meta)
{
if (!d_dnssecdb || d_hybrid)
return false;
return true;
}
-bool Bind2Backend::getDomainKeys(const DNSName& name, std::vector<KeyData>& keys)
+bool Bind2Backend::getDomainKeys(const ZoneName& name, std::vector<KeyData>& keys)
{
if (!d_dnssecdb || d_hybrid)
return false;
return true;
}
-bool Bind2Backend::removeDomainKey(const DNSName& name, unsigned int id)
+bool Bind2Backend::removeDomainKey(const ZoneName& name, unsigned int id)
{
if (!d_dnssecdb || d_hybrid)
return false;
return true;
}
-bool Bind2Backend::addDomainKey(const DNSName& name, const KeyData& key, int64_t& id)
+bool Bind2Backend::addDomainKey(const ZoneName& name, const KeyData& key, int64_t& id)
{
if (!d_dnssecdb || d_hybrid)
return false;
}
}
-bool Bind2Backend::activateDomainKey(const DNSName& name, unsigned int id)
+bool Bind2Backend::activateDomainKey(const ZoneName& name, unsigned int id)
{
if (!d_dnssecdb || d_hybrid)
return false;
return true;
}
-bool Bind2Backend::deactivateDomainKey(const DNSName& name, unsigned int id)
+bool Bind2Backend::deactivateDomainKey(const ZoneName& name, unsigned int id)
{
if (!d_dnssecdb || d_hybrid)
return false;
return true;
}
-bool Bind2Backend::publishDomainKey(const DNSName& name, unsigned int id)
+bool Bind2Backend::publishDomainKey(const ZoneName& name, unsigned int id)
{
if (!d_dnssecdb || d_hybrid)
return false;
return true;
}
-bool Bind2Backend::unpublishDomainKey(const DNSName& name, unsigned int id)
+bool Bind2Backend::unpublishDomainKey(const ZoneName& name, unsigned int id)
{
if (!d_dnssecdb || d_hybrid)
return false;
struct GeoIPDomain
{
std::uint32_t id{};
- DNSName domain;
+ ZoneName domain;
int ttl{};
map<DNSName, GeoIPService> services;
map<DNSName, vector<GeoIPDNSResourceRecord>> records;
reload();
}
-bool GeoIPBackend::getDomainInfo(const DNSName& domain, DomainInfo& di, bool /* getSerial */)
+bool GeoIPBackend::getDomainInfo(const ZoneName& domain, DomainInfo& di, bool /* getSerial */)
{
ReadLock rl(&s_state_lock);
}
}
-bool GeoIPBackend::getAllDomainMetadata(const DNSName& name, std::map<std::string, std::vector<std::string>>& meta)
+bool GeoIPBackend::getAllDomainMetadata(const ZoneName& name, std::map<std::string, std::vector<std::string>>& meta)
{
if (!d_dnssec)
return false;
return false;
}
-bool GeoIPBackend::getDomainMetadata(const DNSName& name, const std::string& kind, std::vector<std::string>& meta)
+bool GeoIPBackend::getDomainMetadata(const ZoneName& name, const std::string& kind, std::vector<std::string>& meta)
{
if (!d_dnssec)
return false;
return false;
}
-bool GeoIPBackend::getDomainKeys(const DNSName& name, std::vector<DNSBackend::KeyData>& keys)
+bool GeoIPBackend::getDomainKeys(const ZoneName& name, std::vector<DNSBackend::KeyData>& keys)
{
if (!d_dnssec)
return false;
return false;
}
-bool GeoIPBackend::removeDomainKey(const DNSName& name, unsigned int id)
+bool GeoIPBackend::removeDomainKey(const ZoneName& name, unsigned int id)
{
if (!d_dnssec)
return false;
return false;
}
-bool GeoIPBackend::addDomainKey(const DNSName& name, const KeyData& key, int64_t& id)
+bool GeoIPBackend::addDomainKey(const ZoneName& name, const KeyData& key, int64_t& id)
{
if (!d_dnssec)
return false;
return false;
}
-bool GeoIPBackend::activateDomainKey(const DNSName& name, unsigned int id)
+bool GeoIPBackend::activateDomainKey(const ZoneName& name, unsigned int id)
{
if (!d_dnssec)
return false;
return false;
}
-bool GeoIPBackend::deactivateDomainKey(const DNSName& name, unsigned int id)
+bool GeoIPBackend::deactivateDomainKey(const ZoneName& name, unsigned int id)
{
if (!d_dnssec)
return false;
return false;
}
-bool GeoIPBackend::publishDomainKey(const DNSName& /* name */, unsigned int /* id */)
+bool GeoIPBackend::publishDomainKey(const ZoneName& /* name */, unsigned int /* id */)
{
return false;
}
-bool GeoIPBackend::unpublishDomainKey(const DNSName& /* name */, unsigned int /* id */)
+bool GeoIPBackend::unpublishDomainKey(const ZoneName& /* name */, unsigned int /* id */)
{
return false;
}
-bool GeoIPBackend::hasDNSSECkey(const DNSName& name)
+bool GeoIPBackend::hasDNSSECkey(const ZoneName& name)
{
ostringstream pathname;
pathname << getArg("dnssec-keydir") << "/" << name.toStringNoDot() << "*.key";
}
void lookup(const QType& qtype, const DNSName& qdomain, int zoneId, DNSPacket* pkt_p = nullptr) override;
- bool list(const DNSName& /* target */, int /* domain_id */, bool /* include_disabled */ = false) override { return false; } // not supported
+ bool list(const ZoneName& /* target */, int /* domain_id */, bool /* include_disabled */ = false) override { return false; } // not supported
bool get(DNSResourceRecord& r) override;
void reload() override;
void rediscover(string* status = nullptr) override;
- bool getDomainInfo(const DNSName& domain, DomainInfo& di, bool getSerial = true) override;
+ bool getDomainInfo(const ZoneName& domain, DomainInfo& di, bool getSerial = true) override;
void getAllDomains(vector<DomainInfo>* domains, bool getSerial, bool include_disabled) override;
// dnssec support
- bool getAllDomainMetadata(const DNSName& name, std::map<std::string, std::vector<std::string>>& meta) override;
- bool getDomainMetadata(const DNSName& name, const std::string& kind, std::vector<std::string>& meta) override;
- bool getDomainKeys(const DNSName& name, std::vector<DNSBackend::KeyData>& keys) override;
- bool removeDomainKey(const DNSName& name, unsigned int id) override;
- bool addDomainKey(const DNSName& name, const KeyData& key, int64_t& id) override;
- bool activateDomainKey(const DNSName& name, unsigned int id) override;
- bool deactivateDomainKey(const DNSName& name, unsigned int id) override;
- bool publishDomainKey(const DNSName& name, unsigned int id) override;
- bool unpublishDomainKey(const DNSName& name, unsigned int id) override;
+ bool getAllDomainMetadata(const ZoneName& name, std::map<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;
private:
static ReadWriteLock s_state_lock;
void initialize();
string format2str(string format, const Netmask& addr, GeoIPNetmask& gl, const GeoIPDomain& dom);
bool d_dnssec{};
- bool hasDNSSECkey(const DNSName& name);
+ bool hasDNSSECkey(const ZoneName& name);
bool lookup_static(const GeoIPDomain& dom, const DNSName& search, const QType& qtype, const DNSName& qdomain, const Netmask& addr, GeoIPNetmask& gl);
void setupNetmasks(const YAML::Node& domain, GeoIPDomain& dom);
bool loadDomain(const YAML::Node& domain, std::uint32_t domainID, GeoIPDomain& dom);
PowerLDAP* d_pldap;
LdapAuthenticator* d_authenticator;
- bool (LdapBackend::*d_list_fcnt)(const DNSName&, int);
+ bool (LdapBackend::*d_list_fcnt)(const ZoneName&, int);
void (LdapBackend::*d_lookup_fcnt)(const QType&, const DNSName&, DNSPacket*, int);
- bool list_simple(const DNSName& target, int domain_id);
- bool list_strict(const DNSName& target, int domain_id);
+ bool list_simple(const ZoneName& target, int domain_id);
+ bool list_strict(const ZoneName& target, int domain_id);
void lookup_simple(const QType& qtype, const DNSName& qdomain, DNSPacket* p, int zoneid);
void lookup_strict(const QType& qtype, const DNSName& qdomain, DNSPacket* p, int zoneid);
// Native backend
unsigned int getCapabilities() override { return CAP_LIST; }
- bool list(const DNSName& target, int domain_id, bool include_disabled = false) override;
+ bool list(const ZoneName& target, int domain_id, bool include_disabled = false) override;
void lookup(const QType& qtype, const DNSName& qdomain, int zoneid, DNSPacket* p = nullptr) override;
bool get(DNSResourceRecord& rr) override;
- bool getDomainInfo(const DNSName& domain, DomainInfo& di, bool getSerial = true) override;
+ bool getDomainInfo(const ZoneName& domain, DomainInfo& di, bool getSerial = true) override;
// Primary backend
void getUpdatedPrimaries(vector<DomainInfo>& domains, std::unordered_set<DNSName>& catalogs, CatalogHashMap& catalogHashes) override;
#include "ldapbackend.hh"
#include <cstdlib>
-bool LdapBackend::list(const DNSName& target, int domain_id, bool /* include_disabled */)
+bool LdapBackend::list(const ZoneName& target, int domain_id, bool /* include_disabled */)
{
try {
d_in_list = true;
return false;
}
-bool LdapBackend::list_simple(const DNSName& target, int /* domain_id */)
+bool LdapBackend::list_simple(const ZoneName& target, int /* domain_id */)
{
string dn;
string filter;
return true;
}
-bool LdapBackend::list_strict(const DNSName& target, int domain_id)
+bool LdapBackend::list_strict(const ZoneName& target, int domain_id)
{
if (target.isPartOf(DNSName("in-addr.arpa")) || target.isPartOf(DNSName("ip6.arpa"))) {
g_log << Logger::Warning << d_myname << " Request for reverse zone AXFR, but this is not supported in strict mode" << endl;
return true;
}
-bool LdapBackend::getDomainInfo(const DNSName& domain, DomainInfo& di, bool /* getSerial */)
+bool LdapBackend::getDomainInfo(const ZoneName& domain, DomainInfo& di, bool /* getSerial */)
{
string filter;
SOAData sd;
di.id = 0;
di.serial = sd.serial;
- di.zone = DNSName(domain);
+ di.zone = domain;
if (result.count("PdnsDomainLastCheck") && !result["PdnsDomainLastCheck"].empty())
pdns::checked_stoi_into(di.last_check, result["PdnsDomainLastCheck"][0]);
continue;
DomainInfo di;
- if (!getDomainInfo(DNSName(result["associatedDomain"][0]), di))
+ if (!getDomainInfo(ZoneName(result["associatedDomain"][0]), di))
continue;
if (di.notified_serial < di.serial)
*/
-bool LMDBBackend::startTransaction(const DNSName& domain, int domain_id)
+bool LMDBBackend::startTransaction(const ZoneName& domain, int domain_id)
{
// cout <<"startTransaction("<<domain<<", "<<domain_id<<")"<<endl;
int real_id = domain_id;
}
#endif
-bool LMDBBackend::deleteDomain(const DNSName& domain)
+bool LMDBBackend::deleteDomain(const ZoneName& domain)
{
if (!d_rwtxn) {
throw DBException(std::string(__PRETTY_FUNCTION__) + " called without a transaction");
}
int transactionDomainId = d_transactiondomainid;
- DNSName transactionDomain = d_transactiondomain;
+ ZoneName transactionDomain = d_transactiondomain;
abortTransaction();
return true;
}
-bool LMDBBackend::list(const DNSName& target, int /* id */, bool include_disabled)
+bool LMDBBackend::list(const ZoneName& target, int /* id */, bool include_disabled)
{
d_includedisabled = include_disabled;
return false;
}
-bool LMDBBackend::getDomainInfo(const DNSName& domain, DomainInfo& di, bool getserial)
+bool LMDBBackend::getDomainInfo(const ZoneName& domain, DomainInfo& di, bool getserial)
{
{
auto txn = d_tdomains->getROTransaction();
return true;
}
-int LMDBBackend::genChangeDomain(const DNSName& domain, const std::function<void(DomainInfo&)>& func)
+int LMDBBackend::genChangeDomain(const ZoneName& domain, const std::function<void(DomainInfo&)>& func)
{
auto txn = d_tdomains->getRWTransaction();
return true;
}
-bool LMDBBackend::setKind(const DNSName& domain, const DomainInfo::DomainKind kind)
+bool LMDBBackend::setKind(const ZoneName& domain, const DomainInfo::DomainKind kind)
{
return genChangeDomain(domain, [kind](DomainInfo& di) {
di.kind = kind;
});
}
-bool LMDBBackend::setAccount(const DNSName& domain, const std::string& account)
+bool LMDBBackend::setAccount(const ZoneName& domain, const std::string& account)
{
return genChangeDomain(domain, [account](DomainInfo& di) {
di.account = account;
});
}
-bool LMDBBackend::setPrimaries(const DNSName& domain, const vector<ComboAddress>& primaries)
+bool LMDBBackend::setPrimaries(const ZoneName& domain, const vector<ComboAddress>& primaries)
{
return genChangeDomain(domain, [&primaries](DomainInfo& di) {
di.primaries = primaries;
});
}
-bool LMDBBackend::createDomain(const DNSName& domain, const DomainInfo::DomainKind kind, const vector<ComboAddress>& primaries, const string& account)
+bool LMDBBackend::createDomain(const ZoneName& domain, const DomainInfo::DomainKind kind, const vector<ComboAddress>& primaries, const string& account)
{
DomainInfo di;
{
auto txn = d_tdomains->getROTransaction();
if (d_handle_dups) {
- map<DNSName, DomainInfo> zonemap;
- set<DNSName> dups;
+ map<ZoneName, DomainInfo> zonemap;
+ set<ZoneName> dups;
for (auto iter = txn.begin(); iter != txn.end(); ++iter) {
DomainInfo di = *iter;
std::runtime_error("getCatalogMembers should return false") {}
};
-bool LMDBBackend::getCatalogMembers(const DNSName& catalog, vector<CatalogInfo>& members, CatalogInfo::CatalogType type)
+bool LMDBBackend::getCatalogMembers(const ZoneName& catalog, vector<CatalogInfo>& members, CatalogInfo::CatalogType type)
{
vector<DomainInfo> scratch;
return true;
}
-bool LMDBBackend::setOptions(const DNSName& domain, const std::string& options)
+bool LMDBBackend::setOptions(const ZoneName& domain, const std::string& options)
{
return genChangeDomain(domain, [options](DomainInfo& di) {
di.options = options;
});
}
-bool LMDBBackend::setCatalog(const DNSName& domain, const DNSName& catalog)
+bool LMDBBackend::setCatalog(const ZoneName& domain, const ZoneName& catalog)
{
return genChangeDomain(domain, [catalog](DomainInfo& di) {
di.catalog = catalog;
});
}
-bool LMDBBackend::getAllDomainMetadata(const DNSName& name, std::map<std::string, std::vector<std::string>>& meta)
+bool LMDBBackend::getAllDomainMetadata(const ZoneName& name, std::map<std::string, std::vector<std::string>>& meta)
{
meta.clear();
auto txn = d_tmeta->getROTransaction();
return true;
}
-bool LMDBBackend::setDomainMetadata(const DNSName& name, const std::string& kind, const std::vector<std::string>& meta)
+bool LMDBBackend::setDomainMetadata(const ZoneName& name, const std::string& kind, const std::vector<std::string>& meta)
{
auto txn = d_tmeta->getRWTransaction();
return true;
}
-bool LMDBBackend::getDomainKeys(const DNSName& name, std::vector<KeyData>& keys)
+bool LMDBBackend::getDomainKeys(const ZoneName& name, std::vector<KeyData>& keys)
{
auto txn = d_tkdb->getROTransaction();
LmdbIdVec ids;
return true;
}
-bool LMDBBackend::removeDomainKey(const DNSName& name, unsigned int id)
+bool LMDBBackend::removeDomainKey(const ZoneName& name, unsigned int id)
{
auto txn = d_tkdb->getRWTransaction();
KeyDataDB kdb;
return true;
}
-bool LMDBBackend::addDomainKey(const DNSName& name, const KeyData& key, int64_t& id)
+bool LMDBBackend::addDomainKey(const ZoneName& name, const KeyData& key, int64_t& id)
{
auto txn = d_tkdb->getRWTransaction();
KeyDataDB kdb{name, key.content, key.flags, key.active, key.published};
return true;
}
-bool LMDBBackend::activateDomainKey(const DNSName& name, unsigned int id)
+bool LMDBBackend::activateDomainKey(const ZoneName& name, unsigned int id)
{
auto txn = d_tkdb->getRWTransaction();
KeyDataDB kdb;
return true;
}
-bool LMDBBackend::deactivateDomainKey(const DNSName& name, unsigned int id)
+bool LMDBBackend::deactivateDomainKey(const ZoneName& name, unsigned int id)
{
auto txn = d_tkdb->getRWTransaction();
KeyDataDB kdb;
return true;
}
-bool LMDBBackend::publishDomainKey(const DNSName& name, unsigned int id)
+bool LMDBBackend::publishDomainKey(const ZoneName& name, unsigned int id)
{
auto txn = d_tkdb->getRWTransaction();
KeyDataDB kdb;
return true;
}
-bool LMDBBackend::unpublishDomainKey(const DNSName& name, unsigned int id)
+bool LMDBBackend::unpublishDomainKey(const ZoneName& name, unsigned int id)
{
auto txn = d_tkdb->getRWTransaction();
KeyDataDB kdb;
return true;
}
-bool LMDBBackend::getBeforeAndAfterNames(uint32_t id, const DNSName& zonenameU, const DNSName& qname, DNSName& before, DNSName& after)
+bool LMDBBackend::getBeforeAndAfterNames(uint32_t id, const ZoneName& zonenameU, const DNSName& qname, DNSName& before, DNSName& after)
{
- DNSName zonename = zonenameU.makeLowerCase();
+ ZoneName zonename = zonenameU.makeLowerCase();
// cout << __PRETTY_FUNCTION__<< ": "<<id <<", "<<zonename << ", '"<<qname<<"'"<<endl;
auto txn = getRecordsROTransaction(id);
nl -> nl0
*/
if (t.empty()) {
- throw std::out_of_range(std::string(__PRETTY_FUNCTION__) + " Attempt to serialize an unset dnsname");
+ throw std::out_of_range(std::string(__PRETTY_FUNCTION__) + " Attempt to serialize an unset DNSName");
}
if (t.isRoot()) {
~LMDBBackend();
unsigned int getCapabilities() override { return CAP_DNSSEC | CAP_DIRECT | CAP_LIST | CAP_CREATE; }
- bool list(const DNSName& target, int id, bool include_disabled) override;
+ bool list(const ZoneName& target, int id, bool include_disabled) override;
- bool getDomainInfo(const DNSName& domain, DomainInfo& di, bool getserial = true) override;
- bool createDomain(const DNSName& domain, const DomainInfo::DomainKind kind, const vector<ComboAddress>& primaries, const string& account) override;
+ bool getDomainInfo(const ZoneName& domain, DomainInfo& di, bool getserial = true) override;
+ bool createDomain(const ZoneName& domain, const DomainInfo::DomainKind kind, const vector<ComboAddress>& primaries, const string& account) override;
- bool startTransaction(const DNSName& domain, int domain_id = -1) override;
+ bool startTransaction(const ZoneName& domain, int domain_id = -1) override;
bool commitTransaction() override;
bool abortTransaction() override;
bool feedRecord(const DNSResourceRecord& r, const DNSName& ordername, bool ordernameIsNSEC3 = false) override;
void setNotified(uint32_t id, uint32_t serial) override;
// catalog zones
- bool getCatalogMembers(const DNSName& catalog, vector<CatalogInfo>& members, CatalogInfo::CatalogType type) override;
- bool setOptions(const DNSName& domain, const std::string& options) override;
- bool setCatalog(const DNSName& domain, const DNSName& options) override;
-
- bool setPrimaries(const DNSName& domain, const vector<ComboAddress>& primaries) override;
- bool setKind(const DNSName& domain, const DomainInfo::DomainKind kind) override;
- bool getAllDomainMetadata(const DNSName& name, std::map<std::string, std::vector<std::string>>& meta) override;
- bool getDomainMetadata(const DNSName& name, const std::string& kind, std::vector<std::string>& meta) override
+ 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 setPrimaries(const ZoneName& domain, const vector<ComboAddress>& primaries) override;
+ bool setKind(const ZoneName& domain, const DomainInfo::DomainKind kind) override;
+ 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
{
// std::cout<<"Request for metadata items for zone "<<name<<", kind "<<kind<<endl;
meta.clear();
return false;
}
- bool setDomainMetadata(const DNSName& name, const std::string& kind, const std::vector<std::string>& meta) override;
- bool setAccount(const DNSName& domain, const std::string& account) override;
- bool deleteDomain(const DNSName& domain) override;
+ bool setDomainMetadata(const ZoneName& name, const std::string& kind, const std::vector<std::string>& meta) override;
+ bool setAccount(const ZoneName& domain, const std::string& account) override;
+ bool deleteDomain(const ZoneName& domain) override;
- bool getDomainKeys(const DNSName& name, std::vector<KeyData>& keys) override;
- bool removeDomainKey(const DNSName& name, unsigned int id) override;
- bool addDomainKey(const DNSName& name, const KeyData& key, int64_t& id) override;
- bool activateDomainKey(const DNSName& name, unsigned int id) override;
- bool deactivateDomainKey(const DNSName& name, unsigned int id) override;
- bool publishDomainKey(const DNSName& name, unsigned int id) override;
- bool unpublishDomainKey(const DNSName& name, unsigned int id) override;
+ bool getDomainKeys(const ZoneName& name, std::vector<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;
// 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 DNSName& zonename, const DNSName& qname, DNSName& before, DNSName& after) override;
+ bool getBeforeAndAfterNames(uint32_t id, const ZoneName& zonename, const DNSName& qname, DNSName& before, DNSName& after) override;
bool updateDNSSECOrderNameAndAuth(uint32_t domain_id, const DNSName& qname, const DNSName& ordername, bool auth, const uint16_t qtype = QType::ANY) override;
public:
struct DomainMeta
{
- DNSName domain;
+ ZoneName domain;
string key;
string value;
};
struct KeyDataDB
{
- DNSName domain;
+ ZoneName domain;
std::string content;
unsigned int flags{0};
bool active{true};
private:
typedef TypedDBI<DomainInfo,
- index_on<DomainInfo, DNSName, &DomainInfo::zone>>
+ index_on<DomainInfo, ZoneName, &DomainInfo::zone>>
tdomains_t;
typedef TypedDBI<DomainMeta,
- index_on<DomainMeta, DNSName, &DomainMeta::domain>>
+ index_on<DomainMeta, ZoneName, &DomainMeta::domain>>
tmeta_t;
typedef TypedDBI<KeyDataDB,
- index_on<KeyDataDB, DNSName, &KeyDataDB::domain>>
+ index_on<KeyDataDB, ZoneName, &KeyDataDB::domain>>
tkdb_t;
typedef TypedDBI<TSIGKey,
bool d_txnorder{false}; // whether d_rotxn is more recent than d_rwtxn
std::shared_ptr<RecordsRWTransaction> getRecordsRWTransaction(uint32_t id);
std::shared_ptr<RecordsROTransaction> getRecordsROTransaction(uint32_t id, const std::shared_ptr<LMDBBackend::RecordsRWTransaction>& rwtxn = nullptr);
- int genChangeDomain(const DNSName& domain, const std::function<void(DomainInfo&)>& func);
+ int genChangeDomain(const ZoneName& domain, const std::function<void(DomainInfo&)>& func);
int genChangeDomain(uint32_t id, const std::function<void(DomainInfo&)>& func);
void deleteDomainRecords(RecordsRWTransaction& txn, uint32_t domain_id, uint16_t qtype = QType::ANY);
bool get_list(DNSZoneRecord& rr);
bool get_lookup(DNSZoneRecord& rr);
std::string d_matchkey;
- DNSName d_lookupdomain;
+ ZoneName d_lookupdomain;
vector<LMDBResourceRecord> d_currentrrset;
size_t d_currentrrsetpos;
MDBOutVal d_currentVal;
bool d_includedisabled;
- DNSName d_transactiondomain;
+ ZoneName d_transactiondomain;
uint32_t d_transactiondomainid;
bool d_dolog;
bool d_random_ids;
g_log << Logger::Debug << "[" << getPrefix() << "] Got empty result" << endl;
}
- bool list(const DNSName& target, int domain_id, bool /* include_disabled */ = false) override
+ bool list(const ZoneName& target, int domain_id, bool /* include_disabled */ = false) override
{
if (f_list == nullptr) {
g_log << Logger::Error << "[" << getPrefix() << "] dns_list missing - cannot do AXFR" << endl;
logResult("zone=" << di.zone << ",serial=" << di.serial << ",kind=" << di.getKindString());
}
- bool getDomainInfo(const DNSName& domain, DomainInfo& di, bool /* getSerial */ = true) override
+ bool getDomainInfo(const ZoneName& domain, DomainInfo& di, bool /* getSerial */ = true) override
{
if (f_get_domaininfo == nullptr) {
// use getAuth instead
}
}
- bool getAllDomainMetadata(const DNSName& name, std::map<std::string, std::vector<std::string>>& meta) override
+ bool getAllDomainMetadata(const ZoneName& name, std::map<std::string, std::vector<std::string>>& meta) override
{
if (f_get_all_domain_metadata == nullptr)
return false;
return true;
}
- bool getDomainMetadata(const DNSName& name, const std::string& kind, std::vector<std::string>& meta) override
+ bool getDomainMetadata(const ZoneName& name, const std::string& kind, std::vector<std::string>& meta) override
{
if (f_get_domain_metadata == nullptr)
return false;
return true;
}
- bool getDomainKeys(const DNSName& name, std::vector<DNSBackend::KeyData>& keys) override
+ bool getDomainKeys(const ZoneName& name, std::vector<DNSBackend::KeyData>& keys) override
{
if (f_get_domain_keys == nullptr)
return false;
d_qname = qname;
}
-bool PipeBackend::list(const DNSName& target, int inZoneId, bool /* include_disabled */)
+bool PipeBackend::list(const ZoneName& target, int inZoneId, bool /* include_disabled */)
{
try {
launch();
unsigned int getCapabilities() override { return CAP_DIRECT | CAP_LIST; }
void lookup(const QType&, const DNSName& qdomain, int zoneId, DNSPacket* p = nullptr) override;
- bool list(const DNSName& target, int domain_id, bool include_disabled = false) override;
+ bool list(const ZoneName& target, int domain_id, bool include_disabled = false) override;
bool get(DNSResourceRecord& r) override;
string directBackendCmd(const string& query) override;
static DNSBackend* maker();
d_index = 0;
}
-bool RemoteBackend::list(const DNSName& target, int domain_id, bool include_disabled)
+bool RemoteBackend::list(const ZoneName& target, int domain_id, bool include_disabled)
{
if (d_index != -1) {
throw PDNSException("Attempt to lookup while one running");
return true;
}
-bool RemoteBackend::getAllDomainMetadata(const DNSName& name, std::map<std::string, std::vector<std::string>>& meta)
+bool RemoteBackend::getAllDomainMetadata(const ZoneName& name, std::map<std::string, std::vector<std::string>>& meta)
{
Json query = Json::object{
{"method", "getAllDomainMetadata"},
return true;
}
-bool RemoteBackend::getDomainMetadata(const DNSName& name, const std::string& kind, std::vector<std::string>& meta)
+bool RemoteBackend::getDomainMetadata(const ZoneName& name, const std::string& kind, std::vector<std::string>& meta)
{
Json query = Json::object{
{"method", "getDomainMetadata"},
return true;
}
-bool RemoteBackend::setDomainMetadata(const DNSName& name, const std::string& kind, const std::vector<std::string>& meta)
+bool RemoteBackend::setDomainMetadata(const ZoneName& name, const std::string& kind, const std::vector<std::string>& meta)
{
Json query = Json::object{
{"method", "setDomainMetadata"},
return boolFromJson(answer, "result", false);
}
-bool RemoteBackend::getDomainKeys(const DNSName& name, std::vector<DNSBackend::KeyData>& keys)
+bool RemoteBackend::getDomainKeys(const ZoneName& name, std::vector<DNSBackend::KeyData>& keys)
{
// no point doing dnssec if it's not supported
if (!d_dnssec) {
return true;
}
-bool RemoteBackend::removeDomainKey(const DNSName& name, unsigned int id)
+bool RemoteBackend::removeDomainKey(const ZoneName& name, unsigned int id)
{
// no point doing dnssec if it's not supported
if (!d_dnssec) {
return this->send(query) && this->recv(answer);
}
-bool RemoteBackend::addDomainKey(const DNSName& name, const KeyData& key, int64_t& id)
+bool RemoteBackend::addDomainKey(const ZoneName& name, const KeyData& key, int64_t& id)
{
// no point doing dnssec if it's not supported
if (!d_dnssec) {
return id >= 0;
}
-bool RemoteBackend::activateDomainKey(const DNSName& name, unsigned int id)
+bool RemoteBackend::activateDomainKey(const ZoneName& name, unsigned int id)
{
// no point doing dnssec if it's not supported
if (!d_dnssec) {
return this->send(query) && this->recv(answer);
}
-bool RemoteBackend::deactivateDomainKey(const DNSName& name, unsigned int id)
+bool RemoteBackend::deactivateDomainKey(const ZoneName& name, unsigned int id)
{
// no point doing dnssec if it's not supported
if (!d_dnssec) {
return this->send(query) && this->recv(answer);
}
-bool RemoteBackend::publishDomainKey(const DNSName& name, unsigned int id)
+bool RemoteBackend::publishDomainKey(const ZoneName& name, unsigned int id)
{
// no point doing dnssec if it's not supported
if (!d_dnssec) {
return this->send(query) && this->recv(answer);
}
-bool RemoteBackend::unpublishDomainKey(const DNSName& name, unsigned int id)
+bool RemoteBackend::unpublishDomainKey(const ZoneName& name, unsigned int id)
{
// no point doing dnssec if it's not supported
if (!d_dnssec) {
void RemoteBackend::parseDomainInfo(const Json& obj, DomainInfo& di)
{
di.id = intFromJson(obj, "id", -1);
- di.zone = DNSName(stringFromJson(obj, "zone"));
+ di.zone = ZoneName(stringFromJson(obj, "zone"));
for (const auto& primary : obj["masters"].array_items()) {
di.primaries.emplace_back(primary.string_value(), 53);
}
di.backend = this;
}
-bool RemoteBackend::getDomainInfo(const DNSName& domain, DomainInfo& di, bool /* getSerial */)
+bool RemoteBackend::getDomainInfo(const ZoneName& domain, DomainInfo& di, bool /* getSerial */)
{
if (domain.empty()) {
return false;
}
}
-bool RemoteBackend::autoPrimaryBackend(const string& ip, const DNSName& domain, const vector<DNSResourceRecord>& nsset, string* nameserver, string* account, DNSBackend** ddb)
+bool RemoteBackend::autoPrimaryBackend(const string& ip, const ZoneName& domain, const vector<DNSResourceRecord>& nsset, string* nameserver, string* account, DNSBackend** ddb)
{
Json::array rrset;
return true;
}
-bool RemoteBackend::createSecondaryDomain(const string& ip, const DNSName& domain, const string& nameserver, const string& account)
+bool RemoteBackend::createSecondaryDomain(const string& ip, const ZoneName& domain, const string& nameserver, const string& account)
{
Json query = Json::object{
{"method", "createSlaveDomain"},
return this->send(query) && this->recv(answer);
}
-bool RemoteBackend::startTransaction(const DNSName& domain, int domain_id)
+bool RemoteBackend::startTransaction(const ZoneName& domain, int domain_id)
{
this->d_trxid = time((time_t*)nullptr);
unsigned int getCapabilities() override;
void lookup(const QType& qtype, const DNSName& qdomain, int zoneId = -1, DNSPacket* pkt_p = nullptr) override;
bool get(DNSResourceRecord& rr) override;
- bool list(const DNSName& target, int domain_id, bool include_disabled = false) override;
+ bool list(const ZoneName& target, int domain_id, bool include_disabled = false) override;
- bool getAllDomainMetadata(const DNSName& name, std::map<std::string, std::vector<std::string>>& meta) override;
- bool getDomainMetadata(const DNSName& name, const std::string& kind, std::vector<std::string>& meta) override;
- bool getDomainKeys(const DNSName& name, std::vector<DNSBackend::KeyData>& keys) override;
+ 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 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 DNSName& name, unsigned int id) override;
- bool addDomainKey(const DNSName& name, const KeyData& key, int64_t& id) override;
- bool activateDomainKey(const DNSName& name, unsigned int id) override;
- bool deactivateDomainKey(const DNSName& name, unsigned int id) override;
- bool publishDomainKey(const DNSName& name, unsigned int id) override;
- bool unpublishDomainKey(const DNSName& name, unsigned int id) override;
- bool getDomainInfo(const DNSName& domain, DomainInfo& di, bool getSerial = true) override;
+ bool removeDomainKey(const ZoneName& name, unsigned int id) override;
+ bool addDomainKey(const ZoneName& name, const KeyData& key, int64_t& id) override;
+ bool activateDomainKey(const ZoneName& name, unsigned int id) override;
+ bool deactivateDomainKey(const ZoneName& name, unsigned int id) override;
+ bool publishDomainKey(const ZoneName& name, unsigned int id) override;
+ bool unpublishDomainKey(const ZoneName& name, unsigned int id) override;
+ bool getDomainInfo(const ZoneName& domain, DomainInfo& di, bool getSerial = true) override;
void setNotified(uint32_t id, uint32_t serial) override;
- bool autoPrimaryBackend(const string& ip, const DNSName& domain, const vector<DNSResourceRecord>& nsset, string* nameserver, string* account, DNSBackend** ddb) override;
- bool createSecondaryDomain(const string& ip, const DNSName& domain, const string& nameserver, const string& account) override;
+ bool autoPrimaryBackend(const string& ip, const ZoneName& domain, const vector<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 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;
bool feedEnts3(int domain_id, const DNSName& domain, map<DNSName, bool>& nonterm, const NSEC3PARAMRecordContent& ns3prc, bool narrow) override;
- bool startTransaction(const DNSName& domain, int domain_id) override;
+ bool startTransaction(const ZoneName& domain, int domain_id) override;
bool commitTransaction() override;
bool abortTransaction() override;
bool setTSIGKey(const DNSName& name, const DNSName& algorithm, const string& content) override;
DNSResourceRecord resourceRecord;
BOOST_TEST_MESSAGE("Testing list method");
- backendUnderTest->list(DNSName("unit.test."), -1);
+ backendUnderTest->list(ZoneName("unit.test."), -1);
while (backendUnderTest->get(resourceRecord)) {
record_count++;
}
std::vector<std::string> meta;
meta.emplace_back("VALUE");
BOOST_TEST_MESSAGE("Testing setDomainMetadata method");
- BOOST_CHECK(backendUnderTest->setDomainMetadata(DNSName("unit.test."), "TEST", meta));
+ BOOST_CHECK(backendUnderTest->setDomainMetadata(ZoneName("unit.test."), "TEST", meta));
}
BOOST_AUTO_TEST_CASE(test_method_alsoNotifies)
{
- BOOST_CHECK(backendUnderTest->setDomainMetadata(DNSName("unit.test."), "ALSO-NOTIFY", {"192.0.2.1"}));
+ BOOST_CHECK(backendUnderTest->setDomainMetadata(ZoneName("unit.test."), "ALSO-NOTIFY", {"192.0.2.1"}));
std::set<std::string> alsoNotifies;
BOOST_TEST_MESSAGE("Testing alsoNotifies method");
- backendUnderTest->alsoNotifies(DNSName("unit.test."), &alsoNotifies);
+ backendUnderTest->alsoNotifies(ZoneName("unit.test."), &alsoNotifies);
BOOST_CHECK_EQUAL(alsoNotifies.size(), 1);
if (!alsoNotifies.empty()) {
BOOST_CHECK_EQUAL(alsoNotifies.count("192.0.2.1"), 1);
}
- BOOST_CHECK(backendUnderTest->setDomainMetadata(DNSName("unit.test."), "ALSO-NOTIFY", std::vector<std::string>()));
+ BOOST_CHECK(backendUnderTest->setDomainMetadata(ZoneName("unit.test."), "ALSO-NOTIFY", std::vector<std::string>()));
}
BOOST_AUTO_TEST_CASE(test_method_getDomainMetadata)
{
std::vector<std::string> meta;
BOOST_TEST_MESSAGE("Testing getDomainMetadata method");
- backendUnderTest->getDomainMetadata(DNSName("unit.test."), "TEST", meta);
+ backendUnderTest->getDomainMetadata(ZoneName("unit.test."), "TEST", meta);
BOOST_CHECK_EQUAL(meta.size(), 1);
// in case we got more than one value, which would be unexpected
// but not fatal
{
std::map<std::string, std::vector<std::string>> meta;
BOOST_TEST_MESSAGE("Testing getAllDomainMetadata method");
- backendUnderTest->getAllDomainMetadata(DNSName("unit.test."), meta);
+ backendUnderTest->getAllDomainMetadata(ZoneName("unit.test."), meta);
BOOST_CHECK_EQUAL(meta.size(), 1);
// in case we got more than one value, which would be unexpected
// but not fatal
{
BOOST_TEST_MESSAGE("Testing addDomainKey method");
int64_t keyID = 0;
- backendUnderTest->addDomainKey(DNSName("unit.test."), k1, keyID);
+ backendUnderTest->addDomainKey(ZoneName("unit.test."), k1, keyID);
BOOST_CHECK_EQUAL(keyID, 1);
- backendUnderTest->addDomainKey(DNSName("unit.test."), k2, keyID);
+ backendUnderTest->addDomainKey(ZoneName("unit.test."), k2, keyID);
BOOST_CHECK_EQUAL(keyID, 2);
}
std::vector<DNSBackend::KeyData> keys;
BOOST_TEST_MESSAGE("Testing getDomainKeys method");
// we expect to get two keys
- backendUnderTest->getDomainKeys(DNSName("unit.test."), keys);
+ backendUnderTest->getDomainKeys(ZoneName("unit.test."), keys);
BOOST_CHECK_EQUAL(keys.size(), 2);
// in case we got more than 2 keys, which would be unexpected
// but not fatal
BOOST_AUTO_TEST_CASE(test_method_deactivateDomainKey)
{
BOOST_TEST_MESSAGE("Testing deactivateDomainKey method");
- BOOST_CHECK(backendUnderTest->deactivateDomainKey(DNSName("unit.test."), 1));
+ BOOST_CHECK(backendUnderTest->deactivateDomainKey(ZoneName("unit.test."), 1));
}
BOOST_AUTO_TEST_CASE(test_method_activateDomainKey)
{
BOOST_TEST_MESSAGE("Testing activateDomainKey method");
- BOOST_CHECK(backendUnderTest->activateDomainKey(DNSName("unit.test."), 1));
+ BOOST_CHECK(backendUnderTest->activateDomainKey(ZoneName("unit.test."), 1));
}
BOOST_AUTO_TEST_CASE(test_method_removeDomainKey)
{
- BOOST_CHECK(backendUnderTest->removeDomainKey(DNSName("unit.test."), 2));
- BOOST_CHECK(backendUnderTest->removeDomainKey(DNSName("unit.test."), 1));
+ BOOST_CHECK(backendUnderTest->removeDomainKey(ZoneName("unit.test."), 2));
+ BOOST_CHECK(backendUnderTest->removeDomainKey(ZoneName("unit.test."), 1));
}
BOOST_AUTO_TEST_CASE(test_method_getBeforeAndAfterNamesAbsolute)
{
DomainInfo domainInfo;
BOOST_TEST_MESSAGE("Testing getDomainInfo method");
- backendUnderTest->getDomainInfo(DNSName("unit.test."), domainInfo);
+ backendUnderTest->getDomainInfo(ZoneName("unit.test."), domainInfo);
BOOST_CHECK_EQUAL(domainInfo.zone.toString(), "unit.test.");
BOOST_CHECK_EQUAL(domainInfo.serial, 2);
BOOST_CHECK_EQUAL(domainInfo.notified_serial, 2);
resourceRecord.content = "ns2.example.com.";
nsset.push_back(resourceRecord);
- BOOST_CHECK(backendUnderTest->autoPrimaryBackend("10.0.0.1", DNSName("example.com."), nsset, nullptr, nullptr, &dbd));
+ BOOST_CHECK(backendUnderTest->autoPrimaryBackend("10.0.0.1", ZoneName("example.com."), nsset, nullptr, nullptr, &dbd));
// let's see what we got
BOOST_CHECK_EQUAL(dbd, backendUnderTest.get());
BOOST_AUTO_TEST_CASE(test_method_createSecondaryDomain)
{
BOOST_TEST_MESSAGE("Testing createSecondaryDomain method");
- BOOST_CHECK(backendUnderTest->createSecondaryDomain("10.0.0.1", DNSName("pirate.unit.test."), "", ""));
+ BOOST_CHECK(backendUnderTest->createSecondaryDomain("10.0.0.1", ZoneName("pirate.unit.test."), "", ""));
}
BOOST_AUTO_TEST_CASE(test_method_feedRecord)
{
DNSResourceRecord resourceRecord;
BOOST_TEST_MESSAGE("Testing feedRecord method");
- backendUnderTest->startTransaction(DNSName("example.com."), 3);
+ backendUnderTest->startTransaction(ZoneName("example.com."), 3);
resourceRecord.qname = DNSName("example.com.");
resourceRecord.qtype = QType::SOA;
resourceRecord.qclass = QClass::IN;
BOOST_AUTO_TEST_CASE(test_method_replaceRRSet)
{
- backendUnderTest->startTransaction(DNSName("example.com."), 3);
+ backendUnderTest->startTransaction(ZoneName("example.com."), 3);
DNSResourceRecord resourceRecord;
std::vector<DNSResourceRecord> rrset;
BOOST_TEST_MESSAGE("Testing replaceRRSet method");
BOOST_AUTO_TEST_CASE(test_method_feedEnts)
{
BOOST_TEST_MESSAGE("Testing feedEnts method");
- backendUnderTest->startTransaction(DNSName("example.com."), 3);
+ backendUnderTest->startTransaction(ZoneName("example.com."), 3);
map<DNSName, bool> nonterm = boost::assign::map_list_of(DNSName("_udp"), true)(DNSName("_sip._udp"), true);
BOOST_CHECK(backendUnderTest->feedEnts(2, nonterm));
backendUnderTest->commitTransaction();
BOOST_AUTO_TEST_CASE(test_method_feedEnts3)
{
BOOST_TEST_MESSAGE("Testing feedEnts3 method");
- backendUnderTest->startTransaction(DNSName("example.com"), 3);
+ backendUnderTest->startTransaction(ZoneName("example.com"), 3);
NSEC3PARAMRecordContent ns3prc;
ns3prc.d_iterations = 1;
ns3prc.d_salt = "\u00aa\u00bb\u00cc\u00dd";
BOOST_AUTO_TEST_CASE(test_method_abortTransaction)
{
BOOST_TEST_MESSAGE("Testing abortTransaction method");
- backendUnderTest->startTransaction(DNSName("example.com."), 3);
+ backendUnderTest->startTransaction(ZoneName("example.com."), 3);
BOOST_CHECK(backendUnderTest->abortTransaction());
}
DomainInfo di;
di.id = -1; // Will be overridden by caller
di.backend = this;
- di.zone = rr.qname;
+ di.zone = ZoneName(rr.qname);
di.kind = DomainInfo::Primary;
di.last_check = time(0);
}
//NOLINTNEXTLINE(readability-identifier-length)
-bool TinyDNSBackend::getDomainInfo(const DNSName& domain, DomainInfo& di, bool getSerial)
+bool TinyDNSBackend::getDomainInfo(const ZoneName& domain, DomainInfo& di, bool getSerial)
{
auto domainInfo = s_domainInfo.lock(); //TODO: We could actually lock less if we do it per suffix.
if (domainInfo->count(d_suffix) == 0) {
return found;
}
-bool TinyDNSBackend::list(const DNSName& target, int /* domain_id */, bool /* include_disabled */)
+bool TinyDNSBackend::list(const ZoneName& target, int /* domain_id */, bool /* include_disabled */)
{
d_isAxfr = true;
d_isGetDomains = false;
{
uint32_t id;
uint32_t notified_serial;
- DNSName zone;
+ ZoneName zone;
bool operator<(const TinyDomainInfo& tdi) const
{
unsigned int getCapabilities() override { return CAP_LIST; }
void lookup(const QType& qtype, const DNSName& qdomain, int zoneId, DNSPacket* pkt_p = nullptr) override;
- bool list(const DNSName& target, int domain_id, bool include_disabled = false) override;
+ bool list(const ZoneName& target, int domain_id, bool include_disabled = false) override;
bool get(DNSResourceRecord& rr) override;
- bool getDomainInfo(const DNSName& domain, DomainInfo& di, bool getSerial = true) override;
+ bool getDomainInfo(const ZoneName& domain, DomainInfo& di, bool getSerial = true) override;
void getAllDomains(vector<DomainInfo>* domains, bool getSerial, bool include_disabled) override;
// Primary mode operation
typedef multi_index_container<
TinyDomainInfo,
indexed_by<
- hashed_unique<tag<tag_zone>, member<TinyDomainInfo, DNSName, &TinyDomainInfo::zone>>,
+ hashed_unique<tag<tag_zone>, member<TinyDomainInfo, ZoneName, &TinyDomainInfo::zone>>,
hashed_unique<tag<tag_domainid>, member<TinyDomainInfo, uint32_t, &TinyDomainInfo::id>>>>
TDI_t;
typedef map<string, TDI_t> TDI_suffix_t;
}
}
-DNSZoneRecord CatalogInfo::getCatalogVersionRecord(const DNSName& zone)
+DNSZoneRecord CatalogInfo::getCatalogVersionRecord(const ZoneName& zone)
{
DNSZoneRecord dzr;
dzr.dr.d_name = DNSName("version") + zone;
return dzr;
}
-void CatalogInfo::toDNSZoneRecords(const DNSName& zone, vector<DNSZoneRecord>& dzrs) const
+void CatalogInfo::toDNSZoneRecords(const ZoneName& zone, vector<DNSZoneRecord>& dzrs) const
{
DNSName prefix;
if (d_unique.empty()) {
struct DomainInfo;
-typedef map<DNSName, pdns::SHADigest> CatalogHashMap;
+typedef map<ZoneName, pdns::SHADigest> CatalogHashMap;
class CatalogInfo
{
CatalogInfo() :
d_id(0), d_type(CatalogType::None) {}
- CatalogInfo(uint32_t id, const DNSName& zone, const std::string& options, CatalogType type)
+ CatalogInfo(uint32_t id, const ZoneName& zone, const std::string& options, CatalogType type)
{
d_id = id;
d_zone = zone;
void updateHash(CatalogHashMap& hashes, const DomainInfo& di) const;
DNSName getUnique() const { return DNSName(toBase32Hex(hashQNameWithSalt(std::to_string(d_id), 0, d_zone))); } // salt with domain id to detect recreated zones
- static DNSZoneRecord getCatalogVersionRecord(const DNSName& zone);
- void toDNSZoneRecords(const DNSName& zone, vector<DNSZoneRecord>& dzrs) const;
+ static DNSZoneRecord getCatalogVersionRecord(const ZoneName& zone);
+ void toDNSZoneRecords(const ZoneName& zone, vector<DNSZoneRecord>& dzrs) const;
bool operator<(const CatalogInfo& rhs) const
{
}
uint32_t d_id;
- DNSName d_zone, d_coo, d_unique;
+ ZoneName d_zone;
+ DNSName d_coo, d_unique;
std::set<std::string> d_group;
vector<ComboAddress> d_primaries;
g_log << Logger::Warning << "Request to queue notification for domain '" << di.zone << "' was processed, but no valid nameservers or ALSO-NOTIFYs found. Not notifying!" << endl;
}
-bool CommunicatorClass::notifyDomain(const DNSName& domain, UeberBackend* B)
+bool CommunicatorClass::notifyDomain(const ZoneName& domain, UeberBackend* B)
{
DomainInfo di;
if (!B->getDomainInfo(domain, di)) {
}
// send out possible new notifications
- DNSName domain;
+ ZoneName domain;
string ip;
uint16_t id = 0;
return d_nq.earliest();
}
-void CommunicatorClass::sendNotification(int sock, const DNSName& domain, const ComboAddress& remote, uint16_t id, UeberBackend* B)
+void CommunicatorClass::sendNotification(int sock, const ZoneName& domain, const ComboAddress& remote, uint16_t id, UeberBackend* B)
{
vector<string> meta;
DNSName tsigkeyname;
}
}
-void CommunicatorClass::drillHole(const DNSName& domain, const string& ip)
+void CommunicatorClass::drillHole(const ZoneName& domain, const string& ip)
{
(*d_holes.lock())[pair(domain, ip)] = time(nullptr);
}
-bool CommunicatorClass::justNotified(const DNSName& domain, const string& ip)
+bool CommunicatorClass::justNotified(const ZoneName& domain, const string& ip)
{
auto holes = d_holes.lock();
auto it = holes->find(pair(domain, ip));
}
}
-void CommunicatorClass::notify(const DNSName& domain, const string& ip)
+void CommunicatorClass::notify(const ZoneName& domain, const string& ip)
{
d_nq.add(domain, ip);
}
#include "ixfr.hh"
-void CommunicatorClass::addSuckRequest(const DNSName& domain, const ComboAddress& primary, SuckRequest::RequestPriority priority, bool force)
+void CommunicatorClass::addSuckRequest(const ZoneName& domain, const ComboAddress& primary, SuckRequest::RequestPriority priority, bool force)
{
auto data = d_data.lock();
SuckRequest sr;
bool doTransaction{true};
bool inTransaction{false};
CatalogInfo ciCreate, ciRemove;
- std::unordered_map<DNSName, bool> clearCache;
+ std::unordered_map<ZoneName, bool> clearCache;
vector<CatalogInfo> retrieve;
try {
logPrefix += "Catalog-Zone ";
vector<CatalogInfo> fromXFR, fromDB;
- std::unordered_set<DNSName> dupcheck;
+ std::unordered_set<ZoneName> dupcheck;
// From XFR
bool hasSOA{false};
return catalogDiff(di, fromXFR, fromDB, logPrefix);
}
-void CommunicatorClass::ixfrSuck(const DNSName& domain, const TSIGTriplet& tt, const ComboAddress& laddr, const ComboAddress& remote, ZoneStatus& zs, vector<DNSRecord>* axfr)
+void CommunicatorClass::ixfrSuck(const ZoneName& domain, const TSIGTriplet& tt, const ComboAddress& laddr, const ComboAddress& remote, ZoneStatus& zs, vector<DNSRecord>* axfr)
{
string logPrefix = "IXFR-in zone '" + domain.toLogString() + "', primary '" + remote.toString() + "', ";
// this means that we must group updates by {qname,qtype}, retrieve the RRSET, apply
// the add/remove updates, and replaceRRSet the whole thing.
- map<pair<DNSName, uint16_t>, pair<vector<DNSRecord>, vector<DNSRecord>>> grouped;
+ map<pair<ZoneName, uint16_t>, pair<vector<DNSRecord>, vector<DNSRecord>>> grouped;
for (const auto& x : remove)
grouped[{x.d_name, x.d_type}].first.push_back(x);
return rrs;
}
-void CommunicatorClass::suck(const DNSName& domain, const ComboAddress& remote, bool force) // NOLINT(readability-function-cognitive-complexity)
+void CommunicatorClass::suck(const ZoneName& domain, const ComboAddress& remote, bool force) // NOLINT(readability-function-cognitive-complexity)
{
{
auto data = d_data.lock();
}
}
-vector<pair<DNSName, ComboAddress>> CommunicatorClass::getSuckRequests()
+vector<pair<ZoneName, ComboAddress>> CommunicatorClass::getSuckRequests()
{
- vector<pair<DNSName, ComboAddress>> ret;
+ vector<pair<ZoneName, ComboAddress>> ret;
auto data = d_data.lock();
ret.reserve(data->d_suckdomains.size());
for (auto const& d : data->d_suckdomains) {
d_statnumentries = S.getPointer("zone-cache-size");
}
-bool AuthZoneCache::getEntry(const DNSName& zone, int& zoneId)
+bool AuthZoneCache::getEntry(const ZoneName& zone, int& zoneId)
{
auto& mc = getMap(zone);
bool found = false;
purgeLockedCollectionsVector(d_maps);
}
-void AuthZoneCache::replace(const vector<std::tuple<DNSName, int>>& zone_indices)
+void AuthZoneCache::replace(const vector<std::tuple<ZoneName, int>>& zone_indices)
{
if (!d_refreshinterval)
return;
}
}
-void AuthZoneCache::add(const DNSName& zone, const int zoneId)
+void AuthZoneCache::add(const ZoneName& zone, const int zoneId)
{
if (!d_refreshinterval)
return;
}
}
-void AuthZoneCache::remove(const DNSName& zone)
+void AuthZoneCache::remove(const ZoneName& zone)
{
if (!d_refreshinterval)
return;
public:
AuthZoneCache(size_t mapsCount = 1024);
- void replace(const vector<std::tuple<DNSName, int>>& zone);
- void add(const DNSName& zone, const int zoneId);
- void remove(const DNSName& zone);
+ void replace(const vector<std::tuple<ZoneName, int>>& zone);
+ void add(const ZoneName& zone, const int zoneId);
+ void remove(const ZoneName& zone);
void setReplacePending(); //!< call this when data collection for the subsequent replace() call starts.
- bool getEntry(const DNSName& zone, int& zoneId);
+ bool getEntry(const ZoneName& zone, int& zoneId);
size_t size() { return *d_statnumentries; } //!< number of entries in the cache
int zoneId{-1};
};
- typedef std::unordered_map<DNSName, CacheValue, std::hash<DNSName>> cmap_t;
+ typedef std::unordered_map<ZoneName, CacheValue, std::hash<ZoneName>> cmap_t;
struct MapCombo
{
};
vector<MapCombo> d_maps;
- size_t getMapIndex(const DNSName& zone)
+ size_t getMapIndex(const ZoneName& zone)
{
return zone.hash() % d_maps.size();
}
- MapCombo& getMap(const DNSName& qname)
+ MapCombo& getMap(const ZoneName& qname)
{
return d_maps[getMapIndex(qname)];
}
struct PendingData
{
- std::vector<std::tuple<DNSName, int, bool>> d_pendingUpdates;
+ std::vector<std::tuple<ZoneName, int, bool>> d_pendingUpdates;
bool d_replacePending{false};
};
LockGuarded<PendingData> d_pending;
using pdns::resolver::parseResult;
AXFRRetriever::AXFRRetriever(const ComboAddress& remote,
- const DNSName& domain,
+ const ZoneName& domain,
const TSIGTriplet& tsigConf,
const ComboAddress* laddr,
size_t maxReceivedBytes,
{
public:
AXFRRetriever(const ComboAddress& remote,
- const DNSName& zone,
+ const ZoneName& zone,
const TSIGTriplet& tt = TSIGTriplet(),
const ComboAddress* laddr = NULL,
size_t maxReceivedBytes=0,
setLastCheck(domain_id, time(nullptr));
}
-bool GSQLBackend::setPrimaries(const DNSName& domain, const vector<ComboAddress>& primaries)
+bool GSQLBackend::setPrimaries(const ZoneName& domain, const vector<ComboAddress>& primaries)
{
vector<string> primaries_s;
primaries_s.reserve(primaries.size());
return true;
}
-bool GSQLBackend::setKind(const DNSName &domain, const DomainInfo::DomainKind kind)
+bool GSQLBackend::setKind(const ZoneName &domain, const DomainInfo::DomainKind kind)
{
try {
reconnectIfNeeded();
return true;
}
-bool GSQLBackend::setOptions(const DNSName& domain, const string& options)
+bool GSQLBackend::setOptions(const ZoneName& domain, const string& options)
{
try {
reconnectIfNeeded();
return true;
}
-bool GSQLBackend::setCatalog(const DNSName& domain, const DNSName& catalog)
+bool GSQLBackend::setCatalog(const ZoneName& domain, const ZoneName& catalog)
{
try {
reconnectIfNeeded();
return true;
}
-bool GSQLBackend::setAccount(const DNSName &domain, const string &account)
+bool GSQLBackend::setAccount(const ZoneName &domain, const string &account)
{
try {
reconnectIfNeeded();
return true;
}
-bool GSQLBackend::getDomainInfo(const DNSName &domain, DomainInfo &di, bool getSerial)
+bool GSQLBackend::getDomainInfo(const ZoneName &domain, DomainInfo &di, bool getSerial)
{
/* fill DomainInfo from database info:
id,name,master IP(s),last_check,notified_serial,type,account */
pdns::checked_stoi_into(di.id, d_result[0][0]);
try {
- di.zone=DNSName(d_result[0][1]);
- di.catalog = (!d_result[0][7].empty() ? DNSName(d_result[0][7]) : DNSName());
+ di.zone=ZoneName(d_result[0][1]);
+ di.catalog = (!d_result[0][7].empty() ? ZoneName(d_result[0][7]) : ZoneName());
} catch (...) {
return false;
}
ASSERT_ROW_COLUMNS("info-all-secondaries-query", row, 6);
try {
- di.zone = DNSName(row[1]);
+ di.zone = ZoneName(row[1]);
}
catch (const std::runtime_error& e) {
g_log << Logger::Warning << __PRETTY_FUNCTION__ << " zone name '" << row[1] << "' is not a valid DNS name: " << e.what() << endl;
}
try {
- di.zone = DNSName(row[1]);
+ di.zone = ZoneName(row[1]);
}
catch (const std::runtime_error& e) {
g_log << Logger::Warning << __PRETTY_FUNCTION__ << " zone name '" << row[1] << "' is not a valid DNS name: " << e.what() << endl;
}
try {
- di.catalog = DNSName(row[5]);
+ di.catalog = ZoneName(row[5]);
}
catch (const std::runtime_error& e) {
g_log << Logger::Warning << __PRETTY_FUNCTION__ << " zone name '" << row[5] << "' is not a valid DNS name: " << e.what() << endl;
}
}
-bool GSQLBackend::getCatalogMembers(const DNSName& catalog, vector<CatalogInfo>& members, CatalogInfo::CatalogType type)
+bool GSQLBackend::getCatalogMembers(const ZoneName& catalog, vector<CatalogInfo>& members, CatalogInfo::CatalogType type)
{
try {
reconnectIfNeeded();
CatalogInfo ci;
try {
- ci.d_zone = DNSName(row[1]);
+ ci.d_zone = ZoneName(row[1]);
}
catch (const std::runtime_error& e) {
g_log << Logger::Warning << __PRETTY_FUNCTION__ << " zone name '" << row[1] << "' is not a valid DNS name: " << e.what() << endl;
return true;
}
-bool GSQLBackend::addDomainKey(const DNSName& name, const KeyData& key, int64_t& id)
+bool GSQLBackend::addDomainKey(const ZoneName& name, const KeyData& key, int64_t& id)
{
if(!d_dnssecQueries)
return false;
}
}
-bool GSQLBackend::activateDomainKey(const DNSName& name, unsigned int id)
+bool GSQLBackend::activateDomainKey(const ZoneName& name, unsigned int id)
{
if(!d_dnssecQueries)
return false;
return true;
}
-bool GSQLBackend::deactivateDomainKey(const DNSName& name, unsigned int id)
+bool GSQLBackend::deactivateDomainKey(const ZoneName& name, unsigned int id)
{
if(!d_dnssecQueries)
return false;
return true;
}
-bool GSQLBackend::publishDomainKey(const DNSName& name, unsigned int id)
+bool GSQLBackend::publishDomainKey(const ZoneName& name, unsigned int id)
{
if(!d_dnssecQueries)
return false;
return true;
}
-bool GSQLBackend::unpublishDomainKey(const DNSName& name, unsigned int id)
+bool GSQLBackend::unpublishDomainKey(const ZoneName& name, unsigned int id)
{
if(!d_dnssecQueries)
return false;
-bool GSQLBackend::removeDomainKey(const DNSName& name, unsigned int id)
+bool GSQLBackend::removeDomainKey(const ZoneName& name, unsigned int id)
{
if(!d_dnssecQueries)
return false;
return true;
}
-bool GSQLBackend::getDomainKeys(const DNSName& name, std::vector<KeyData>& keys)
+bool GSQLBackend::getDomainKeys(const ZoneName& name, std::vector<KeyData>& keys)
{
if(!d_dnssecQueries)
return false;
return true;
}
-bool GSQLBackend::getAllDomainMetadata(const DNSName& name, std::map<std::string, std::vector<std::string> >& meta)
+bool GSQLBackend::getAllDomainMetadata(const ZoneName& name, std::map<std::string, std::vector<std::string> >& meta)
{
try {
reconnectIfNeeded();
}
-bool GSQLBackend::getDomainMetadata(const DNSName& name, const std::string& kind, std::vector<std::string>& meta)
+bool GSQLBackend::getDomainMetadata(const ZoneName& name, const std::string& kind, std::vector<std::string>& meta)
{
if(!d_dnssecQueries && isDnssecDomainMetadata(kind))
return false;
return true;
}
-bool GSQLBackend::setDomainMetadata(const DNSName& name, const std::string& kind, const std::vector<std::string>& meta)
+bool GSQLBackend::setDomainMetadata(const ZoneName& name, const std::string& kind, const std::vector<std::string>& meta)
{
if(!d_dnssecQueries && isDnssecDomainMetadata(kind))
return false;
d_qname=qname;
}
-bool GSQLBackend::list(const DNSName &target, int domain_id, bool include_disabled)
+bool GSQLBackend::list(const ZoneName &target, int domain_id, bool include_disabled)
{
DLOG(g_log<<"GSQLBackend constructing handle for list of domain id '"<<domain_id<<"'"<<endl);
return true;
}
-bool GSQLBackend::listSubZone(const DNSName &zone, int domain_id) {
+bool GSQLBackend::listSubZone(const ZoneName &zone, int domain_id) {
string wildzone = "%." + zone.makeLowerCase().toStringNoDot();
return true;
}
-bool GSQLBackend::autoPrimaryBackend(const string& ip, const DNSName& domain, const vector<DNSResourceRecord>& nsset, string* nameserver, string* account, DNSBackend** ddb)
+bool GSQLBackend::autoPrimaryBackend(const string& ip, 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) {
return false;
}
-bool GSQLBackend::createDomain(const DNSName& domain, const DomainInfo::DomainKind kind, const vector<ComboAddress>& primaries, const string& account)
+bool GSQLBackend::createDomain(const ZoneName& domain, const DomainInfo::DomainKind kind, const vector<ComboAddress>& primaries, const string& account)
{
vector<string> primaries_s;
primaries_s.reserve(primaries.size());
return true;
}
-bool GSQLBackend::createSecondaryDomain(const string& ip, const DNSName& domain, const string& nameserver, const string& account)
+bool GSQLBackend::createSecondaryDomain(const string& ip, const ZoneName& domain, const string& nameserver, const string& account)
{
string name;
vector<ComboAddress> primaries({ComboAddress(ip, 53)});
return true;
}
-bool GSQLBackend::deleteDomain(const DNSName &domain)
+bool GSQLBackend::deleteDomain(const ZoneName &domain)
{
if (!d_inTransaction) {
throw PDNSException("deleteDomain called outside of transaction");
DomainInfo di;
pdns::checked_stoi_into(di.id, row[0]);
try {
- di.zone = DNSName(row[1]);
+ di.zone = ZoneName(row[1]);
if (!row[8].empty()) {
- di.catalog = DNSName(row[8]);
+ di.catalog = ZoneName(row[8]);
}
} catch (...) {
continue;
return true;
}
-bool GSQLBackend::startTransaction(const DNSName &domain, int domain_id)
+bool GSQLBackend::startTransaction(const ZoneName &domain, int domain_id)
{
try {
reconnectIfNeeded();
public:
unsigned int getCapabilities() override;
void lookup(const QType &, const DNSName &qdomain, int zoneId, DNSPacket *p=nullptr) override;
- bool list(const DNSName &target, int domain_id, bool include_disabled=false) override;
+ bool list(const ZoneName &target, int domain_id, bool include_disabled=false) override;
bool get(DNSResourceRecord &r) override;
void getAllDomains(vector<DomainInfo>* domains, bool getSerial, bool include_disabled) override;
- bool startTransaction(const DNSName &domain, int domain_id=-1) override;
+ bool startTransaction(const ZoneName &domain, int domain_id=-1) override;
bool commitTransaction() override;
bool abortTransaction() override;
bool feedRecord(const DNSResourceRecord &r, const DNSName &ordername, bool ordernameIsNSEC3=false) override;
bool feedEnts(int domain_id, map<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 DNSName& domain, const DomainInfo::DomainKind kind, const vector<ComboAddress>& primaries, const string& account) override;
- bool createSecondaryDomain(const string& ip, const DNSName& domain, const string& nameserver, const string& account) override;
- bool deleteDomain(const DNSName &domain) override;
+ bool createDomain(const ZoneName& domain, const DomainInfo::DomainKind kind, const vector<ComboAddress>& primaries, const string& account) override;
+ bool createSecondaryDomain(const string& ip, const ZoneName& domain, const string& nameserver, const string& account) override;
+ bool deleteDomain(const ZoneName &domain) override;
bool autoPrimaryAdd(const AutoPrimary& primary) override;
bool autoPrimaryRemove(const AutoPrimary& primary) override;
bool autoPrimariesList(std::vector<AutoPrimary>& primaries) override;
- bool autoPrimaryBackend(const string& ip, const DNSName& domain, const vector<DNSResourceRecord>& nsset, string* nameserver, string* account, DNSBackend** db) override;
+ bool autoPrimaryBackend(const string& ip, 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 DNSName& catalog, vector<CatalogInfo>& members, CatalogInfo::CatalogType type) override;
- bool getDomainInfo(const DNSName &domain, DomainInfo &di, bool getSerial=true) override;
+ bool getCatalogMembers(const ZoneName& catalog, vector<CatalogInfo>& members, CatalogInfo::CatalogType type) override;
+ bool getDomainInfo(const ZoneName &domain, DomainInfo &di, bool getSerial=true) override;
void setNotified(uint32_t domain_id, uint32_t serial) override;
- bool setPrimaries(const DNSName& domain, const vector<ComboAddress>& primaries) override;
- bool setKind(const DNSName &domain, const DomainInfo::DomainKind kind) override;
- bool setOptions(const DNSName& domain, const string& options) override;
- bool setCatalog(const DNSName& domain, const DNSName& catalog) override;
- bool setAccount(const DNSName &domain, const string &account) override;
+ bool setPrimaries(const ZoneName& domain, const vector<ComboAddress>& primaries) override;
+ bool setKind(const ZoneName &domain, const DomainInfo::DomainKind kind) override;
+ bool setOptions(const ZoneName& domain, const string& options) override;
+ bool setCatalog(const ZoneName& domain, const ZoneName& catalog) override;
+ bool setAccount(const ZoneName &domain, const string &account) override;
bool getBeforeAndAfterNamesAbsolute(uint32_t id, const DNSName& qname, DNSName& unhashed, DNSName& before, DNSName& after) override;
bool updateDNSSECOrderNameAndAuth(uint32_t domain_id, const DNSName& qname, const DNSName& ordername, bool auth, const uint16_t=QType::ANY) override;
bool updateEmptyNonTerminals(uint32_t domain_id, set<DNSName>& insert ,set<DNSName>& erase, bool remove) override;
bool replaceRRSet(uint32_t domain_id, const DNSName& qname, const QType& qt, const vector<DNSResourceRecord>& rrset) override;
- bool listSubZone(const DNSName &zone, int domain_id) override;
- bool addDomainKey(const DNSName& name, const KeyData& key, int64_t& id) override;
- bool getDomainKeys(const DNSName& name, std::vector<KeyData>& keys) override;
- bool getAllDomainMetadata(const DNSName& name, std::map<std::string, std::vector<std::string> >& meta) override;
- bool getDomainMetadata(const DNSName& name, const std::string& kind, std::vector<std::string>& meta) override;
- bool setDomainMetadata(const DNSName& name, const std::string& kind, const std::vector<std::string>& meta) override;
-
- bool removeDomainKey(const DNSName& name, unsigned int id) override;
- bool activateDomainKey(const DNSName& name, unsigned int id) override;
- bool deactivateDomainKey(const DNSName& name, unsigned int id) override;
- bool publishDomainKey(const DNSName& name, unsigned int id) override;
- bool unpublishDomainKey(const DNSName& name, unsigned int id) override;
+ bool listSubZone(const ZoneName &zone, int domain_id) override;
+ bool addDomainKey(const ZoneName& name, const KeyData& key, int64_t& id) override;
+ bool getDomainKeys(const ZoneName& name, std::vector<KeyData>& keys) override;
+ 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 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 getTSIGKey(const DNSName& name, DNSName& algorithm, string& content) override;
bool setTSIGKey(const DNSName& name, const DNSName& algorithm, const string& content) override;
global_zone_command:
ZONETOK quotedname zone_block
{
- s_di.name=DNSName($2);
+ s_di.name=ZoneName($2);
free($2);
parent->commit(s_di);
s_di.clear();
|
ZONETOK quotedname AWORD zone_block
{
- s_di.name=DNSName($2);
+ s_di.name=ZoneName($2);
free($2);
parent->commit(s_di);
s_di.clear();
public:
void clear()
{
- name=DNSName();
+ name=ZoneName();
filename=type="";
primaries.clear();
alsoNotify.clear();
d_dev=0;
d_ino=0;
}
- DNSName name;
+ ZoneName name;
string viewName;
string filename;
vector<ComboAddress> primaries;
set<string> & getAlsoNotify() { return this->alsoNotify; }
private:
string d_dir{"."};
- typedef map<DNSName,string> zonedomain_t;
set<string> alsoNotify;
vector<BindDomainInfo> d_zonedomains;
bool d_verbose{false};
struct SuckRequest
{
- DNSName domain;
+ ZoneName domain;
ComboAddress primary;
bool force;
enum RequestPriority : uint8_t
class NotificationQueue
{
public:
- void add(const DNSName& domain, const string& ipstring, time_t delay = 0)
+ void add(const ZoneName& domain, const string& ipstring, time_t delay = 0)
{
const ComboAddress ipaddress(ipstring);
add(domain, ipaddress, delay);
}
- void add(const DNSName& domain, const ComboAddress& ipaddress, time_t delay = 0)
+ void add(const ZoneName& domain, const ComboAddress& ipaddress, time_t delay = 0)
{
NotificationRequest nr;
nr.domain = domain;
d_nqueue.push_back(nr);
}
- bool removeIf(const ComboAddress& remote, uint16_t id, const DNSName& domain)
+ bool removeIf(const ComboAddress& remote, uint16_t id, const ZoneName& domain)
{
for (auto i = d_nqueue.begin(); i != d_nqueue.end(); ++i) {
ComboAddress stQueued{i->ip};
return false;
}
- bool getOne(DNSName& domain, string& ip, uint16_t* id, bool& purged)
+ bool getOne(ZoneName& domain, string& ip, uint16_t* id, bool& purged)
{
for (d_nqueue_t::iterator i = d_nqueue.begin(); i != d_nqueue.end(); ++i)
if (i->next <= time(nullptr)) {
private:
struct NotificationRequest
{
- DNSName domain;
+ ZoneName domain;
string ip;
time_t next;
int attempts;
time_t doNotifications(PacketHandler* P);
void go();
- void drillHole(const DNSName& domain, const string& ip);
- bool justNotified(const DNSName& domain, const string& ip);
- void addSuckRequest(const DNSName& domain, const ComboAddress& primary, SuckRequest::RequestPriority, bool force = false);
+ void drillHole(const ZoneName& domain, const string& ip);
+ bool justNotified(const ZoneName& domain, const string& ip);
+ void addSuckRequest(const ZoneName& domain, const ComboAddress& primary, SuckRequest::RequestPriority, bool force = false);
void addSecondaryCheckRequest(const DomainInfo& di, const ComboAddress& remote);
void addTryAutoPrimaryRequest(const DNSPacket& p);
- void notify(const DNSName& domain, const string& ip);
+ void notify(const ZoneName& domain, const string& ip);
void mainloop();
void retrievalLoopThread();
- void sendNotification(int sock, const DNSName& domain, const ComboAddress& remote, uint16_t id, UeberBackend* B);
- bool notifyDomain(const DNSName& domain, UeberBackend* B);
- vector<pair<DNSName, ComboAddress>> getSuckRequests();
+ void sendNotification(int sock, const ZoneName& domain, const ComboAddress& remote, uint16_t id, UeberBackend* B);
+ bool notifyDomain(const ZoneName& domain, UeberBackend* B);
+ vector<pair<ZoneName, ComboAddress>> getSuckRequests();
size_t getSuckRequestsWaiting();
private:
void makeNotifySockets();
void queueNotifyDomain(const DomainInfo& di, UeberBackend* B);
int d_nsock4, d_nsock6;
- LockGuarded<map<pair<DNSName, string>, time_t>> d_holes;
+ LockGuarded<map<pair<ZoneName, string>, time_t>> d_holes;
- void suck(const DNSName& domain, const ComboAddress& remote, bool force = false);
- void ixfrSuck(const DNSName& domain, const TSIGTriplet& tt, const ComboAddress& laddr, const ComboAddress& remote, ZoneStatus& zs, vector<DNSRecord>* axfr);
+ void suck(const ZoneName& domain, const ComboAddress& remote, bool force = false);
+ void ixfrSuck(const ZoneName& domain, const TSIGTriplet& tt, const ComboAddress& laddr, const ComboAddress& remote, ZoneStatus& zs, vector<DNSRecord>* axfr);
void secondaryRefresh(PacketHandler* P);
void primaryUpdateCheck(PacketHandler* P);
{
uint64_t d_sorthelper{0};
UniQueue d_suckdomains;
- set<DNSName> d_inprogress;
+ set<ZoneName> d_inprogress;
set<DomainInfo> d_tocheck;
struct cmp
// Used to keep some state on domains that failed their freshness checks.
// uint64_t == counter of the number of failures (increased by 1 every consecutive slave-cycle-interval that the domain fails)
// time_t == wait at least until this time before attempting a new check
- map<DNSName, pair<uint64_t, time_t>> d_failedSecondaryRefresh;
+ map<ZoneName, pair<uint64_t, time_t>> d_failedSecondaryRefresh;
};
LockGuarded<Data> d_data;
struct RemoveSentinel
{
- explicit RemoveSentinel(DNSName dn, CommunicatorClass* cc) :
+ explicit RemoveSentinel(ZoneName dn, CommunicatorClass* cc) :
d_dn(std::move(dn)), d_cc(cc)
{}
catch (...) {
}
}
- DNSName d_dn;
+ ZoneName d_dn;
CommunicatorClass* d_cc;
};
};
return d_keymetadb->doesDNSSEC();
}
-bool DNSSECKeeper::isSecuredZone(const DNSName& zone, bool useCache)
+bool DNSSECKeeper::isSecuredZone(const ZoneName& zone, bool useCache)
{
if(isPresigned(zone, useCache))
return true;
return false;
}
-bool DNSSECKeeper::isPresigned(const DNSName& name, bool useCache)
+bool DNSSECKeeper::isPresigned(const ZoneName& name, bool useCache)
{
string meta;
if (useCache) {
}
-bool DNSSECKeeper::addKey(const DNSName& name, bool setSEPBit, int algorithm, int64_t& id, int bits, bool active, bool published)
+bool DNSSECKeeper::addKey(const ZoneName& name, bool setSEPBit, int algorithm, int64_t& id, int bits, bool active, bool published)
{
if(!bits) {
if(algorithm <= 10)
/* This function never fails, the return value is to simplify call chains
elsewhere so we can do mutate<cache> && clear<cache> */
-bool DNSSECKeeper::clearKeyCache(const DNSName& name)
+bool DNSSECKeeper::clearKeyCache(const ZoneName& name)
{
s_keycache.write_lock()->erase(name);
return true;
}
-bool DNSSECKeeper::clearMetaCache(const DNSName& name)
+bool DNSSECKeeper::clearMetaCache(const ZoneName& name)
{
s_metacache.write_lock()->erase(name);
++s_metaCacheCleanActions;
return true;
}
-void DNSSECKeeper::clearCaches(const DNSName& name)
+void DNSSECKeeper::clearCaches(const ZoneName& name)
{
(void)clearKeyCache(name);
(void)clearMetaCache(name);
}
-bool DNSSECKeeper::addKey(const DNSName& name, const DNSSECPrivateKey& dpk, int64_t& id, bool active, bool published)
+bool DNSSECKeeper::addKey(const ZoneName& name, const DNSSECPrivateKey& dpk, int64_t& id, bool active, bool published)
{
DNSBackend::KeyData kd;
kd.flags = dpk.getFlags(); // the dpk doesn't get stored, only they key part
pair(!b.second.keyType, b.second.id);
}
-DNSSECPrivateKey DNSSECKeeper::getKeyById(const DNSName& zname, unsigned int id)
+DNSSECPrivateKey DNSSECKeeper::getKeyById(const ZoneName& zname, unsigned int id)
{
vector<DNSBackend::KeyData> keys;
d_keymetadb->getDomainKeys(zname, keys);
}
-bool DNSSECKeeper::removeKey(const DNSName& zname, unsigned int id)
+bool DNSSECKeeper::removeKey(const ZoneName& zname, unsigned int id)
{
return d_keymetadb->removeDomainKey(zname, id) && clearKeyCache(zname);
}
-bool DNSSECKeeper::deactivateKey(const DNSName& zname, unsigned int id)
+bool DNSSECKeeper::deactivateKey(const ZoneName& zname, unsigned int id)
{
return d_keymetadb->deactivateDomainKey(zname, id) && clearKeyCache(zname);
}
-bool DNSSECKeeper::activateKey(const DNSName& zname, unsigned int id)
+bool DNSSECKeeper::activateKey(const ZoneName& zname, unsigned int id)
{
return d_keymetadb->activateDomainKey(zname, id) && clearKeyCache(zname);
}
-bool DNSSECKeeper::unpublishKey(const DNSName& zname, unsigned int id)
+bool DNSSECKeeper::unpublishKey(const ZoneName& zname, unsigned int id)
{
return d_keymetadb->unpublishDomainKey(zname, id) && clearKeyCache(zname);
}
-bool DNSSECKeeper::publishKey(const DNSName& zname, unsigned int id)
+bool DNSSECKeeper::publishKey(const ZoneName& zname, unsigned int id)
{
return d_keymetadb->publishDomainKey(zname, id) && clearKeyCache(zname);
}
-void DNSSECKeeper::getFromMetaOrDefault(const DNSName& zname, const std::string& key, std::string& value, const std::string& defaultvalue)
+void DNSSECKeeper::getFromMetaOrDefault(const ZoneName& zname, const std::string& key, std::string& value, const std::string& defaultvalue)
{
if (getFromMeta(zname, key, value))
return;
value = defaultvalue;
}
-bool DNSSECKeeper::getFromMeta(const DNSName& zname, const std::string& key, std::string& value)
+bool DNSSECKeeper::getFromMeta(const ZoneName& zname, const std::string& key, std::string& value)
{
if (d_metaUpdate) {
if (d_keymetadb->inTransaction()) {
return ret;
}
-bool DNSSECKeeper::getFromMetaNoCache(const DNSName& name, const std::string& kind, std::string& value)
+bool DNSSECKeeper::getFromMetaNoCache(const ZoneName& name, const std::string& kind, std::string& value)
{
std::vector<std::string> meta;
if (d_keymetadb->getDomainMetadata(name, kind, meta)) {
return false;
}
-void DNSSECKeeper::getSoaEdit(const DNSName& zname, std::string& value, bool useCache)
+void DNSSECKeeper::getSoaEdit(const ZoneName& zname, std::string& value, bool useCache)
{
static const string soaEdit(::arg()["default-soa-edit"]);
static const string soaEditSigned(::arg()["default-soa-edit-signed"]);
return (uint64_t)-1;
}
-bool DNSSECKeeper::getNSEC3PARAM(const DNSName& zname, NSEC3PARAMRecordContent* ns3p, bool* narrow, bool useCache)
+bool DNSSECKeeper::getNSEC3PARAM(const ZoneName& zname, NSEC3PARAMRecordContent* ns3p, bool* narrow, bool useCache)
{
string value;
if(useCache) {
return ret;
}
-bool DNSSECKeeper::setNSEC3PARAM(const DNSName& zname, const NSEC3PARAMRecordContent& ns3p, const bool& narrow)
+bool DNSSECKeeper::setNSEC3PARAM(const ZoneName& zname, const NSEC3PARAMRecordContent& ns3p, const bool& narrow)
{
if (d_keymetadb->inTransaction()) {
d_metaUpdate = true;
return false;
}
-bool DNSSECKeeper::unsetNSEC3PARAM(const DNSName& zname)
+bool DNSSECKeeper::unsetNSEC3PARAM(const ZoneName& zname)
{
if (d_keymetadb->inTransaction()) {
d_metaUpdate = true;
}
-bool DNSSECKeeper::setPresigned(const DNSName& zname)
+bool DNSSECKeeper::setPresigned(const ZoneName& zname)
{
if (d_keymetadb->inTransaction()) {
d_metaUpdate = true;
return d_keymetadb->setDomainMetadata(zname, "PRESIGNED", meta) && clearMetaCache(zname);
}
-bool DNSSECKeeper::unsetPresigned(const DNSName& zname)
+bool DNSSECKeeper::unsetPresigned(const ZoneName& zname)
{
if (d_keymetadb->inTransaction()) {
d_metaUpdate = true;
/**
* Add domainmetadata to allow publishing CDS records for zone zname
*
- * @param zname DNSName of the zone
+ * @param zname ZoneName of the zone
* @param digestAlgos string with comma-separated numbers that describe the
* used digest algorithms. This is copied to the database
* verbatim
* @return true if the data was inserted, false otherwise
*/
-bool DNSSECKeeper::setPublishCDS(const DNSName& zname, const string& digestAlgos)
+bool DNSSECKeeper::setPublishCDS(const ZoneName& zname, const string& digestAlgos)
{
if (d_keymetadb->inTransaction()) {
d_metaUpdate = true;
return d_keymetadb->setDomainMetadata(zname, "PUBLISH-CDS", meta) && clearMetaCache(zname);
}
-void DNSSECKeeper::getPublishCDS(const DNSName& zname, std::string& value)
+void DNSSECKeeper::getPublishCDS(const ZoneName& zname, std::string& value)
{
getFromMetaOrDefault(zname, "PUBLISH-CDS", value, ::arg()["default-publish-cds"]);
}
/**
* Remove domainmetadata to stop publishing CDS records for zone zname
*
- * @param zname DNSName of the zone
+ * @param zname ZoneName of the zone
* @return true if the operation was successful, false otherwise
*/
-bool DNSSECKeeper::unsetPublishCDS(const DNSName& zname)
+bool DNSSECKeeper::unsetPublishCDS(const ZoneName& zname)
{
if (d_keymetadb->inTransaction()) {
d_metaUpdate = true;
/**
* Add domainmetadata to allow publishing CDNSKEY records.for zone zname
*
- * @param zname DNSName of the zone
+ * @param zname ZoneName of the zone
* @return true if the data was inserted, false otherwise
*/
-bool DNSSECKeeper::setPublishCDNSKEY(const DNSName& zname, bool deleteAlg)
+bool DNSSECKeeper::setPublishCDNSKEY(const ZoneName& zname, bool deleteAlg)
{
if (d_keymetadb->inTransaction()) {
d_metaUpdate = true;
return d_keymetadb->setDomainMetadata(zname, "PUBLISH-CDNSKEY", meta) && clearMetaCache(zname);
}
-void DNSSECKeeper::getPublishCDNSKEY(const DNSName& zname, std::string& value)
+void DNSSECKeeper::getPublishCDNSKEY(const ZoneName& zname, std::string& value)
{
getFromMetaOrDefault(zname, "PUBLISH-CDNSKEY", value, ::arg()["default-publish-cdnskey"]);
}
/**
* Remove domainmetadata to stop publishing CDNSKEY records for zone zname
*
- * @param zname DNSName of the zone
+ * @param zname ZoneName of the zone
* @return true if the operation was successful, false otherwise
*/
-bool DNSSECKeeper::unsetPublishCDNSKEY(const DNSName& zname)
+bool DNSSECKeeper::unsetPublishCDNSKEY(const ZoneName& zname)
{
if (d_keymetadb->inTransaction()) {
d_metaUpdate = true;
/**
* Returns all keys that are used to sign the DNSKEY RRSet in a zone
*
- * @param zname DNSName of the zone
+ * @param zname ZoneName of the zone
* @return a keyset_t with all keys that are used to sign the DNSKEY
* RRSet (these are the entrypoint(s) to the zone)
*/
-DNSSECKeeper::keyset_t DNSSECKeeper::getEntryPoints(const DNSName& zname)
+DNSSECKeeper::keyset_t DNSSECKeeper::getEntryPoints(const ZoneName& zname)
{
DNSSECKeeper::keyset_t ret;
DNSSECKeeper::keyset_t keys = getKeys(zname);
return ret;
}
-DNSSECKeeper::keyset_t DNSSECKeeper::getKeys(const DNSName& zone, bool useCache)
+DNSSECKeeper::keyset_t DNSSECKeeper::getKeys(const ZoneName& zone, bool useCache)
{
static int ttl = ::arg().asNum("dnssec-key-cache-ttl");
// coverity[store_truncates_time_t]
return retkeyset;
}
-bool DNSSECKeeper::checkKeys(const DNSName& zone, std::optional<std::reference_wrapper<std::vector<std::string>>> errorMessages)
+bool DNSSECKeeper::checkKeys(const ZoneName& zone, std::optional<std::reference_wrapper<std::vector<std::string>>> errorMessages)
{
vector<DNSBackend::KeyData> dbkeyset;
d_keymetadb->getDomainKeys(zone, dbkeyset);
}
}
-bool DNSSECKeeper::TSIGGrantsAccess(const DNSName& zone, const DNSName& keyname)
+bool DNSSECKeeper::TSIGGrantsAccess(const ZoneName& zone, const DNSName& keyname)
{
vector<string> allowed;
return false;
}
-bool DNSSECKeeper::getTSIGForAccess(const DNSName& zone, const ComboAddress& /* primary */, DNSName* keyname)
+bool DNSSECKeeper::getTSIGForAccess(const ZoneName& zone, const ComboAddress& /* primary */, DNSName* keyname)
{
vector<string> keynames;
d_keymetadb->getDomainMetadata(zone, "AXFR-MASTER-TSIG", keynames);
return false;
}
-bool DNSSECKeeper::unSecureZone(const DNSName& zone, string& error) {
+bool DNSSECKeeper::unSecureZone(const ZoneName& zone, string& error) {
// Not calling isSecuredZone(), as it will return false for zones with zero
// active keys.
DNSSECKeeper::keyset_t keyset=getKeys(zone);
* \param info& A string where informational messages are added
* \param doTransaction Whether or not to wrap the rectify in a transaction
*/
-bool DNSSECKeeper::rectifyZone(const DNSName& zone, string& error, string& info, bool doTransaction) {
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
+bool DNSSECKeeper::rectifyZone(const ZoneName& zone, string& error, string& info, bool doTransaction) {
if (isPresigned(zone, doTransaction)) {
error = "Rectify presigned zone '"+zone.toLogString()+"' is not allowed/necessary.";
return false;
// this is so the geoipbackend can set this pointer if loaded for lua-record.cc
std::function<std::string(const std::string&, int)> g_getGeo;
-bool DNSBackend::getAuth(const DNSName& target, SOAData* soaData)
+bool DNSBackend::getAuth(const ZoneName& target, SOAData* soaData)
{
return this->getSOA(target, *soaData);
}
\param sd SOAData which is filled with the SOA details
\param unmodifiedSerial bool if set, serial will be returned as stored in the backend (maybe 0)
*/
-bool DNSBackend::getSOA(const DNSName& domain, SOAData& soaData)
+bool DNSBackend::getSOA(const ZoneName& domain, SOAData& soaData)
{
this->lookup(QType(QType::SOA), domain, -1);
S.inc("backend-queries");
return true;
}
-bool DNSBackend::getBeforeAndAfterNames(uint32_t id, const DNSName& zonename, const DNSName& qname, DNSName& before, DNSName& after)
+bool DNSBackend::getBeforeAndAfterNames(uint32_t id, const ZoneName& zonename, const DNSName& qname, DNSName& before, DNSName& after)
{
DNSName unhashed;
bool ret = this->getBeforeAndAfterNamesAbsolute(id, qname.makeRelative(zonename).makeLowerCase(), unhashed, before, after);
{
DomainInfo() = default;
- DNSName zone;
- DNSName catalog;
+ ZoneName zone;
+ ZoneName catalog;
time_t last_check{};
string options;
string account;
if the backend does not consider itself responsible for the id passed.
\param domain_id ID of which a list is requested
*/
- virtual bool list(const DNSName& target, int domain_id, bool include_disabled = false) = 0;
+ virtual bool list(const ZoneName& target, int domain_id, bool include_disabled = false) = 0;
virtual ~DNSBackend() = default;
//! fills the soadata struct with the SOA details. Returns false if there is no SOA.
- virtual bool getSOA(const DNSName& domain, SOAData& soaData);
+ virtual bool getSOA(const ZoneName& domain, SOAData& soaData);
virtual bool replaceRRSet(uint32_t /* domain_id */, const DNSName& /* qname */, const QType& /* qt */, const vector<DNSResourceRecord>& /* rrset */)
{
return false;
}
- virtual bool listSubZone(const DNSName& /* zone */, int /* domain_id */)
+ virtual bool listSubZone(const ZoneName& /* zone */, int /* domain_id */)
{
return false;
}
{
return (name == "PRESIGNED" || name == "NSEC3PARAM" || name == "NSEC3NARROW");
}
- virtual bool getAllDomainMetadata(const DNSName& /* name */, std::map<std::string, std::vector<std::string>>& /* meta */) { return false; };
- virtual bool getDomainMetadata(const DNSName& /* name */, const std::string& /* kind */, std::vector<std::string>& /* meta */) { return false; }
- virtual bool getDomainMetadataOne(const DNSName& name, const std::string& kind, std::string& value)
+ virtual bool getAllDomainMetadata(const ZoneName& /* name */, std::map<std::string, std::vector<std::string>>& /* meta */) { return false; };
+ virtual bool getDomainMetadata(const ZoneName& /* name */, const std::string& /* kind */, std::vector<std::string>& /* meta */) { return false; }
+ virtual bool getDomainMetadataOne(const ZoneName& name, const std::string& kind, std::string& value)
{
std::vector<std::string> meta;
if (getDomainMetadata(name, kind, meta)) {
return false;
}
- virtual bool setDomainMetadata(const DNSName& /* name */, const std::string& /* kind */, const std::vector<std::string>& /* meta */) { return false; }
- virtual bool setDomainMetadataOne(const DNSName& name, const std::string& kind, const std::string& value)
+ virtual bool setDomainMetadata(const ZoneName& /* name */, const std::string& /* kind */, const std::vector<std::string>& /* meta */) { return false; }
+ virtual bool setDomainMetadataOne(const ZoneName& name, const std::string& kind, const std::string& value)
{
const std::vector<std::string> meta(1, value);
return setDomainMetadata(name, kind, meta);
virtual void getAllDomains(vector<DomainInfo>* domains, bool getSerial, bool include_disabled);
/** Determines if we are authoritative for a zone, and at what level */
- virtual bool getAuth(const DNSName& target, SOAData* /* sd */);
+ virtual bool getAuth(const ZoneName& target, SOAData* /* sd */);
struct KeyData
{
bool published{false};
};
- virtual bool getDomainKeys(const DNSName& /* name */, std::vector<KeyData>& /* keys */) { return false; }
- virtual bool removeDomainKey(const DNSName& /* name */, unsigned int /* id */) { return false; }
- virtual bool addDomainKey(const DNSName& /* name */, const KeyData& /* key */, int64_t& /* id */) { return false; }
- virtual bool activateDomainKey(const DNSName& /* name */, unsigned int /* id */) { return false; }
- virtual bool deactivateDomainKey(const DNSName& /* name */, unsigned int /* id */) { return false; }
- virtual bool publishDomainKey(const DNSName& /* name */, unsigned int /* id */) { return false; }
- virtual bool unpublishDomainKey(const DNSName& /* name */, unsigned int /* id */) { return false; }
+ virtual bool getDomainKeys(const ZoneName& /* name */, std::vector<KeyData>& /* keys */) { return false; }
+ virtual bool removeDomainKey(const ZoneName& /* name */, unsigned int /* id */) { return false; }
+ virtual bool addDomainKey(const ZoneName& /* name */, const KeyData& /* key */, int64_t& /* id */) { return false; }
+ virtual bool activateDomainKey(const ZoneName& /* name */, unsigned int /* id */) { return false; }
+ virtual bool deactivateDomainKey(const ZoneName& /* name */, unsigned int /* id */) { return false; }
+ virtual bool publishDomainKey(const ZoneName& /* name */, unsigned int /* id */) { return false; }
+ virtual bool unpublishDomainKey(const ZoneName& /* name */, unsigned int /* id */) { return false; }
virtual bool setTSIGKey(const DNSName& /* name */, const DNSName& /* algorithm */, const string& /* content */) { return false; }
virtual bool getTSIGKey(const DNSName& /* name */, DNSName& /* algorithm */, string& /* content */) { return false; }
return false;
}
- virtual bool getBeforeAndAfterNames(uint32_t /* id */, const DNSName& zonename, const DNSName& qname, DNSName& before, DNSName& after);
+ virtual bool getBeforeAndAfterNames(uint32_t /* id */, const ZoneName& zonename, const DNSName& qname, DNSName& before, DNSName& after);
virtual bool updateDNSSECOrderNameAndAuth(uint32_t /* domain_id */, const DNSName& /* qname */, const DNSName& /* ordername */, bool /* auth */, const uint16_t /* qtype */ = QType::ANY)
{
}
//! returns true if primary ip is primary for domain name.
- //! starts the transaction for updating domain qname (FIXME: what is id?)
- virtual bool startTransaction(const DNSName& /* qname */, int /* id */ = -1)
+ //! starts the transaction for updating domain qname, destroying all
+ //! existing data for that domain if id is >= 0. In this case, the id MUST
+ //! match the DomainInfo information for qname, or very bad things will
+ //! happen.
+ //! FIXME: replace this with a bool to make this a less error-prone interface.
+ virtual bool startTransaction(const ZoneName& /* qname */, int /* id */ = -1)
{
return false;
}
}
//! if this returns true, DomainInfo di contains information about the domain
- virtual bool getDomainInfo(const DNSName& /* domain */, DomainInfo& /* di */, bool /* getSerial */ = true)
+ virtual bool getDomainInfo(const ZoneName& /* domain */, DomainInfo& /* di */, bool /* getSerial */ = true)
{
return false;
}
}
//! get a list of IP addresses that should also be notified for a domain
- virtual void alsoNotifies(const DNSName& domain, set<string>* ips)
+ virtual void alsoNotifies(const ZoneName& domain, set<string>* ips)
{
std::vector<std::string> meta;
getDomainMetadata(domain, "ALSO-NOTIFY", meta);
}
//! get list of all members in a catalog
- [[nodiscard]] virtual bool getCatalogMembers(const DNSName& /* catalog */, vector<CatalogInfo>& /* members */, CatalogInfo::CatalogType /* type */)
+ [[nodiscard]] virtual bool getCatalogMembers(const ZoneName& /* catalog */, vector<CatalogInfo>& /* members */, CatalogInfo::CatalogType /* type */)
{
return false;
}
}
//! Called when the Primary list of a domain should be changed
- virtual bool setPrimaries(const DNSName& /* domain */, const vector<ComboAddress>& /* primaries */)
+ virtual bool setPrimaries(const ZoneName& /* domain */, const vector<ComboAddress>& /* primaries */)
{
return false;
}
//! Called when the Kind of a domain should be changed (primary -> native and similar)
- virtual bool setKind(const DNSName& /* domain */, const DomainInfo::DomainKind /* kind */)
+ virtual bool setKind(const ZoneName& /* domain */, const DomainInfo::DomainKind /* kind */)
{
return false;
}
//! Called when the options of a domain should be changed
- virtual bool setOptions(const DNSName& /* domain */, const string& /* options */)
+ virtual bool setOptions(const ZoneName& /* domain */, const string& /* options */)
{
return false;
}
//! Called when the catalog of a domain should be changed
- virtual bool setCatalog(const DNSName& /* domain */, const DNSName& /* catalog */)
+ virtual bool setCatalog(const ZoneName& /* domain */, const ZoneName& /* catalog */)
{
return false;
}
//! Called when the Account of a domain should be changed
- virtual bool setAccount(const DNSName& /* domain */, const string& /* account */)
+ virtual bool setAccount(const ZoneName& /* domain */, const string& /* account */)
{
return false;
}
}
//! determine if ip is a autoprimary or a domain
- virtual bool autoPrimaryBackend(const string& /* ip */, const DNSName& /* domain */, const vector<DNSResourceRecord>& /* nsset */, string* /* nameserver */, string* /* account */, DNSBackend** /* db */)
+ virtual bool autoPrimaryBackend(const string& /* ip */, const ZoneName& /* domain */, const vector<DNSResourceRecord>& /* nsset */, string* /* nameserver */, string* /* account */, DNSBackend** /* db */)
{
return false;
}
//! called by PowerDNS to create a new domain
- virtual bool createDomain(const DNSName& /* domain */, const DomainInfo::DomainKind /* kind */, const vector<ComboAddress>& /* primaries */, const string& /* account */)
+ virtual bool createDomain(const ZoneName& /* domain */, const DomainInfo::DomainKind /* kind */, const vector<ComboAddress>& /* primaries */, const string& /* account */)
{
return false;
}
//! called by PowerDNS to create a secondary record for a autoPrimary
- virtual bool createSecondaryDomain(const string& /* ip */, const DNSName& /* domain */, const string& /* nameserver */, const string& /* account */)
+ virtual bool createSecondaryDomain(const string& /* ip */, const ZoneName& /* domain */, const string& /* nameserver */, const string& /* account */)
{
return false;
}
//! called to delete a domain, incl. all metadata, zone contents, etc.
- virtual bool deleteDomain(const DNSName& /* domain */)
+ virtual bool deleteDomain(const ZoneName& /* domain */)
{
return false;
}
void DNSName::toString(std::string& output, const std::string& separator, const bool trailing) const
{
if (empty()) {
- throw std::out_of_range("Attempt to print an unset dnsname");
+ throw std::out_of_range("Attempt to print an unset DNSName");
}
if (isRoot()) {
std::string DNSName::toDNSString() const
{
if (empty()) {
- throw std::out_of_range("Attempt to DNSString an unset dnsname");
+ throw std::out_of_range("Attempt to DNSString an unset DNSName");
}
return std::string(d_storage.c_str(), d_storage.length());
bool DNSName::isPartOf(const DNSName& parent) const
{
if(parent.empty() || empty()) {
- throw std::out_of_range("empty dnsnames aren't part of anything");
+ throw std::out_of_range("empty DNSNames aren't part of anything");
}
if(parent.d_storage.size() > d_storage.size()) {
return true;
}
if (static_cast<uint8_t>(*us) > 63) {
- throw std::out_of_range("illegal label length in dnsname");
+ throw std::out_of_range("illegal label length in DNSName");
}
}
return false;
#include "burtle.hh"
#include "views.hh"
-// #include "dns.hh"
-// #include "logger.hh"
-
-//#include <ext/vstring.h>
-
/* Quest in life:
accept escaped ascii presentations of DNS names and store them "natively"
accept a DNS packet with an offset, and extract a DNS name from it
NOTE: For now, everything MUST be . terminated, otherwise it is an error
*/
+// DNSName: represents a case-insensitive string, allowing for non-printable
+// characters. It is used for all kinds of name (of hosts, domains, keys,
+// algorithm...) overall the PowerDNS codebase.
+//
+// The following type traits are provided:
+// - EqualityComparable
+// - LessThanComparable
+// - Hash
class DNSName
{
public:
extern const DNSName g_rootdnsname, g_wildcarddnsname;
+// ZoneName: this is equivalent to DNSName, but intended to only store zone
+// names. For the time being, they are strictly identical.
+using ZoneName = DNSName;
+using CanonZoneNameCompare = CanonDNSNameCompare;
+
template<typename T>
struct SuffixMatchTree
{
DNSName qdomain; //!< qname of the question 4 - unsure how this is used
DNSName qdomainwild; //!< wildcard matched by qname, used by LuaPolicyEngine
- DNSName qdomainzone; //!< zone name for the answer (as reflected in SOA for negative responses), used by LuaPolicyEngine
+ ZoneName qdomainzone; //!< zone name for the answer (as reflected in SOA for negative responses), used by LuaPolicyEngine
string d_peer_principal;
const DNSName& getTSIGKeyname() const;
public:
static void report(const ReportIsOnlyCallableByReportAllTypes& guard);
NSECRecordContent() = default;
- NSECRecordContent(const string& content, const DNSName& zone=DNSName());
+ NSECRecordContent(const string& content, const ZoneName& zone=ZoneName());
static std::shared_ptr<DNSRecordContent> make(const DNSRecord &dr, PacketReader& pr);
static std::shared_ptr<DNSRecordContent> make(const string& content);
public:
static void report(const ReportIsOnlyCallableByReportAllTypes& guard);
NSEC3RecordContent() = default;
- NSEC3RecordContent(const string& content, const DNSName& zone=DNSName());
+ NSEC3RecordContent(const string& content, const ZoneName& zone=ZoneName());
static std::shared_ptr<DNSRecordContent> make(const DNSRecord &dr, PacketReader& pr);
static std::shared_ptr<DNSRecordContent> make(const string& content);
public:
static void report(const ReportIsOnlyCallableByReportAllTypes& guard);
CSYNCRecordContent() = default;
- CSYNCRecordContent(const string& content, const DNSName& zone=DNSName());
+ CSYNCRecordContent(const string& content, const ZoneName& zone=ZoneName());
static std::shared_ptr<DNSRecordContent> make(const DNSRecord &dr, PacketReader& pr);
static std::shared_ptr<DNSRecordContent> make(const string& content);
public:
static void report(const ReportIsOnlyCallableByReportAllTypes& guard);
NSEC3PARAMRecordContent() = default;
- NSEC3PARAMRecordContent(const string& content, const DNSName& zone=DNSName());
+ NSEC3PARAMRecordContent(const string& content, const ZoneName& zone=ZoneName());
static std::shared_ptr<DNSRecordContent> make(const DNSRecord &dr, PacketReader& pr);
static std::shared_ptr<DNSRecordContent> make(const string& content);
void incrementHash(std::string& raw);
void decrementHash(std::string& raw);
-void addRRSigs(DNSSECKeeper& dk, UeberBackend& db, const std::set<DNSName>& authSet, vector<DNSZoneRecord>& rrs, DNSPacket* packet=nullptr);
+void addRRSigs(DNSSECKeeper& dk, UeberBackend& db, 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);
static uint64_t dbdnssecCacheSizes(const std::string& str);
static void clearAllCaches();
- static bool clearKeyCache(const DNSName& name);
- static bool clearMetaCache(const DNSName& name);
- static void clearCaches(const DNSName& name);
+ static bool clearKeyCache(const ZoneName& name);
+ static bool clearMetaCache(const ZoneName& name);
+ static void clearCaches(const ZoneName& name);
bool doesDNSSEC();
- bool isSecuredZone(const DNSName& zone, bool useCache=true);
- keyset_t getEntryPoints(const DNSName& zname);
- keyset_t getKeys(const DNSName& zone, bool useCache = true);
- DNSSECPrivateKey getKeyById(const DNSName& zone, unsigned int id);
- bool addKey(const DNSName& zname, bool setSEPBit, int algorithm, int64_t& id, int bits=0, bool active=true, bool published=true);
- bool addKey(const DNSName& zname, const DNSSECPrivateKey& dpk, int64_t& id, bool active=true, bool published=true);
- bool removeKey(const DNSName& zname, unsigned int id);
- bool activateKey(const DNSName& zname, unsigned int id);
- bool deactivateKey(const DNSName& zname, unsigned int id);
- bool publishKey(const DNSName& zname, unsigned int id);
- bool unpublishKey(const DNSName& zname, unsigned int id);
- bool checkKeys(const DNSName& zname, std::optional<std::reference_wrapper<std::vector<std::string>>> errorMessages);
-
- bool getNSEC3PARAM(const DNSName& zname, NSEC3PARAMRecordContent* n3p=nullptr, bool* narrow=nullptr, bool useCache=true);
+ bool isSecuredZone(const ZoneName& zone, bool useCache=true);
+ keyset_t getEntryPoints(const ZoneName& zname);
+ keyset_t getKeys(const ZoneName& zone, bool useCache = true);
+ DNSSECPrivateKey getKeyById(const ZoneName& zone, unsigned int id);
+ bool addKey(const ZoneName& zname, bool setSEPBit, int algorithm, int64_t& id, int bits=0, bool active=true, bool published=true);
+ bool addKey(const ZoneName& zname, const DNSSECPrivateKey& dpk, int64_t& id, bool active=true, bool published=true);
+ bool removeKey(const ZoneName& zname, unsigned int id);
+ bool activateKey(const ZoneName& zname, unsigned int id);
+ bool deactivateKey(const ZoneName& zname, unsigned int id);
+ bool publishKey(const ZoneName& zname, unsigned int id);
+ bool unpublishKey(const ZoneName& zname, unsigned int id);
+ bool checkKeys(const ZoneName& zname, std::optional<std::reference_wrapper<std::vector<std::string>>> errorMessages);
+
+ bool getNSEC3PARAM(const ZoneName& zname, NSEC3PARAMRecordContent* n3p=nullptr, bool* narrow=nullptr, bool useCache=true);
bool checkNSEC3PARAM(const NSEC3PARAMRecordContent& ns3p, string& msg);
- bool setNSEC3PARAM(const DNSName& zname, const NSEC3PARAMRecordContent& n3p, const bool& narrow=false);
- bool unsetNSEC3PARAM(const DNSName& zname);
+ bool setNSEC3PARAM(const ZoneName& zname, const NSEC3PARAMRecordContent& n3p, const bool& narrow=false);
+ bool unsetNSEC3PARAM(const ZoneName& zname);
void getPreRRSIGs(UeberBackend& db, vector<DNSZoneRecord>& rrs, uint32_t signTTL, DNSPacket* p=nullptr);
- bool isPresigned(const DNSName& zname, bool useCache=true);
- bool setPresigned(const DNSName& zname);
- bool unsetPresigned(const DNSName& zname);
- bool setPublishCDNSKEY(const DNSName& zname, bool deleteAlg);
- void getPublishCDNSKEY(const DNSName& zname, std::string& value);
- bool unsetPublishCDNSKEY(const DNSName& zname);
- bool setPublishCDS(const DNSName& zname, const string& digestAlgos);
- void getPublishCDS(const DNSName& zname, std::string& value);
- bool unsetPublishCDS(const DNSName& zname);
-
- bool TSIGGrantsAccess(const DNSName& zone, const DNSName& keyname);
- bool getTSIGForAccess(const DNSName& zone, const ComboAddress& primary, DNSName* keyname);
-
- void startTransaction(const DNSName& zone, int zone_id)
+ bool isPresigned(const ZoneName& zname, bool useCache=true);
+ bool setPresigned(const ZoneName& zname);
+ bool unsetPresigned(const ZoneName& zname);
+ bool setPublishCDNSKEY(const ZoneName& zname, bool deleteAlg);
+ void getPublishCDNSKEY(const ZoneName& zname, std::string& value);
+ bool unsetPublishCDNSKEY(const ZoneName& zname);
+ bool setPublishCDS(const ZoneName& zname, const string& digestAlgos);
+ void getPublishCDS(const ZoneName& zname, std::string& value);
+ bool unsetPublishCDS(const ZoneName& zname);
+
+ bool TSIGGrantsAccess(const ZoneName& zone, const DNSName& keyname);
+ bool getTSIGForAccess(const ZoneName& zone, const ComboAddress& primary, DNSName* keyname);
+
+ void startTransaction(const ZoneName& zone, int zone_id)
{
(*d_keymetadb->backends.begin())->startTransaction(zone, zone_id);
}
(*d_keymetadb->backends.begin())->commitTransaction();
}
- void getFromMetaOrDefault(const DNSName& zname, const std::string& key, std::string& value, const std::string& defaultvalue);
- bool getFromMeta(const DNSName& zname, const std::string& key, std::string& value);
- void getSoaEdit(const DNSName& zname, std::string& value, bool useCache=true);
- bool unSecureZone(const DNSName& zone, std::string& error);
- bool rectifyZone(const DNSName& zone, std::string& error, std::string& info, bool doTransaction);
+ void getFromMetaOrDefault(const ZoneName& zname, const std::string& key, std::string& value, const std::string& defaultvalue);
+ bool getFromMeta(const ZoneName& zname, const std::string& key, std::string& value);
+ void getSoaEdit(const ZoneName& zname, std::string& value, bool useCache=true);
+ bool unSecureZone(const ZoneName& zone, std::string& error);
+ bool rectifyZone(const ZoneName& zone, std::string& error, std::string& info, bool doTransaction);
static void setMaxEntries(size_t maxEntries);
typedef std::map<std::string, std::vector<std::string> > METAValues;
private:
- bool getFromMetaNoCache(const DNSName& name, const std::string& kind, std::string& value);
+ bool getFromMetaNoCache(const ZoneName& name, const std::string& kind, std::string& value);
int64_t d_metaCacheCleanAction{0};
bool d_metaUpdate{false};
return d_ttd < now;
}
- DNSName d_domain;
+ ZoneName d_domain;
mutable keys_t d_keys;
unsigned int d_ttd;
};
return d_ttd < now;
}
- DNSName d_domain;
+ ZoneName d_domain;
mutable METAValues d_value;
time_t d_ttd;
};
typedef multi_index_container<
KeyCacheEntry,
indexed_by<
- hashed_unique<tag<KeyCacheTag>,member<KeyCacheEntry, DNSName, &KeyCacheEntry::d_domain> >,
+ hashed_unique<tag<KeyCacheTag>,member<KeyCacheEntry, ZoneName, &KeyCacheEntry::d_domain> >,
sequenced<tag<SequencedTag>>
>
> keycache_t;
typedef multi_index_container<
METACacheEntry,
indexed_by<
- ordered_unique<member<METACacheEntry, DNSName, &METACacheEntry::d_domain> >,
+ ordered_unique<member<METACacheEntry, ZoneName, &METACacheEntry::d_domain> >,
sequenced<tag<SequencedTag>>
>
> metacache_t;
uint32_t localtime_format_YYYYMMDDSS(time_t t, uint32_t seq);
// for SOA-EDIT
-uint32_t calculateEditSOA(uint32_t old_serial, DNSSECKeeper& dk, const DNSName& zonename);
-uint32_t calculateEditSOA(uint32_t old_serial, const string& kind, const DNSName& zonename);
+uint32_t calculateEditSOA(uint32_t old_serial, DNSSECKeeper& dk, const ZoneName& zonename);
+uint32_t calculateEditSOA(uint32_t old_serial, const string& kind, const ZoneName& zonename);
// for SOA-EDIT-DNSUPDATE/API
bool increaseSOARecord(DNSResourceRecord& dr, const string& increaseKind, const string& editKind);
bool makeIncreasedSOARecord(SOAData& sd, const string& increaseKind, const string& editKind, DNSResourceRecord& rrout);
/* this is where the RRSIGs begin, keys are retrieved,
but the actual signing happens in fillOutRRSIG */
-static int getRRSIGsForRRSET(DNSSECKeeper& dk, const DNSName& signer, const DNSName& signQName, uint16_t signQType, uint32_t signTTL,
+static int getRRSIGsForRRSET(DNSSECKeeper& dk, const ZoneName& signer, const DNSName& signQName, uint16_t signQType, uint32_t signTTL,
const sortedRecords_t& toSign, vector<RRSIGRecordContent>& rrcs)
{
if(toSign.empty())
}
// this is the entrypoint from DNSPacket
-static void addSignature(DNSSECKeeper& dk, UeberBackend& db, const DNSName& signer, const DNSName& signQName, const DNSName& wildcardname, uint16_t signQType,
+static void addSignature(DNSSECKeeper& dk, UeberBackend& db, const ZoneName& signer, const DNSName& signQName, const DNSName& wildcardname, uint16_t signQType,
uint32_t signTTL, DNSResourceRecord::Place signPlace,
sortedRecords_t& toSign, vector<DNSZoneRecord>& outsigned, uint32_t origTTL, DNSPacket* packet)
{
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<DNSName>& authSet, const DNSName& name, DNSName& auth)
+static bool getBestAuthFromSet(const set<ZoneName>& authSet, const DNSName& name, ZoneName& auth)
{
auth.trimToLabels(0);
- DNSName sname(name);
+ ZoneName sname(name);
do {
if(authSet.find(sname) != authSet.end()) {
auth = sname;
return false;
}
-void addRRSigs(DNSSECKeeper& dk, UeberBackend& db, const set<DNSName>& authSet, vector<DNSZoneRecord>& rrs, DNSPacket* packet)
+void addRRSigs(DNSSECKeeper& dk, UeberBackend& db, const set<ZoneName>& authSet, vector<DNSZoneRecord>& rrs, DNSPacket* packet)
{
stable_sort(rrs.begin(), rrs.end(), rrsigncomp);
vector<DNSZoneRecord> signedRecords;
signedRecords.reserve(rrs.size()*1.5);
// cout<<rrs.size()<<", "<<sizeof(DNSZoneRecord)<<endl;
- DNSName signer;
+ ZoneName signer;
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))
g_log<<Logger::Warning<<"Cache clear request for '"<<*i<<"' received from operator"<<endl;
ret+=purgeAuthCaches(*i);
if(!boost::ends_with(*i, "$"))
- DNSSECKeeper::clearCaches(DNSName(*i));
+ DNSSECKeeper::clearCaches(ZoneName(*i));
else
DNSSECKeeper::clearAllCaches(); // at least we do what we promise.. and a bit more!
}
if(parts.size()!=2 && parts.size()!=3)
return "syntax: retrieve zone [ip]";
- DNSName domain;
+ ZoneName domain;
try {
- domain = DNSName(parts[1]);
+ domain = ZoneName(parts[1]);
} catch (...) {
return "Failed to parse zone as valid DNS name";
}
if(!::arg().mustDo("primary") && !(::arg().mustDo("secondary") && ::arg().mustDo("secondary-do-renotify")))
return "PowerDNS not configured as primary, or secondary with re-notifications";
- DNSName domain;
+ ZoneName domain;
try {
- domain = DNSName(parts[1]);
+ domain = ZoneName(parts[1]);
} catch (...) {
return "Failed to parse zone as valid DNS name";
}
return std::to_string(notified)+" out of "+std::to_string(total)+" zones added to queue - see log";
return "Added " + std::to_string(total) + " MASTER/SLAVE/PRODUCER/CONSUMER zones to queue";
} else {
- DNSName domain;
+ ZoneName domain;
try {
- domain = DNSName(parts[1]);
+ domain = ZoneName(parts[1]);
} catch (...) {
return "Failed to parse zone as valid DNS name";
}
- if(!Communicator.notifyDomain(DNSName(parts[1]), &B))
+ if(!Communicator.notifyDomain(domain, &B))
return "Failed to add to the queue - see log";
return "Added to queue";
}
std::string getStats();
- void setSOASerial(const DNSName& d, const uint32_t serial) {
+ void setSOASerial(const ZoneName& d, const uint32_t serial) {
auto stat = getRegisteredDomain(d);
stat->second.currentSOA = serial;
stat->second.haveZone = true;
}
- void incrementSOAChecks(const DNSName& d, const uint64_t amount = 1) {
+ void incrementSOAChecks(const ZoneName& d, const uint64_t amount = 1) {
getRegisteredDomain(d)->second.numSOAChecks += amount;
}
- void incrementSOAChecksFailed(const DNSName& d, const uint64_t amount = 1) {
+ void incrementSOAChecksFailed(const ZoneName& d, const uint64_t amount = 1) {
getRegisteredDomain(d)->second.numSOAChecksFailed += amount;
}
- void incrementSOAinQueries(const DNSName& d, const uint64_t amount = 1) {
+ void incrementSOAinQueries(const ZoneName& d, const uint64_t amount = 1) {
getRegisteredDomain(d)->second.numSOAinQueries += amount;
}
- void incrementAXFRinQueries(const DNSName& d, const uint64_t amount = 1) {
+ void incrementAXFRinQueries(const ZoneName& d, const uint64_t amount = 1) {
getRegisteredDomain(d)->second.numAXFRinQueries += amount;
}
- void incrementIXFRinQueries(const DNSName& d, const uint64_t amount = 1) {
+ void incrementIXFRinQueries(const ZoneName& d, const uint64_t amount = 1) {
getRegisteredDomain(d)->second.numIXFRinQueries += amount;
}
- void incrementAXFRFailures(const DNSName& d, const uint64_t amount = 1) {
+ void incrementAXFRFailures(const ZoneName& d, const uint64_t amount = 1) {
getRegisteredDomain(d)->second.numAXFRFailures += amount;
}
- void incrementIXFRFailures(const DNSName& d, const uint64_t amount = 1) {
+ void incrementIXFRFailures(const ZoneName& d, const uint64_t amount = 1) {
getRegisteredDomain(d)->second.numIXFRFailures += amount;
}
- void registerDomain(const DNSName& d) {
+ void registerDomain(const ZoneName& d) {
domainStats[d].haveZone = false;
}
- void incrementUnknownDomainInQueries(const DNSName& /* d */)
+ void incrementUnknownDomainInQueries(const ZoneName& /* d */)
{ // the name is ignored. It would be great to report it, but we don't want to blow up Prometheus
progStats.unknownDomainInQueries += 1;
}
std::atomic<uint32_t> unknownDomainInQueries{0};
};
- std::map<DNSName, perDomainStat> domainStats;
+ std::map<ZoneName, perDomainStat> domainStats;
std::array<std::atomic<uint64_t>, 16> notimpStats{};
programStats progStats;
- std::map<DNSName, perDomainStat>::iterator getRegisteredDomain(const DNSName& d) {
+ std::map<ZoneName, perDomainStat>::iterator getRegisteredDomain(const DNSName& d) {
auto ret = domainStats.find(d);
if (ret == domainStats.end()) {
throw PDNSException("Domain '" + d.toLogString() + "' not defined in the statistics map");
}
/* END Needed because of deeper dependencies */
-// Allows reading/writing ComboAddresses and DNSNames in YAML-cpp
+// Allows reading/writing ComboAddresses and ZoneNames in YAML-cpp
namespace YAML {
template<>
struct convert<ComboAddress> {
};
template<>
-struct convert<DNSName> {
- static Node encode(const DNSName& rhs) {
+struct convert<ZoneName> {
+ static Node encode(const ZoneName& rhs) {
return Node(rhs.toStringRootDot());
}
- static bool decode(const Node& node, DNSName& rhs) {
+ static bool decode(const Node& node, ZoneName& rhs) {
if (!node.IsScalar()) {
return false;
}
try {
- rhs = DNSName(node.as<string>());
+ rhs = ZoneName(node.as<string>());
return true;
} catch(const runtime_error &e) {
return false;
};
// This contains the configuration for each domain
-static map<DNSName, ixfrdistdomain_t> g_domainConfigs;
+static map<ZoneName, ixfrdistdomain_t> g_domainConfigs;
// Map domains and their data
-static LockGuarded<std::map<DNSName, std::shared_ptr<ixfrinfo_t>>> g_soas;
+static LockGuarded<std::map<ZoneName, std::shared_ptr<ixfrinfo_t>>> g_soas;
// Queue of received NOTIFYs, already verified against their primary IPs
// Lazily implemented as a set
-static LockGuarded<std::set<DNSName>> g_notifiesReceived;
+static LockGuarded<std::set<ZoneName>> g_notifiesReceived;
// Queue of outgoing NOTIFY
static LockGuarded<NotificationQueue> g_notificationQueue;
return rfc1982LessThan(i, j);
}
-static void cleanUpDomain(const DNSName& domain, const uint16_t& keep, const string& workdir) {
+static void cleanUpDomain(const ZoneName& domain, const uint16_t& keep, const string& workdir) {
string dir = workdir + "/" + domain.toString();
vector<uint32_t> zoneVersions;
auto directoryError = pdns::visit_directory(dir, [&zoneVersions]([[maybe_unused]] ino_t inodeNumber, const std::string_view& name) {
}
/* you can _never_ alter the content of the resulting shared pointer */
-static std::shared_ptr<ixfrinfo_t> getCurrentZoneInfo(const DNSName& domain)
+static std::shared_ptr<ixfrinfo_t> getCurrentZoneInfo(const ZoneName& domain)
{
return (*g_soas.lock())[domain];
}
-static void updateCurrentZoneInfo(const DNSName& domain, std::shared_ptr<ixfrinfo_t>& newInfo)
+static void updateCurrentZoneInfo(const ZoneName& domain, std::shared_ptr<ixfrinfo_t>& newInfo)
{
auto soas = g_soas.lock();
(*soas)[domain] = newInfo;
// FIXME: also report zone size?
}
-static void sendNotification(int sock, const DNSName& domain, const ComboAddress& remote, uint16_t notificationId)
+static void sendNotification(int sock, const ZoneName& domain, const ComboAddress& remote, uint16_t notificationId)
{
std::vector<std::string> meta;
std::vector<uint8_t> packet;
static void communicatorSendNotifications(const int sock4, const int sock6)
{
- DNSName domain;
+ ZoneName domain;
string destinationIp;
uint16_t notificationId = 0;
bool purged{false};
static void updateThread(const string& workdir, const uint16_t& keep, const uint16_t& axfrTimeout, const uint16_t& soaRetry, const uint32_t axfrMaxRecords) { // NOLINT(readability-function-cognitive-complexity) 13400 https://github.com/PowerDNS/pdns/issues/13400 Habbie: ixfrdist: reduce complexity
setThreadName("ixfrdist/update");
- std::map<DNSName, time_t> lastCheck;
+ std::map<ZoneName, time_t> lastCheck;
// Initialize the serials we have
for (const auto &domainConfig : g_domainConfigs) {
- DNSName domain = domainConfig.first;
+ ZoneName domain = domainConfig.first;
lastCheck[domain] = 0;
string dir = workdir + "/" + domain.toString();
try {
break;
}
- DNSName domain = domainConfig.first;
+ ZoneName domain = domainConfig.first;
shared_ptr<const SOARecordContent> current_soa;
const auto& zoneInfo = getCurrentZoneInfo(domain);
if (zoneInfo != nullptr) {
retval = false;
continue;
}
- domain["domain"].as<DNSName>();
+ domain["domain"].as<ZoneName>();
} catch (const runtime_error &e) {
g_log<<Logger::Error<<"Unable to read domain '"<<domain["domain"].as<string>()<<"': "<<e.what()<<endl;
}
for (auto const &domain : config["domains"]) {
set<ComboAddress> s;
s.insert(domain["master"].as<ComboAddress>());
- g_domainConfigs[domain["domain"].as<DNSName>()].primaries = s;
+ g_domainConfigs[domain["domain"].as<ZoneName>()].primaries = s;
if (domain["max-soa-refresh"].IsDefined()) {
- g_domainConfigs[domain["domain"].as<DNSName>()].maxSOARefresh = domain["max-soa-refresh"].as<uint32_t>();
+ g_domainConfigs[domain["domain"].as<ZoneName>()].maxSOARefresh = domain["max-soa-refresh"].as<uint32_t>();
}
if (domain["notify"].IsDefined()) {
- auto& listset = g_domainConfigs[domain["domain"].as<DNSName>()].notify;
+ auto& listset = g_domainConfigs[domain["domain"].as<ZoneName>()].notify;
if (domain["notify"].IsScalar()) {
auto remote = domain["notify"].as<std::string>();
try {
}
}
}
- g_stats.registerDomain(domain["domain"].as<DNSName>());
+ g_stats.registerDomain(domain["domain"].as<ZoneName>());
}
for (const auto &addr : config["acl"].as<vector<string>>()) {
#include "zoneparser-tng.hh"
#include "dnsparser.hh"
-uint32_t getSerialFromPrimary(const ComboAddress& primary, const DNSName& 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>& sr, const TSIGTriplet& tt, const uint16_t timeout)
{
vector<uint8_t> packet;
DNSPacketWriter pw(packet, zone, QType::SOA);
}
}
-void writeZoneToDisk(const records_t& records, const DNSName& zone, const std::string& directory)
+void writeZoneToDisk(const records_t& records, const ZoneName& zone, const std::string& directory)
{
DNSRecord soa;
auto serial = getSerialFromRecords(records, soa);
}
}
-void loadZoneFromDisk(records_t& records, const string& fname, const DNSName& zone)
+void loadZoneFromDisk(records_t& records, const string& fname, const ZoneName& zone)
{
ZoneParserTNG zpt(fname, zone);
* Load the zone `zone` from `fname` and put the first found SOA into `soa`
* Does NOT check for nullptr
*/
-void loadSOAFromDisk(const DNSName& zone, const string& fname, shared_ptr<const SOARecordContent>& soa, uint32_t& soaTTL)
+void loadSOAFromDisk(const ZoneName& zone, const string& fname, shared_ptr<const SOARecordContent>& soa, uint32_t& soaTTL)
{
ZoneParserTNG zpt(fname, zone);
zpt.disableGenerate();
> /* indexed_by */
> /* multi_index_container */ records_t;
-uint32_t getSerialFromPrimary(const ComboAddress& primary, const DNSName& 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>& sr, const TSIGTriplet& tt = TSIGTriplet(), const uint16_t timeout = 2);
uint32_t getSerialFromDir(const std::string& dir);
uint32_t getSerialFromRecords(const records_t& records, DNSRecord& soaret);
-void writeZoneToDisk(const records_t& records, const DNSName& zone, const std::string& directory);
-void loadZoneFromDisk(records_t& records, const string& fname, const DNSName& zone);
-void loadSOAFromDisk(const DNSName& zone, const string& fname, shared_ptr<const SOARecordContent>& soa, uint32_t& soaTTL);
+void writeZoneToDisk(const records_t& records, const ZoneName& zone, const std::string& directory);
+void loadZoneFromDisk(records_t& records, const string& fname, const ZoneName& zone);
+void loadSOAFromDisk(const ZoneName& zone, const string& fname, shared_ptr<const SOARecordContent>& soa, uint32_t& soaTTL);
}
if(command=="diff") {
records_t before, after;
- DNSName zone(argv[2]);
+ ZoneName zone(argv[2]);
cout<<"Loading before from "<<argv[3]<<endl;
loadZoneFromDisk(before, argv[3], zone);
cout<<"Parsed "<<before.size()<<" records"<<endl;
Next up, loop this every REFRESH seconds */
- DNSName zone(argv[4]);
+ ZoneName zone(argv[4]);
ComboAddress primary(argv[2], atoi(argv[3]));
string directory(argv[5]);
records_t records;
return ret;
}
-static bool getAuth(const DNSName& name, uint16_t qtype, SOAData* soaData)
+static bool getAuth(const ZoneName& name, uint16_t qtype, SOAData* soaData)
{
static LockGuarded<UeberBackend> s_ub;
static vector<string> lua_dblookup(const string& record, uint16_t qtype)
{
- DNSName rec;
+ ZoneName rec;
vector<string> ret;
try {
- rec = DNSName(record);
+ rec = ZoneName(record);
}
catch (const std::exception& e) {
g_log << Logger::Error << "DB lookup cannot be performed, the name (" << record << ") is malformed: " << e.what() << endl;
#include "namespaces.hh"
class DNSName;
+using ZoneName = DNSName;
// Do not change to "using TSIGHashEnum ..." until you know CodeQL does not choke on it
typedef enum
return qname[qname.size()-1]=='.';
}
-inline DNSName toCanonic(const DNSName& zone, const string& qname)
+inline DNSName toCanonic(const ZoneName& zone, const string& qname)
{
if(qname.size()==1 && qname[0]=='@')
return zone;
return std::make_shared<NSECRecordContent>(content);
}
-NSECRecordContent::NSECRecordContent(const string& content, const DNSName& zone)
+NSECRecordContent::NSECRecordContent(const string& content, const ZoneName& zone)
{
RecordTextReader rtr(content, zone);
rtr.xfrName(d_next);
return std::make_shared<NSEC3RecordContent>(content);
}
-NSEC3RecordContent::NSEC3RecordContent(const string& content, const DNSName& zone)
+NSEC3RecordContent::NSEC3RecordContent(const string& content, const ZoneName& zone)
{
RecordTextReader rtr(content, zone);
rtr.xfr8BitInt(d_algorithm);
return std::make_shared<NSEC3PARAMRecordContent>(content);
}
-NSEC3PARAMRecordContent::NSEC3PARAMRecordContent(const string& content, const DNSName& zone)
+NSEC3PARAMRecordContent::NSEC3PARAMRecordContent(const string& content, const ZoneName& zone)
{
RecordTextReader rtr(content, zone);
rtr.xfr8BitInt(d_algorithm);
return std::make_shared<CSYNCRecordContent>(content);
}
-CSYNCRecordContent::CSYNCRecordContent(const string& content, const DNSName& zone)
+CSYNCRecordContent::CSYNCRecordContent(const string& content, const ZoneName& zone)
{
RecordTextReader rtr(content, zone);
rtr.xfr32BitInt(d_serial);
return EXIT_FAILURE;
}
-static bool rectifyZone(DNSSECKeeper& dk, const DNSName& zone, bool quiet = false, bool rectifyTransaction = true)
+static bool rectifyZone(DNSSECKeeper& dk, const ZoneName& zone, bool quiet = false, bool rectifyTransaction = true)
{
string output;
string error;
return result;
}
-static int checkZone(DNSSECKeeper &dk, UeberBackend &B, const DNSName& zone, const vector<DNSResourceRecord>* suppliedrecords=nullptr) // NOLINT(readability-function-cognitive-complexity,readability-identifier-length)
+static int checkZone(DNSSECKeeper &dk, UeberBackend &B, const ZoneName& zone, const vector<DNSResourceRecord>* suppliedrecords=nullptr) // NOLINT(readability-function-cognitive-complexity,readability-identifier-length)
{
int numerrors=0;
int numwarnings=0;
}
// Check for delegation in parent zone
- DNSName parent(zone);
+ ZoneName parent(zone);
while(parent.chopOff()) {
SOAData sd_p;
if(B.getSOAUncached(parent, sd_p)) {
multi_index_container<
DomainInfo,
indexed_by<
- ordered_non_unique< member<DomainInfo,DNSName,&DomainInfo::zone>, CanonDNSNameCompare >,
+ ordered_non_unique< member<DomainInfo,ZoneName,&DomainInfo::zone>, CanonZoneNameCompare >,
ordered_non_unique< member<DomainInfo,uint32_t,&DomainInfo::id> >
>
> seenInfos;
return EXIT_FAILURE;
}
-static int increaseSerial(const DNSName& zone, DNSSECKeeper &dk)
+static int increaseSerial(const ZoneName& zone, DNSSECKeeper &dk)
{
UtilBackend B("default"); //NOLINT(readability-identifier-length)
SOAData sd;
return 0;
}
-static int deleteZone(const DNSName &zone) {
+static int deleteZone(const ZoneName &zone) {
UtilBackend B; //NOLINT(readability-identifier-length)
DomainInfo di;
if (! B.getDomainInfo(zone, di)) {
if (!zname.empty()) {
DomainInfo di;
- if(!B.getDomainInfo(DNSName(zname), di)) {
+ if(!B.getDomainInfo(ZoneName(zname), di)) {
cerr << "Zone "<<zname<<" not found."<<endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
-static int listZone(const DNSName &zone) {
+static int listZone(const ZoneName &zone) {
UtilBackend B; //NOLINT(readability-identifier-length)
DomainInfo di;
return c;
}
-static int clearZone(const DNSName &zone) {
+static int clearZone(const ZoneName &zone) {
UtilBackend B; //NOLINT(readability-identifier-length)
DomainInfo di;
bool d_colors;
};
-static int editZone(const DNSName &zone, const PDNSColors& col) {
+static int editZone(const ZoneName &zone, const PDNSColors& col) {
UtilBackend B; //NOLINT(readability-identifier-length)
DomainInfo di;
DNSSECKeeper dk(&B);
}
#endif /* HAVE_IPCIPHER */
-static int zonemdVerifyFile(const DNSName& zone, const string& fname) {
+static int zonemdVerifyFile(const ZoneName& zone, const string& fname) {
ZoneParserTNG zpt(fname, zone, "", true);
zpt.setMaxGenerateSteps(::arg().asNum("max-generate-steps"));
return EXIT_FAILURE;
}
-static int loadZone(const DNSName& zone, const string& fname) {
+static int loadZone(const ZoneName& zone, const string& fname) {
UtilBackend B; //NOLINT(readability-identifier-length)
DomainInfo di;
return EXIT_SUCCESS;
}
-static int createZone(const DNSName &zone, const DNSName& nsname) {
+static int createZone(const ZoneName &zone, const DNSName& nsname) {
UtilBackend B; //NOLINT(readability-identifier-length)
DomainInfo di;
if (B.getDomainInfo(zone, di)) {
static int addOrReplaceRecord(bool isAdd, const vector<string>& cmds) {
DNSResourceRecord rr;
vector<DNSResourceRecord> newrrs;
- DNSName zone(cmds.at(1));
+ ZoneName zone(cmds.at(1));
DNSName name;
if (cmds.at(2) == "@")
name=zone;
{
UtilBackend B; //NOLINT(readability-identifier-length)
DomainInfo di;
- DNSName zone(zone_);
+ ZoneName zone(zone_);
if(!B.getDomainInfo(zone, di)) {
cerr << "Zone '" << zone << "' does not exist" << endl;
return EXIT_FAILURE;
UtilBackend B("default"); //NOLINT(readability-identifier-length)
- DNSName catz(catalog);
+ ZoneName catz(catalog);
DomainInfo di;
if (!B.getDomainInfo(catz, di)) {
cerr << "Zone '" << catz << "' not found" << endl;
return DNSCryptoKeyEngine::testAll();
}
-static void testSpeed(const DNSName& zone, int cores)
+static void testSpeed(const ZoneName& zone, int cores)
{
DNSResourceRecord rr;
rr.qname=DNSName("blah")+zone;
throw runtime_error("No backends available for DNSSEC key storage");
}
- ChunkedSigningPipe csp(DNSName(zone), true, cores, 100);
+ ChunkedSigningPipe csp(zone, true, cores, 100);
vector<DNSZoneRecord> signatures;
uint32_t rnd;
}
}
-static bool disableDNSSECOnZone(DNSSECKeeper& dk, const DNSName& zone)
+static bool disableDNSSECOnZone(DNSSECKeeper& dk, const ZoneName& zone)
{
UtilBackend B("default"); //NOLINT(readability-identifier-length)
DomainInfo di;
return ret;
}
-static int setZoneOptionsJson(const DNSName& zone, const string& options)
+static int setZoneOptionsJson(const ZoneName& zone, const string& options)
{
UtilBackend B("default"); //NOLINT(readability-identifier-length)
DomainInfo di;
return EXIT_SUCCESS;
}
-static int setZoneOption(const DNSName& zone, const string& type, const string& option, const set<string>& values)
+static int setZoneOption(const ZoneName& zone, const string& type, const string& option, const set<string>& values)
{
UtilBackend B("default"); //NOLINT(readability-identifier-length)
DomainInfo di;
return EXIT_SUCCESS;
}
-static int setZoneCatalog(const DNSName& zone, const DNSName& catalog)
+static int setZoneCatalog(const ZoneName& zone, const ZoneName& catalog)
{
UtilBackend B("default"); //NOLINT(readability-identifier-length)
DomainInfo di;
return EXIT_SUCCESS;
}
-static int setZoneAccount(const DNSName& zone, const string &account)
+static int setZoneAccount(const ZoneName& zone, const string &account)
{
UtilBackend B("default"); //NOLINT(readability-identifier-length)
DomainInfo di;
return EXIT_SUCCESS;
}
-static int setZoneKind(const DNSName& zone, const DomainInfo::DomainKind kind)
+static int setZoneKind(const ZoneName& zone, const DomainInfo::DomainKind kind)
{
UtilBackend B("default"); //NOLINT(readability-identifier-length)
DomainInfo di;
return EXIT_SUCCESS;
}
-static bool showZone(DNSSECKeeper& dnsseckeeper, const DNSName& zone, bool exportDS = false) // NOLINT(readability-function-cognitive-complexity)
+static bool showZone(DNSSECKeeper& dnsseckeeper, const ZoneName& zone, bool exportDS = false) // NOLINT(readability-function-cognitive-complexity)
{
UtilBackend B("default"); //NOLINT(readability-identifier-length)
DomainInfo di;
return true;
}
-static bool secureZone(DNSSECKeeper& dk, const DNSName& zone)
+static bool secureZone(DNSSECKeeper& dk, const ZoneName& zone)
{
// temp var for addKey
int64_t id{-1};
return true;
}
-static int testSchema(DNSSECKeeper& dk, const DNSName& zone)
+static int testSchema(DNSSECKeeper& dk, const ZoneName& zone)
{
cout<<"Note: test-schema will try to create the zone, but it will not remove it."<<endl;
cout<<"Please clean up after this."<<endl;
return EXIT_SUCCESS;
}
-static int addOrSetMeta(const DNSName& zone, const string& kind, const vector<string>& values, bool clobber) {
+static int addOrSetMeta(const ZoneName& zone, const string& kind, const vector<string>& values, bool clobber) {
UtilBackend B("default"); //NOLINT(readability-identifier-length)
DomainInfo di;
cmds[1].clear();
}
- return zonemdVerifyFile(DNSName(cmds[1]), cmds[2]);
+ return zonemdVerifyFile(ZoneName(cmds[1]), cmds[2]);
}
return usage(synopsis);
}
DNSSECKeeper dk; //NOLINT(readability-identifier-length)
- return testSchema(dk, DNSName(cmds.at(1)));
+ return testSchema(dk, ZoneName(cmds.at(1)));
}
static int rectifyZone(vector<string>& cmds, const std::string_view synopsis)
DNSSECKeeper dk; //NOLINT(readability-identifier-length)
int exitCode = 0;
for(unsigned int n = 1; n < cmds.size(); ++n) { // NOLINT(readability-identifier-length)
- if (!rectifyZone(dk, DNSName(cmds.at(n)))) {
+ if (!rectifyZone(dk, ZoneName(cmds.at(n)))) {
exitCode = 1;
}
}
}
DNSSECKeeper dk; //NOLINT(readability-identifier-length)
UtilBackend B("default"); // NOLINT(readability-identifier-length)
- return checkZone(dk, B, DNSName(cmds.at(1)));
+ return checkZone(dk, B, ZoneName(cmds.at(1)));
}
static int benchDb(vector<string>& cmds, [[maybe_unused]] const std::string_view synopsis)
if(cmds.size() < 3) {
return usage(synopsis);
}
- testSpeed(DNSName(cmds.at(1)), pdns::checked_stoi<int>(cmds.at(2)));
+ testSpeed(ZoneName(cmds.at(1)), pdns::checked_stoi<int>(cmds.at(2)));
return 0;
}
return usage(synopsis);
}
DNSSECKeeper dk; //NOLINT(readability-identifier-length)
- if (!showZone(dk, DNSName(cmds.at(1)))) {
+ if (!showZone(dk, ZoneName(cmds.at(1)))) {
return 1;
}
return 0;
return usage(synopsis);
}
DNSSECKeeper dk; //NOLINT(readability-identifier-length)
- if (!showZone(dk, DNSName(cmds.at(1)), true)) {
+ if (!showZone(dk, ZoneName(cmds.at(1)), true)) {
return 1;
}
return 0;
return usage(synopsis);
}
DNSSECKeeper dk; //NOLINT(readability-identifier-length)
- DNSName zone(cmds.at(1));
+ ZoneName zone(cmds.at(1));
if(!disableDNSSECOnZone(dk, zone)) {
cerr << "Cannot disable DNSSEC on " << zone << endl;
return 1;
if(cmds.size() != 3) {
return usage(synopsis);
}
- DNSName zone(cmds.at(1));
+ ZoneName zone(cmds.at(1));
// NOLINTNEXTLINE(readability-identifier-length)
unsigned int id = atoi(cmds.at(2).c_str()); // if you make this pdns::checked_stoi, the error gets worse
if(id == 0)
if(cmds.size() != 3) {
return usage(synopsis);
}
- DNSName zone(cmds.at(1));
+ ZoneName zone(cmds.at(1));
auto id = pdns::checked_stoi<unsigned int>(cmds.at(2)); // NOLINT(readability-identifier-length)
if(id == 0)
{
if(cmds.size() != 3) {
return usage(synopsis);
}
- DNSName zone(cmds.at(1));
+ ZoneName zone(cmds.at(1));
// NOLINTNEXTLINE(readability-identifier-length)
unsigned int id = atoi(cmds.at(2).c_str()); // if you make this pdns::checked_stoi, the error gets worse
if(id == 0)
if(cmds.size() != 3) {
return usage(synopsis);
}
- DNSName zone(cmds.at(1));
+ ZoneName zone(cmds.at(1));
// NOLINTNEXTLINE(readability-identifier-length)
unsigned int id = atoi(cmds.at(2).c_str()); // if you make this pdns::checked_stoi, the error gets worse
if(id == 0)
return 0;
}
-static int checkZoneKey(DNSSECKeeper &dsk, DNSName &zone, int64_t keyId)
+static int checkZoneKey(DNSSECKeeper &dsk, ZoneName &zone, int64_t keyId)
{
if (keyId == -1) {
cerr<<std::to_string(keyId)<<": Key was added, but backend does not support returning of key id"<<endl;
return usage(synopsis);
}
DNSSECKeeper dk; //NOLINT(readability-identifier-length)
- DNSName zone(cmds.at(1));
+ ZoneName zone(cmds.at(1));
UtilBackend B("default"); //NOLINT(readability-identifier-length)
DomainInfo di; //NOLINT(readability-identifier-length)
return usage(synopsis);
}
DNSSECKeeper dk; //NOLINT(readability-identifier-length)
- DNSName zone(cmds.at(1));
+ ZoneName zone(cmds.at(1));
auto id = pdns::checked_stoi<unsigned int>(cmds.at(2)); // NOLINT(readability-identifier-length)
if (!dk.removeKey(zone, id)) {
cerr<<"Cannot remove key " << id << " from " << zone <<endl;
if(cmds.size() != 2) {
return usage(synopsis);
}
- return deleteZone(DNSName(cmds.at(1)));
+ return deleteZone(ZoneName(cmds.at(1)));
}
static int createZone(vector<string>& cmds, const std::string_view synopsis)
if(cmds.size() != 2 && cmds.size()!=3 ) {
return usage(synopsis);
}
- return createZone(DNSName(cmds.at(1)), cmds.size() > 2 ? DNSName(cmds.at(2)) : DNSName());
+ return createZone(ZoneName(cmds.at(1)), cmds.size() > 2 ? DNSName(cmds.at(2)) : DNSName());
}
static int createSecondaryZone(vector<string>& cmds, const std::string_view synopsis)
}
UtilBackend B; // NOLINT(readability-identifier-length)
DomainInfo di; // NOLINT(readability-identifier-length)
- DNSName zone(cmds.at(1));
+ ZoneName zone(cmds.at(1));
if (B.getDomainInfo(zone, di)) {
cerr << "Zone '" << zone << "' exists already" << endl;
return EXIT_FAILURE;
}
UtilBackend B; // NOLINT(readability-identifier-length)
DomainInfo di; // NOLINT(readability-identifier-length)
- DNSName zone(cmds.at(1));
+ ZoneName zone(cmds.at(1));
if (!B.getDomainInfo(zone, di)) {
cerr << "Zone '" << zone << "' doesn't exist" << endl;
return EXIT_FAILURE;
cmds.at(1).clear();
}
- return listZone(DNSName(cmds.at(1)));
+ return listZone(ZoneName(cmds.at(1)));
}
static int editZone(vector<string>& cmds, const std::string_view synopsis)
}
PDNSColors col(g_vm.count("no-colors") != 0);
- return editZone(DNSName(cmds.at(1)), col);
+ return editZone(ZoneName(cmds.at(1)), col);
}
static int clearZone(vector<string>& cmds, const std::string_view synopsis)
cmds.at(1).clear();
}
- return clearZone(DNSName(cmds.at(1)));
+ return clearZone(ZoneName(cmds.at(1)));
}
static int listKeys(vector<string>& cmds, const std::string_view synopsis)
}
for(size_t n=1; n + 2 <= cmds.size(); n+=2) { // NOLINT(readability-identifier-length)
- int ret = loadZone(DNSName(cmds.at(n)), cmds.at(n + 1));
+ int ret = loadZone(ZoneName(cmds.at(n)), cmds.at(n + 1));
if (ret != 0) {
return ret;
}
return usage(synopsis);
}
DNSSECKeeper dk; //NOLINT(readability-identifier-length)
- vector<DNSName> mustRectify;
+ vector<ZoneName> mustRectify;
unsigned int zoneErrors=0;
for(unsigned int n = 1; n < cmds.size(); ++n) { // NOLINT(readability-identifier-length)
- DNSName zone(cmds.at(n));
+ ZoneName zone(cmds.at(n));
dk.startTransaction(zone, -1);
if(secureZone(dk, zone)) {
mustRectify.push_back(std::move(zone));
if(cmds.size() != 3) {
return usage(synopsis);
}
- DNSName zone(cmds.at(1));
+ ZoneName zone(cmds.at(1));
auto kind = DomainInfo::stringToKind(cmds.at(2));
return setZoneKind(zone, kind);
}
}
}
- DNSName zone(cmds.at(1));
+ ZoneName zone(cmds.at(1));
return setZoneOptionsJson(zone, cmds.at(2));
}
return usage(synopsis);
}
- DNSName zone(cmds.at(1));
+ ZoneName zone(cmds.at(1));
set<string> values;
for (unsigned int n = 4; n < cmds.size(); ++n) { // NOLINT(readability-identifier-length)
if (!cmds.at(n).empty()) {
if (cmds.size() < 2) {
return usage(synopsis);
}
- DNSName zone(cmds.at(1));
- DNSName catalog; // Create an empty DNSName()
+ ZoneName zone(cmds.at(1));
+ ZoneName catalog; // Create an empty ZoneName()
if (cmds.size() > 2 && !cmds.at(2).empty()) {
- catalog = DNSName(cmds.at(2));
+ catalog = ZoneName(cmds.at(2));
}
return setZoneCatalog(zone, catalog);
}
if(cmds.size() != 3) {
return usage(synopsis);
}
- DNSName zone(cmds.at(1));
+ ZoneName zone(cmds.at(1));
return setZoneAccount(zone, cmds.at(2));
}
NSEC3PARAMRecordContent ns3pr(nsec3params);
DNSSECKeeper dk; //NOLINT(readability-identifier-length)
- DNSName zone(cmds.at(1));
+ ZoneName zone(cmds.at(1));
if (zone.wirelength() > 222) {
cerr<<"Cannot enable NSEC3 for " << zone << " as it is too long (" << zone.wirelength() << " bytes, maximum is 222 bytes)"<<endl;
return 1;
return usage(synopsis);
}
DNSSECKeeper dk; //NOLINT(readability-identifier-length)
- if (!dk.setPresigned(DNSName(cmds.at(1)))) {
+ if (!dk.setPresigned(ZoneName(cmds.at(1)))) {
cerr << "Could not set presigned for " << cmds.at(1) << " (is DNSSEC enabled in your backend?)" << endl;
return 1;
}
return usage(synopsis);
}
DNSSECKeeper dk; //NOLINT(readability-identifier-length)
- if (!dk.setPublishCDNSKEY(DNSName(cmds.at(1)), (cmds.size() == 3 && cmds.at(2) == "delete"))) {
+ if (!dk.setPublishCDNSKEY(ZoneName(cmds.at(1)), (cmds.size() == 3 && cmds.at(2) == "delete"))) {
cerr << "Could not set publishing for CDNSKEY records for " << cmds.at(1) << endl;
return 1;
}
}
DNSSECKeeper dk; //NOLINT(readability-identifier-length)
- if (!dk.setPublishCDS(DNSName(cmds.at(1)), cmds.at(2))) {
+ if (!dk.setPublishCDS(ZoneName(cmds.at(1)), cmds.at(2))) {
cerr << "Could not set publishing for CDS records for " << cmds.at(1) << endl;
return 1;
}
return usage(synopsis);
}
DNSSECKeeper dk; //NOLINT(readability-identifier-length)
- if (!dk.unsetPresigned(DNSName(cmds.at(1)))) {
+ if (!dk.unsetPresigned(ZoneName(cmds.at(1)))) {
cerr << "Could not unset presigned on for " << cmds.at(1) << endl;
return 1;
}
return usage(synopsis);
}
DNSSECKeeper dk; //NOLINT(readability-identifier-length)
- if (!dk.unsetPublishCDNSKEY(DNSName(cmds.at(1)))) {
+ if (!dk.unsetPublishCDNSKEY(ZoneName(cmds.at(1)))) {
cerr << "Could not unset publishing for CDNSKEY records for " << cmds.at(1) << endl;
return 1;
}
return usage(synopsis);
}
DNSSECKeeper dk; //NOLINT(readability-identifier-length)
- if (!dk.unsetPublishCDS(DNSName(cmds.at(1)))) {
+ if (!dk.unsetPublishCDS(ZoneName(cmds.at(1)))) {
cerr << "Could not unset publishing for CDS records for " << cmds.at(1) << endl;
return 1;
}
return usage(synopsis);
}
DNSSECKeeper dk; //NOLINT(readability-identifier-length)
- DNSName zone(cmds.at(1));
+ ZoneName zone(cmds.at(1));
DNSName record(cmds.at(2));
NSEC3PARAMRecordContent ns3pr;
bool narrow = false;
return usage(synopsis);
}
DNSSECKeeper dk; //NOLINT(readability-identifier-length)
- if (!dk.unsetNSEC3PARAM(DNSName(cmds.at(1)))) {
+ if (!dk.unsetNSEC3PARAM(ZoneName(cmds.at(1)))) {
cerr << "Cannot unset NSEC3 param for " << cmds.at(1) << endl;
return 1;
}
DNSSECKeeper dk; //NOLINT(readability-identifier-length)
string zone = cmds.at(1);
auto id = pdns::checked_stoi<unsigned int>(cmds.at(2)); // NOLINT(readability-identifier-length)
- DNSSECPrivateKey dpk = dk.getKeyById(DNSName(zone), id);
+ DNSSECPrivateKey dpk = dk.getKeyById(ZoneName(zone), id);
cout << dpk.getKey()->convertToISC() << endl;
return 0;
}
DNSSECKeeper dk; //NOLINT(readability-identifier-length)
string zone = cmds.at(1);
auto id = pdns::checked_stoi<unsigned int>(cmds.at(2)); // NOLINT(readability-identifier-length)
- DNSSECPrivateKey dpk = dk.getKeyById(DNSName(zone), id);
+ DNSSECPrivateKey dpk = dk.getKeyById(ZoneName(zone), id);
dpk.getKey()->convertToPEMFile(*stdout);
return 0;
}
return usage(synopsis);
}
DNSSECKeeper dk; //NOLINT(readability-identifier-length)
- return increaseSerial(DNSName(cmds.at(1)), dk);
+ return increaseSerial(ZoneName(cmds.at(1)), dk);
}
static int importZoneKeyPEM(vector<string>& cmds, const std::string_view synopsis)
return usage(synopsis);
}
- DNSName zone(cmds.at(1));
+ ZoneName zone(cmds.at(1));
const string filename = cmds.at(2);
const auto algorithm = pdns::checked_stoi<unsigned int>(cmds.at(3));
if(cmds.size() < 3) {
return usage(synopsis);
}
- DNSName zone(cmds.at(1));
+ ZoneName zone(cmds.at(1));
string fname = cmds.at(2);
DNSKEYRecordContent drc;
shared_ptr<DNSCryptoKeyEngine> key(DNSCryptoKeyEngine::makeFromISCFile(drc, fname.c_str()));
}
DNSSECKeeper dk; //NOLINT(readability-identifier-length)
- DNSName zone(cmds.at(1));
+ ZoneName zone(cmds.at(1));
auto id = pdns::checked_stoi<unsigned int>(cmds.at(2)); // NOLINT(readability-identifier-length)
DNSSECPrivateKey dpk=dk.getKeyById(zone, id);
cout << zone<<" IN DNSKEY "<<dpk.getDNSKEY().getZoneRepresentation() <<endl;
if (cmds.size() < 4) {
return usage(synopsis);
}
- DNSName zname(cmds.at(1));
+ ZoneName zname(cmds.at(1));
string name = cmds.at(2);
if (cmds.at(3) == "primary" || cmds.at(3) == "producer") {
metaKey = "TSIG-ALLOW-AXFR";
if (cmds.size() < 4) {
return usage(synopsis);
}
- DNSName zname(cmds.at(1));
+ ZoneName zname(cmds.at(1));
string name = cmds.at(2);
if (cmds.at(3) == "primary" || cmds.at(3) == "producer") {
metaKey = "TSIG-ALLOW-AXFR";
return usage(synopsis);
}
UtilBackend B("default"); // NOLINT(readability-identifier-length)
- DNSName zone(cmds.at(1));
+ ZoneName zone(cmds.at(1));
vector<string> keys;
DomainInfo di; // NOLINT(readability-identifier-length)
if (cmds.size() < 3) {
return usage(synopsis);
}
- DNSName zone(cmds.at(1));
+ ZoneName zone(cmds.at(1));
string kind = cmds.at(2);
const static std::array<string, 7> multiMetaWhitelist = {"ALLOW-AXFR-FROM", "ALLOW-DNSUPDATE-FROM",
"ALSO-NOTIFY", "TSIG-ALLOW-AXFR", "TSIG-ALLOW-DNSUPDATE", "GSS-ALLOW-AXFR-PRINCIPAL",
}
UtilBackend B("default"); // NOLINT(readability-identifier-length)
- DNSName zone(cmds.at(2));
+ ZoneName zone(cmds.at(2));
// verify zone
if (!B.getDomainInfo(zone, di)) {
}
UtilBackend B("default"); // NOLINT(readability-identifier-length)
DomainInfo di; // NOLINT(readability-identifier-length)
- DNSName zone(cmds.at(2));
+ ZoneName zone(cmds.at(2));
unsigned int id{0}; // NOLINT(readability-identifier-length)
int bits = 2048;
// verify zone
#include "base64.hh"
#include "namespaces.hh"
-RecordTextReader::RecordTextReader(string str, DNSName zone) :
+RecordTextReader::RecordTextReader(string str, ZoneName zone) :
d_string(std::move(str)), d_zone(std::move(zone))
{
/* remove whitespace */
class RecordTextReader
{
public:
- RecordTextReader(string str, DNSName zone=DNSName(""));
+ RecordTextReader(string str, ZoneName zone=ZoneName(""));
void xfrNodeOrLocatorID(NodeOrLocatorID& val);
void xfr64BitInt(uint64_t& val);
void xfr48BitInt(uint64_t& val);
bool eof();
private:
string d_string;
- DNSName d_zone;
+ ZoneName d_zone;
string::size_type d_pos{0};
string::size_type d_end;
void skipSpaces();
+ seq;
}
-uint32_t calculateEditSOA(uint32_t old_serial, const string& kind, const DNSName& zonename)
+uint32_t calculateEditSOA(uint32_t old_serial, const string& kind, const ZoneName& zonename)
{
if(pdns_iequals(kind,"INCEPTION-INCREMENT")) {
time_t inception = getStartOfWeek();
return old_serial;
}
-uint32_t calculateEditSOA(uint32_t old_serial, DNSSECKeeper& dk, const DNSName& zonename) {
+uint32_t calculateEditSOA(uint32_t old_serial, DNSSECKeeper& dk, const ZoneName& zonename) {
string kind;
dk.getSoaEdit(zonename, kind);
return calculateEditSOA(old_serial, kind, zonename);
}
/** Used for SOA-EDIT-DNSUPDATE and SOA-EDIT-API. */
-static uint32_t calculateIncreaseSOA(uint32_t old_serial, const string& increaseKind, const string& editKind, const DNSName& zonename) {
+static uint32_t calculateIncreaseSOA(uint32_t old_serial, const string& increaseKind, const string& editKind, const ZoneName& zonename) {
if (pdns_iequals(increaseKind, "SOA-EDIT-INCREASE")) {
uint32_t new_serial = old_serial;
if (!editKind.empty()) {
return nullptr;
}
-ChunkedSigningPipe::ChunkedSigningPipe(DNSName signerName, bool mustSign, unsigned int workers, unsigned int maxChunkRecords) :
+ChunkedSigningPipe::ChunkedSigningPipe(ZoneName signerName, bool mustSign, unsigned int workers, unsigned int maxChunkRecords) :
d_signed(0), d_numworkers(workers), d_signer(std::move(signerName)), d_maxchunkrecords(maxChunkRecords), d_threads(d_numworkers), d_mustSign(mustSign)
{
d_rrsetToSign = make_unique<rrset_t>();
if(res < 0)
unixDie("reading object pointer to sign from pdns");
try {
- set<DNSName> authSet;
+ set<ZoneName> authSet;
authSet.insert(d_signer);
addRRSigs(dk, db, authSet, *chunk);
++d_signed;
ChunkedSigningPipe(const ChunkedSigningPipe&) = delete;
void operator=(const ChunkedSigningPipe&) = delete;
- ChunkedSigningPipe(DNSName signerName, bool mustSign, unsigned int numWorkers, unsigned int maxChunkRecords);
+ ChunkedSigningPipe(ZoneName signerName, bool mustSign, unsigned int numWorkers, unsigned int maxChunkRecords);
~ChunkedSigningPipe();
bool submit(const DNSZoneRecord& rr);
chunk_t getChunk(bool final=false);
std::unique_ptr<rrset_t> d_rrsetToSign;
std::deque< std::vector<DNSZoneRecord> > d_chunks;
- DNSName d_signer;
+ ZoneName d_signer;
chunk_t::size_type d_maxchunkrecords;
DNSZoneRecord soa = makeEditedDNSZRFromSOAData(dk, sd);
outpacket->addRecord(DNSZoneRecord(soa));
if(securedZone && !presignedZone) {
- set<DNSName> authSet;
+ set<ZoneName> authSet;
authSet.insert(target);
addRRSigs(dk, db, authSet, outpacket->getRRS());
}
}
if (serialPermitsIXFR) {
- DNSName target = q->qdomain;
+ ZoneName target = q->qdomain;
TSIGRecordContent trc;
DNSName tsigkeyname;
string tsigsecret;
DNSZoneRecord soa = makeEditedDNSZRFromSOAData(dk, sd);
outpacket->addRecord(std::move(soa));
if(securedZone && outpacket->d_dnssecOk) {
- set<DNSName> authSet;
+ set<ZoneName> authSet;
authSet.insert(target);
addRRSigs(dk, db, authSet, outpacket->getRRS());
}
AuthZoneCache cache;
cache.setRefreshInterval(3600);
- vector<std::tuple<DNSName, int>> zone_indices{
- {DNSName("example.org."), 1},
+ vector<std::tuple<ZoneName, int>> zone_indices{
+ {ZoneName("example.org."), 1},
};
cache.setReplacePending();
cache.replace(zone_indices);
int zoneId = 0;
- bool found = cache.getEntry(DNSName("example.org."), zoneId);
+ bool found = cache.getEntry(ZoneName("example.org."), zoneId);
if (!found || zoneId != 1) {
BOOST_FAIL("zone added in replace() not found");
}
AuthZoneCache cache;
cache.setRefreshInterval(3600);
- vector<std::tuple<DNSName, int>> zone_indices{
- {DNSName("powerdns.org."), 1}};
+ vector<std::tuple<ZoneName, int>> zone_indices{
+ {ZoneName("powerdns.org."), 1}};
cache.setReplacePending();
- cache.add(DNSName("example.org."), 2);
+ cache.add(ZoneName("example.org."), 2);
cache.replace(zone_indices);
int zoneId = 0;
- bool found = cache.getEntry(DNSName("example.org."), zoneId);
+ bool found = cache.getEntry(ZoneName("example.org."), zoneId);
if (!found || zoneId != 2) {
BOOST_FAIL("zone added while replace was pending not found");
}
AuthZoneCache cache;
cache.setRefreshInterval(3600);
- vector<std::tuple<DNSName, int>> zone_indices{
- {DNSName("powerdns.org."), 1}};
+ vector<std::tuple<ZoneName, int>> zone_indices{
+ {ZoneName("powerdns.org."), 1}};
cache.setReplacePending();
- cache.remove(DNSName("powerdns.org."));
+ cache.remove(ZoneName("powerdns.org."));
cache.replace(zone_indices);
int zoneId = 0;
- bool found = cache.getEntry(DNSName("example.org."), zoneId);
+ bool found = cache.getEntry(ZoneName("example.org."), zoneId);
if (found) {
BOOST_FAIL("zone removed while replace was pending is found");
}
AuthZoneCache cache;
cache.setRefreshInterval(3600);
- vector<std::tuple<DNSName, int>> zone_indices{
- {DNSName("powerdns.org."), 1},
- {DNSName("example.org."), 2},
+ vector<std::tuple<ZoneName, int>> zone_indices{
+ {ZoneName("powerdns.org."), 1},
+ {ZoneName("example.org."), 2},
};
cache.setReplacePending();
- cache.add(DNSName("example.org."), 3);
+ cache.add(ZoneName("example.org."), 3);
cache.replace(zone_indices);
int zoneId = 0;
- bool found = cache.getEntry(DNSName("example.org."), zoneId);
+ bool found = cache.getEntry(ZoneName("example.org."), zoneId);
if (!found || zoneId == 0) {
BOOST_FAIL("zone added while replace was pending not found");
}
#define checkzone(i, dname, fname, ztype, nprimaries) \
{ \
- BOOST_CHECK(domains[i].name == DNSName(dname)); \
+ BOOST_CHECK(domains[i].name == ZoneName(dname)); \
BOOST_CHECK_EQUAL(domains[i].filename, fname); \
BOOST_CHECK_EQUAL(domains[i].type, #ztype); \
BOOST_CHECK_EQUAL(domains[i].primaries.size(), nprimaries); \
BOOST_AUTO_TEST_CASE(test_axfr_queue_priority_order)
{
SuckRequest sr[5] = {
- {DNSName("test1.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::SignaturesRefresh, 0}},
- {DNSName("test2.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::SerialRefresh, 1}},
- {DNSName("test3.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Notify, 2}},
- {DNSName("test4.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 3}},
- {DNSName("test5.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::PdnsControl, 4}},
+ {ZoneName("test1.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::SignaturesRefresh, 0}},
+ {ZoneName("test2.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::SerialRefresh, 1}},
+ {ZoneName("test3.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Notify, 2}},
+ {ZoneName("test4.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 3}},
+ {ZoneName("test5.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::PdnsControl, 4}},
};
UniQueue suckDomains;
BOOST_AUTO_TEST_CASE(test_axfr_queue_insert_and_priority_order)
{
SuckRequest sr[5] = {
- {DNSName("test1.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 2}},
- {DNSName("test2.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 1}},
- {DNSName("test3.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 0}},
- {DNSName("test4.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::PdnsControl, 4}},
- {DNSName("test5.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::PdnsControl, 3}},
+ {ZoneName("test1.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 2}},
+ {ZoneName("test2.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 1}},
+ {ZoneName("test3.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 0}},
+ {ZoneName("test4.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::PdnsControl, 4}},
+ {ZoneName("test5.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::PdnsControl, 3}},
};
UniQueue suckDomains;
BOOST_AUTO_TEST_CASE(test_axfr_queue_insert_and_priority_order_after_modify)
{
SuckRequest sr[5] = {
- {DNSName("test1.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 1}},
- {DNSName("test2.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 0}},
- {DNSName("test3.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 2}},
- {DNSName("test4.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::PdnsControl, 4}},
- {DNSName("test5.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::PdnsControl, 3}},
+ {ZoneName("test1.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 1}},
+ {ZoneName("test2.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 0}},
+ {ZoneName("test3.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 2}},
+ {ZoneName("test4.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::PdnsControl, 4}},
+ {ZoneName("test5.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::PdnsControl, 3}},
};
- SuckRequest rr = {DNSName("test3.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::PdnsControl, 5}};
- SuckRequest rr2 = {DNSName("test4.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 6}};
+ SuckRequest rr = {ZoneName("test3.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::PdnsControl, 5}};
+ SuckRequest rr2 = {ZoneName("test4.com"), ComboAddress("0.0.0.0"), false, {SuckRequest::Api, 6}};
UniQueue suckDomains;
struct SimpleDNSZone
{
- SimpleDNSZone(const DNSName& name, uint64_t id): d_records(std::make_shared<RecordStorage>()), d_name(name), d_id(id)
+ SimpleDNSZone(const ZoneName& name, uint64_t id): d_records(std::make_shared<RecordStorage>()), d_name(name), d_id(id)
{
}
std::shared_ptr<RecordStorage> d_records;
- DNSName d_name;
+ ZoneName d_name;
uint64_t d_id;
};
SimpleDNSZone,
indexed_by <
ordered_unique<tag<IDTag>, member<SimpleDNSZone, uint64_t, &SimpleDNSZone::d_id> >,
- hashed_unique<tag<HashedNameTag>, member<SimpleDNSZone, DNSName, &SimpleDNSZone::d_name> >
+ hashed_unique<tag<HashedNameTag>, member<SimpleDNSZone, ZoneName, &SimpleDNSZone::d_name> >
>
> ZoneStorage;
struct SimpleMetaData
{
- SimpleMetaData(const DNSName& name, const std::string& kind, const std::vector<std::string>& values): d_name(name), d_kind(kind), d_values(values)
+ SimpleMetaData(const ZoneName& name, const std::string& kind, const std::vector<std::string>& values): d_name(name), d_kind(kind), d_values(values)
{
}
- DNSName d_name;
+ ZoneName d_name;
std::string d_kind;
std::vector<std::string> d_values;
};
ordered_unique<tag<OrderedNameKindTag>,
composite_key<
SimpleMetaData,
- member<SimpleMetaData, DNSName, &SimpleMetaData::d_name>,
+ member<SimpleMetaData, ZoneName, &SimpleMetaData::d_name>,
member<SimpleMetaData, std::string, &SimpleMetaData::d_kind>
>,
- composite_key_compare<CanonDNSNameCompare, std::less<std::string> >
+ composite_key_compare<CanonZoneNameCompare, std::less<std::string> >
>
>
> MetaDataStorage;
unsigned int getCapabilities() override { return CAP_LIST; }
- bool findZone(const DNSName& qdomain, int zoneId, std::shared_ptr<RecordStorage>& records, uint64_t& currentZoneId) const
+ bool findZone(const ZoneName& qdomain, int zoneId, std::shared_ptr<RecordStorage>& records, uint64_t& currentZoneId) const
{
currentZoneId = -1;
records.reset();
return true;
}
- bool list(const DNSName& target, int zoneId, bool /* include_disabled */ = false) override
+ bool list(const ZoneName& target, int zoneId, bool /* include_disabled */ = false) override
{
findZone(target, zoneId, d_records, d_currentZone);
return false;
}
- bool getDomainMetadata(const DNSName& name, const std::string& kind, std::vector<std::string>& meta) override
+ bool getDomainMetadata(const ZoneName& name, const std::string& kind, std::vector<std::string>& meta) override
{
const auto& idx = boost::multi_index::get<OrderedNameKindTag>(s_metadata.at(d_backendId));
auto it = idx.find(std::tuple(name, kind));
return true;
}
- bool setDomainMetadata(const DNSName& name, const std::string& kind, const std::vector<std::string>& meta) override
+ bool setDomainMetadata(const ZoneName& name, const std::string& kind, const std::vector<std::string>& meta) override
{
auto& idx = boost::multi_index::get<OrderedNameKindTag>(s_metadata.at(d_backendId));
auto it = idx.find(std::tuple(name, kind));
{
}
- bool getAuth(const DNSName& target, SOAData* sd) override
+ bool getAuth(const ZoneName& target, SOAData* sd) override
{
- static const DNSName best("d.0.1.0.0.2.ip6.arpa.");
+ static const ZoneName best("d.0.1.0.0.2.ip6.arpa.");
++d_authLookupCount;
{
}
- bool getDomainMetadata(const DNSName& /* name */, const std::string& /* kind */, std::vector<std::string>& /* meta */) override
+ bool getDomainMetadata(const ZoneName& /* name */, const std::string& /* kind */, std::vector<std::string>& /* meta */) override
{
return false;
}
- bool setDomainMetadata(const DNSName& /* name */, const std::string& /* kind */, const std::vector<std::string>& /* meta */) override
+ bool setDomainMetadata(const ZoneName& /* name */, const std::string& /* kind */, const std::vector<std::string>& /* meta */) override
{
return false;
}
BOOST_AUTO_TEST_CASE(test_simple) {
try {
- SimpleBackend::SimpleDNSZone zoneA(DNSName("powerdns.com."), 1);
+ SimpleBackend::SimpleDNSZone zoneA(ZoneName("powerdns.com."), 1);
zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::SOA, "ns1.powerdns.com. powerdns.com. 3 600 600 3600000 604800", 3600));
zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::AAAA, "2001:db8::1", 60));
zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("www.powerdns.com."), QType::A, "192.168.0.1", 60));
// no overlap
try {
- SimpleBackend::SimpleDNSZone zoneA(DNSName("powerdns.com."), 1);
+ SimpleBackend::SimpleDNSZone zoneA(ZoneName("powerdns.com."), 1);
zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::SOA, "ns1.powerdns.com. powerdns.com. 3 600 600 3600000 604800", 3600));
zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::AAAA, "2001:db8::1", 60));
zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("www.powerdns.com."), QType::A, "192.168.0.1", 60));
zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("geo.powerdns.com."), QType::A, "192.168.0.42", 60));
SimpleBackend::s_zones[1].insert(zoneA);
- SimpleBackend::SimpleDNSZone zoneB(DNSName("powerdns.org."), 2);
+ SimpleBackend::SimpleDNSZone zoneB(ZoneName("powerdns.org."), 2);
zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.org."), QType::SOA, "ns1.powerdns.org. powerdns.org. 3 600 600 3600000 604800", 3600));
zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.org."), QType::AAAA, "2001:db8::2", 60));
zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("www.powerdns.org."), QType::AAAA, "2001:db8::2", 60));
// one backend holds the SOA, NS and one A
// a second backend holds another A and AAAA
try {
- SimpleBackend::SimpleDNSZone zoneA(DNSName("powerdns.com."), 1);
+ SimpleBackend::SimpleDNSZone zoneA(ZoneName("powerdns.com."), 1);
zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::SOA, "ns1.powerdns.com. powerdns.com. 3 600 600 3600000 604800", 3600));
zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::NS, "ns1.powerdns.com.", 3600));
zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::A, "192.168.0.1", 60));
SimpleBackend::s_zones[1].insert(zoneA);
- SimpleBackend::SimpleDNSZone zoneB(DNSName("powerdns.com."), 1);
+ SimpleBackend::SimpleDNSZone zoneB(ZoneName("powerdns.com."), 1);
zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::A, "192.168.0.2", 60));
zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::AAAA, "2001:db8::1", 60));
zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("www.powerdns.com."), QType::A, "192.168.0.1", 60));
// one backend holds the apex with SOA, NS and one A
// a second backend holds others names
try {
- SimpleBackend::SimpleDNSZone zoneA(DNSName("powerdns.com."), 1);
+ SimpleBackend::SimpleDNSZone zoneA(ZoneName("powerdns.com."), 1);
zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::SOA, "ns1.powerdns.com. powerdns.com. 3 600 600 3600000 604800", 3600));
zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::NS, "ns1.powerdns.com.", 3600));
zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::A, "192.168.0.1", 60));
zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::AAAA, "2001:db8::1", 60));
SimpleBackend::s_zones[1].insert(zoneA);
- SimpleBackend::SimpleDNSZone zoneB(DNSName("powerdns.com."), 1);
+ SimpleBackend::SimpleDNSZone zoneB(ZoneName("powerdns.com."), 1);
zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("www.powerdns.com."), QType::A, "192.168.0.1", 60));
zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("www.powerdns.com."), QType::AAAA, "192.168.0.1", 60));
zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("geo.powerdns.com."), QType::A, "192.168.0.42", 60));
// Check that DS queries are correctly handled
try {
- SimpleBackend::SimpleDNSZone zoneA(DNSName("com."), 1);
+ SimpleBackend::SimpleDNSZone zoneA(ZoneName("com."), 1);
zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("com."), QType::SOA, "a.gtld-servers.net. nstld.verisign-grs.com. 3 600 600 3600000 604800", 3600));
zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::NS, "ns1.powerdns.com.", 3600));
zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::DS, "44030 8 3 7DD75AE1565051F9563CF8DF976AC99CDCA51E3463019C81BD2BB083 82F3854E", 3600));
zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("ns1.powerdns.com."), QType::A, "192.0.2.1", 3600));
SimpleBackend::s_zones[1].insert(zoneA);
- SimpleBackend::SimpleDNSZone zoneB(DNSName("powerdns.com."), 2);
+ SimpleBackend::SimpleDNSZone zoneB(ZoneName("powerdns.com."), 2);
zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::SOA, "ns1.powerdns.com. powerdns.com. 3 600 600 3600000 604800", 3600));
zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::AAAA, "2001:db8::2", 60));
zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::NS, "ns1.powerdns.com.", 3600));
{
// test getAuth() for DS
SOAData sd;
- BOOST_REQUIRE(ub.getAuth(DNSName("powerdns.com."), QType::DS, &sd));
+ BOOST_REQUIRE(ub.getAuth(ZoneName("powerdns.com."), QType::DS, &sd));
BOOST_CHECK_EQUAL(sd.qname.toString(), "com.");
BOOST_CHECK_EQUAL(sd.domain_id, 1);
}
{
// test getAuth() for A
SOAData sd;
- BOOST_REQUIRE(ub.getAuth(DNSName("powerdns.com."), QType::A, &sd));
+ BOOST_REQUIRE(ub.getAuth(ZoneName("powerdns.com."), QType::A, &sd));
BOOST_CHECK_EQUAL(sd.qname.toString(), "powerdns.com.");
BOOST_CHECK_EQUAL(sd.domain_id, 2);
}
// while the others do simple lookups
try {
- SimpleBackend::SimpleDNSZone zoneA(DNSName("d.0.1.0.0.2.ip6.arpa."), 1);
+ SimpleBackend::SimpleDNSZone zoneA(ZoneName("d.0.1.0.0.2.ip6.arpa."), 1);
zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("d.0.1.0.0.2.ip6.arpa."), QType::SOA, "ns.apnic.net. read-txt-record-of-zone-first-dns-admin.apnic.net. 3005126844 7200 1800 604800 3600", 3600));
zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("2.4.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa."), QType::PTR, "a.reverse.", 3600));
SimpleBackend::s_zones[1].insert(zoneA);
- SimpleBackend::SimpleDNSZone zoneB(DNSName("0.1.0.0.2.ip6.arpa."), 2);
+ SimpleBackend::SimpleDNSZone zoneB(ZoneName("0.1.0.0.2.ip6.arpa."), 2);
zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("0.1.0.0.2.ip6.arpa."), QType::SOA, "ns.apnic.net. read-txt-record-of-zone-first-dns-admin.apnic.net. 3005126844 7200 1800 604800 3600", 3600));
SimpleBackend::s_zones[2].insert(zoneB);
// test getAuth()
SOAData sd;
- BOOST_REQUIRE(ub.getAuth(DNSName("2.4.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa."), QType::PTR, &sd));
+ BOOST_REQUIRE(ub.getAuth(ZoneName("2.4.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa."), QType::PTR, &sd));
BOOST_CHECK_EQUAL(sd.qname.toString(), "d.0.1.0.0.2.ip6.arpa.");
BOOST_CHECK_EQUAL(sd.domain_id, 1);
// Updating will insert into the first backend, leaving the first one untouched
try {
- SimpleBackend::SimpleDNSZone zoneA(DNSName("powerdns.com."), 1);
+ SimpleBackend::SimpleDNSZone zoneA(ZoneName("powerdns.com."), 1);
zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::SOA, "ns1.powerdns.com. powerdns.com. 3 600 600 3600000 604800", 3600));
zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.com."), QType::AAAA, "2001:db8::1", 60));
zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("www.powerdns.com."), QType::A, "192.168.0.1", 60));
zoneA.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("geo.powerdns.com."), QType::A, "192.168.0.42", 60));
SimpleBackend::s_zones[1].insert(zoneA);
- SimpleBackend::s_metadata[1].insert(SimpleBackend::SimpleMetaData(DNSName("powerdns.com."), "test-data-a", { "value1", "value2"}));
+ SimpleBackend::s_metadata[1].insert(SimpleBackend::SimpleMetaData(ZoneName("powerdns.com."), "test-data-a", { "value1", "value2"}));
- SimpleBackend::SimpleDNSZone zoneB(DNSName("powerdns.org."), 2);
+ SimpleBackend::SimpleDNSZone zoneB(ZoneName("powerdns.org."), 2);
zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.org."), QType::SOA, "ns1.powerdns.org. powerdns.org. 3 600 600 3600000 604800", 3600));
zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("powerdns.org."), QType::AAAA, "2001:db8::2", 60));
zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("www.powerdns.org."), QType::AAAA, "2001:db8::2", 60));
zoneB.d_records->insert(SimpleBackend::SimpleDNSRecord(DNSName("geo.powerdns.org."), QType::AAAA, "2001:db8::42", 60));
SimpleBackend::s_zones[2].insert(zoneB);
- SimpleBackend::s_metadata[2].insert(SimpleBackend::SimpleMetaData(DNSName("powerdns.org."), "test-data-b", { "value1", "value2"}));
+ SimpleBackend::s_metadata[2].insert(SimpleBackend::SimpleMetaData(ZoneName("powerdns.org."), "test-data-b", { "value1", "value2"}));
BackendMakers().report(std::make_unique<SimpleBackendFactory>());
BackendMakers().launch("SimpleBackend:1, SimpleBackend:2");
{
// check the initial values
std::vector<std::string> values;
- BOOST_CHECK(ub.getDomainMetadata(DNSName("powerdns.com."), "test-data-a", values));
+ BOOST_CHECK(ub.getDomainMetadata(ZoneName("powerdns.com."), "test-data-a", values));
BOOST_REQUIRE_EQUAL(values.size(), 2U);
BOOST_CHECK_EQUAL(values.at(0), "value1");
BOOST_CHECK_EQUAL(values.at(1), "value2");
values.clear();
- BOOST_CHECK(ub.getDomainMetadata(DNSName("powerdns.com."), "test-data-b", values));
+ BOOST_CHECK(ub.getDomainMetadata(ZoneName("powerdns.com."), "test-data-b", values));
BOOST_CHECK_EQUAL(values.size(), 0U);
values.clear();
- BOOST_CHECK(ub.getDomainMetadata(DNSName("powerdns.org."), "test-data-a", values));
+ BOOST_CHECK(ub.getDomainMetadata(ZoneName("powerdns.org."), "test-data-a", values));
BOOST_CHECK_EQUAL(values.size(), 0U);
values.clear();
- BOOST_CHECK(ub.getDomainMetadata(DNSName("powerdns.org."), "test-data-b", values));
+ BOOST_CHECK(ub.getDomainMetadata(ZoneName("powerdns.org."), "test-data-b", values));
BOOST_CHECK_EQUAL(values.size(), 0U);
}
{
// update the values
- BOOST_CHECK(ub.setDomainMetadata(DNSName("powerdns.com."), "test-data-a", std::vector<std::string>({"value3"})));
- BOOST_CHECK(ub.setDomainMetadata(DNSName("powerdns.org."), "test-data-a", std::vector<std::string>({"value4"})));
- BOOST_CHECK(ub.setDomainMetadata(DNSName("powerdns.org."), "test-data-b", std::vector<std::string>({"value5"})));
+ BOOST_CHECK(ub.setDomainMetadata(ZoneName("powerdns.com."), "test-data-a", std::vector<std::string>({"value3"})));
+ BOOST_CHECK(ub.setDomainMetadata(ZoneName("powerdns.org."), "test-data-a", std::vector<std::string>({"value4"})));
+ BOOST_CHECK(ub.setDomainMetadata(ZoneName("powerdns.org."), "test-data-b", std::vector<std::string>({"value5"})));
}
// check the updated values
{
std::vector<std::string> values;
- BOOST_CHECK(ub.getDomainMetadata(DNSName("powerdns.com."), "test-data-a", values));
+ BOOST_CHECK(ub.getDomainMetadata(ZoneName("powerdns.com."), "test-data-a", values));
BOOST_REQUIRE_EQUAL(values.size(), 1U);
BOOST_CHECK_EQUAL(values.at(0), "value3");
values.clear();
- BOOST_CHECK(ub.getDomainMetadata(DNSName("powerdns.org."), "test-data-a", values));
+ BOOST_CHECK(ub.getDomainMetadata(ZoneName("powerdns.org."), "test-data-a", values));
BOOST_REQUIRE_EQUAL(values.size(), 1U);
BOOST_CHECK_EQUAL(values.at(0), "value4");
values.clear();
- BOOST_CHECK(ub.getDomainMetadata(DNSName("powerdns.org."), "test-data-b", values));
+ BOOST_CHECK(ub.getDomainMetadata(ZoneName("powerdns.org."), "test-data-b", values));
BOOST_REQUIRE_EQUAL(values.size(), 1U);
BOOST_CHECK_EQUAL(values.at(0), "value5");
}
{
// check that it has not been updated in the second backend
- const auto& it = SimpleBackend::s_metadata[2].find(std::tuple(DNSName("powerdns.org."), "test-data-b"));
+ const auto& it = SimpleBackend::s_metadata[2].find(std::tuple(ZoneName("powerdns.org."), "test-data-b"));
BOOST_REQUIRE(it != SimpleBackend::s_metadata[2].end());
BOOST_REQUIRE_EQUAL(it->d_values.size(), 2U);
BOOST_CHECK_EQUAL(it->d_values.at(0), "value1");
if (!p) {
p = ".";
}
- DNSName z(zone);
+ ZoneName z(zone);
std::ostringstream pathbuf;
pathbuf << p << "/../regression-tests/zones/" + file;
ZoneParserTNG zpt(pathbuf.str(), z);
if(!p)
p = ".";
pathbuf << p << "/../regression-tests/zones/unit.test";
- ZoneParserTNG zp(pathbuf.str(), DNSName("unit.test"));
+ ZoneParserTNG zp(pathbuf.str(), ZoneName("unit.test"));
DNSResourceRecord rr;
ifstream ifs(pathbuf.str());
{
/* simple case */
- ZoneParserTNG zp(pathbuf.str(), DNSName("unit2.test"));
+ ZoneParserTNG zp(pathbuf.str(), ZoneName("unit2.test"));
const vector<string> expected = {
"0.01.0003.000005.00000007.unit2.test.",
{
/* 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"}), DNSName("unit2.test"));
+ 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"));
const vector<string> expected = {
"0.01.0003.000005.00000007.unit2.test.",
{
/* 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"}), DNSName("unit2.test"));
+ ZoneParserTNG zp(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.",
{
/* 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"}), DNSName("test"));
+ 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"));
DNSResourceRecord rr;
BOOST_CHECK_THROW(zp.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"}), DNSName("test"));
+ 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"));
DNSResourceRecord rr;
BOOST_CHECK_THROW(zp.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"}), DNSName("test"));
+ 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"));
DNSResourceRecord rr;
BOOST_CHECK_THROW(zp.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"}), DNSName("test"));
+ 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"));
DNSResourceRecord rr;
BOOST_CHECK_THROW(zp.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"}), DNSName("test"));
+ 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"));
DNSResourceRecord rr;
BOOST_CHECK_THROW(zp.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"}), DNSName("test"));
+ 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"));
DNSResourceRecord rr;
BOOST_CHECK_THROW(zp.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"}), DNSName("test"));
+ 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"));
DNSResourceRecord rr;
BOOST_CHECK_THROW(zp.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"}), DNSName("test"));
+ 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"));
DNSResourceRecord rr;
BOOST_CHECK_THROW(zp.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"}), DNSName("test"));
+ 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"));
DNSResourceRecord rr;
BOOST_CHECK_THROW(zp.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"}), DNSName("test"));
+ 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"));
DNSResourceRecord rr;
BOOST_CHECK_THROW(zp.get(rr), PDNSException);
}
}
BOOST_AUTO_TEST_CASE(test_tng_upgrade) {
- ZoneParserTNG zp(std::vector<std::string>({"foo.test. 86400 IN TYPE1 \\# 4 c0000304"}), DNSName("test"), true);
+ ZoneParserTNG zp(std::vector<std::string>({"foo.test. 86400 IN TYPE1 \\# 4 c0000304"}), ZoneName("test"), true);
DNSResourceRecord rr;
zp.get(rr);
if (g_doGssTSIG) {
if (tkey_in.d_algo == DNSName("gss-tsig.")) {
std::vector<std::string> meta;
- DNSName tmpName(name);
+ ZoneName tmpName(name);
do {
if (B.getDomainMetadata(tmpName, "GSS-ACCEPTOR-PRINCIPAL", meta) && meta.size()>0) {
break;
tt.name=keyname;
tt.algo=DNSName("hmac-md5");
tt.secret=key;
- AXFRRetriever axfr(dest, DNSName("b.aa"), tt);
+ AXFRRetriever axfr(dest, ZoneName("b.aa"), tt);
vector<DNSResourceRecord> res;
while(axfr.getChunk(res)) {
}
d_cond.notify_all();
}
-bool UeberBackend::getDomainInfo(const DNSName& domain, DomainInfo& domainInfo, bool getSerial)
+bool UeberBackend::getDomainInfo(const ZoneName& domain, DomainInfo& domainInfo, bool getSerial)
{
for (auto& backend : backends) {
if (backend->getDomainInfo(domain, domainInfo, getSerial)) {
return false;
}
-bool UeberBackend::createDomain(const DNSName& domain, const DomainInfo::DomainKind kind, const vector<ComboAddress>& primaries, const string& account)
+bool UeberBackend::createDomain(const ZoneName& domain, const DomainInfo::DomainKind kind, const vector<ComboAddress>& primaries, const string& account)
{
for (auto& backend : backends) {
if (backend->createDomain(domain, kind, primaries, account)) {
return false;
}
-bool UeberBackend::addDomainKey(const DNSName& name, const DNSBackend::KeyData& key, int64_t& keyID)
+bool UeberBackend::addDomainKey(const ZoneName& name, const DNSBackend::KeyData& key, int64_t& keyID)
{
keyID = -1;
for (auto& backend : backends) {
}
return false;
}
-bool UeberBackend::getDomainKeys(const DNSName& name, std::vector<DNSBackend::KeyData>& keys)
+bool UeberBackend::getDomainKeys(const ZoneName& name, std::vector<DNSBackend::KeyData>& keys)
{
for (auto& backend : backends) {
if (backend->getDomainKeys(name, keys)) {
return false;
}
-bool UeberBackend::getAllDomainMetadata(const DNSName& name, std::map<std::string, std::vector<std::string>>& meta)
+bool UeberBackend::getAllDomainMetadata(const ZoneName& name, std::map<std::string, std::vector<std::string>>& meta)
{
for (auto& backend : backends) {
if (backend->getAllDomainMetadata(name, meta)) {
return false;
}
-bool UeberBackend::getDomainMetadata(const DNSName& name, const std::string& kind, std::vector<std::string>& meta)
+bool UeberBackend::getDomainMetadata(const ZoneName& name, const std::string& kind, std::vector<std::string>& meta)
{
for (auto& backend : backends) {
if (backend->getDomainMetadata(name, kind, meta)) {
return false;
}
-bool UeberBackend::getDomainMetadata(const DNSName& name, const std::string& kind, std::string& meta)
+bool UeberBackend::getDomainMetadata(const ZoneName& name, const std::string& kind, std::string& meta)
{
meta.clear();
std::vector<string> tmp;
return ret;
}
-bool UeberBackend::setDomainMetadata(const DNSName& name, const std::string& kind, const std::vector<std::string>& meta)
+bool UeberBackend::setDomainMetadata(const ZoneName& name, const std::string& kind, const std::vector<std::string>& meta)
{
for (auto& backend : backends) {
if (backend->setDomainMetadata(name, kind, meta)) {
return false;
}
-bool UeberBackend::setDomainMetadata(const DNSName& name, const std::string& kind, const std::string& meta)
+bool UeberBackend::setDomainMetadata(const ZoneName& name, const std::string& kind, const std::string& meta)
{
std::vector<string> tmp;
if (!meta.empty()) {
return setDomainMetadata(name, kind, tmp);
}
-bool UeberBackend::activateDomainKey(const DNSName& name, unsigned int keyID)
+bool UeberBackend::activateDomainKey(const ZoneName& name, unsigned int keyID)
{
for (auto& backend : backends) {
if (backend->activateDomainKey(name, keyID)) {
return false;
}
-bool UeberBackend::deactivateDomainKey(const DNSName& name, unsigned int keyID)
+bool UeberBackend::deactivateDomainKey(const ZoneName& name, unsigned int keyID)
{
for (auto& backend : backends) {
if (backend->deactivateDomainKey(name, keyID)) {
return false;
}
-bool UeberBackend::publishDomainKey(const DNSName& name, unsigned int keyID)
+bool UeberBackend::publishDomainKey(const ZoneName& name, unsigned int keyID)
{
for (auto& backend : backends) {
if (backend->publishDomainKey(name, keyID)) {
return false;
}
-bool UeberBackend::unpublishDomainKey(const DNSName& name, unsigned int keyID)
+bool UeberBackend::unpublishDomainKey(const ZoneName& name, unsigned int keyID)
{
for (auto& backend : backends) {
if (backend->unpublishDomainKey(name, keyID)) {
return false;
}
-bool UeberBackend::removeDomainKey(const DNSName& name, unsigned int keyID)
+bool UeberBackend::removeDomainKey(const ZoneName& name, unsigned int keyID)
{
for (auto& backend : backends) {
if (backend->removeDomainKey(name, keyID)) {
return;
}
- vector<std::tuple<DNSName, int>> zone_indices;
+ vector<std::tuple<ZoneName, int>> zone_indices;
g_zoneCache.setReplacePending();
for (auto& backend : backends) {
return false;
}
-bool UeberBackend::fillSOAFromZoneRecord(DNSName& shorter, const int zoneId, SOAData* const soaData)
+bool UeberBackend::fillSOAFromZoneRecord(ZoneName& shorter, const int zoneId, SOAData* const soaData)
{
// Zone exists in zone cache, directly look up SOA.
lookup(QType(QType::SOA), shorter, zoneId, nullptr);
return true;
}
-UeberBackend::CacheResult UeberBackend::fillSOAFromCache(SOAData* soaData, DNSName& shorter)
+UeberBackend::CacheResult UeberBackend::fillSOAFromCache(SOAData* soaData, ZoneName& shorter)
{
auto cacheResult = cacheHas(d_question, d_answers);
return cacheResult;
}
-static std::vector<std::unique_ptr<DNSBackend>>::iterator findBestMatchingBackend(std::vector<std::unique_ptr<DNSBackend>>& backends, std::vector<std::pair<std::size_t, SOAData>>& bestMatches, const DNSName& shorter, SOAData* soaData)
+static std::vector<std::unique_ptr<DNSBackend>>::iterator findBestMatchingBackend(std::vector<std::unique_ptr<DNSBackend>>& backends, std::vector<std::pair<std::size_t, SOAData>>& bestMatches, const ZoneName& shorter, SOAData* soaData)
{
auto backend = backends.begin();
for (auto bestMatch = bestMatches.begin(); backend != backends.end() && bestMatch != bestMatches.end(); ++backend, ++bestMatch) {
return false;
}
-bool UeberBackend::getAuth(const DNSName& target, const QType& qtype, SOAData* soaData, bool cachedOk)
+bool UeberBackend::getAuth(const ZoneName& target, const QType& qtype, SOAData* soaData, bool cachedOk)
{
// A backend can respond to our authority request with the 'best' match it
// has. For example, when asked for a.b.c.example.com. it might respond with
// If a backend has no match it may respond with an empty qname.
bool found = false;
- DNSName shorter(target);
+ ZoneName shorter(target);
vector<pair<size_t, SOAData>> bestMatches(backends.size(), pair(target.wirelength() + 1, SOAData()));
bool first = true;
return found;
}
-bool UeberBackend::getSOAUncached(const DNSName& domain, SOAData& soaData)
+bool UeberBackend::getSOAUncached(const ZoneName& domain, SOAData& soaData)
{
d_question.qtype = QType::SOA;
d_question.qname = domain;
return false;
}
-bool UeberBackend::autoPrimaryBackend(const string& ipAddr, const DNSName& domain, const vector<DNSResourceRecord>& nsset, string* nameserver, string* account, DNSBackend** dnsBackend)
+bool UeberBackend::autoPrimaryBackend(const string& ipAddr, const ZoneName& domain, const vector<DNSResourceRecord>& nsset, string* nameserver, string* account, DNSBackend** dnsBackend)
{
for (auto& backend : backends) {
if (backend->autoPrimaryBackend(ipAddr, domain, nsset, nameserver, account, dnsBackend)) {
QC.insert(question.qname, question.qtype, std::move(rrs), d_cache_ttl, question.zoneId);
}
-void UeberBackend::alsoNotifies(const DNSName& domain, set<string>* ips)
+void UeberBackend::alsoNotifies(const ZoneName& domain, set<string>* ips)
{
for (auto& backend : backends) {
backend->alsoNotifies(domain, ips);
UeberBackend(const string& pname = "default");
~UeberBackend();
- bool autoPrimaryBackend(const string& ip, const DNSName& domain, const vector<DNSResourceRecord>& nsset, string* nameserver, string* account, DNSBackend** dnsBackend);
+ bool autoPrimaryBackend(const string& ip, const ZoneName& domain, const vector<DNSResourceRecord>& nsset, string* nameserver, string* account, DNSBackend** dnsBackend);
bool autoPrimaryAdd(const AutoPrimary& primary);
bool autoPrimaryRemove(const struct AutoPrimary& primary);
void lookupEnd();
/** Determines if we are authoritative for a zone, and at what level */
- bool getAuth(const DNSName& target, const QType& qtype, SOAData* soaData, bool cachedOk = true);
+ bool getAuth(const ZoneName& target, const QType& qtype, SOAData* soaData, bool cachedOk = true);
/** Load SOA info from backends, ignoring the cache.*/
- bool getSOAUncached(const DNSName& domain, SOAData& soaData);
+ bool getSOAUncached(const ZoneName& domain, SOAData& soaData);
void getAllDomains(vector<DomainInfo>* domains, bool getSerial, bool include_disabled);
void getUnfreshSecondaryInfos(vector<DomainInfo>* domains);
void getUpdatedPrimaries(vector<DomainInfo>& domains, std::unordered_set<DNSName>& catalogs, CatalogHashMap& catalogHashes);
- bool getDomainInfo(const DNSName& domain, DomainInfo& domainInfo, bool getSerial = true);
- bool createDomain(const DNSName& domain, DomainInfo::DomainKind kind, const vector<ComboAddress>& primaries, const string& account);
+ bool getDomainInfo(const ZoneName& domain, DomainInfo& domainInfo, bool getSerial = true);
+ bool createDomain(const ZoneName& domain, DomainInfo::DomainKind kind, const vector<ComboAddress>& primaries, const string& account);
bool doesDNSSEC();
- bool addDomainKey(const DNSName& name, const DNSBackend::KeyData& key, int64_t& keyID);
- bool getDomainKeys(const DNSName& name, std::vector<DNSBackend::KeyData>& keys);
- bool getAllDomainMetadata(const DNSName& name, std::map<std::string, std::vector<std::string>>& meta);
- bool getDomainMetadata(const DNSName& name, const std::string& kind, std::vector<std::string>& meta);
- bool getDomainMetadata(const DNSName& name, const std::string& kind, std::string& meta);
- bool setDomainMetadata(const DNSName& name, const std::string& kind, const std::vector<std::string>& meta);
- bool setDomainMetadata(const DNSName& name, const std::string& kind, const std::string& meta);
-
- bool removeDomainKey(const DNSName& name, unsigned int keyID);
- bool activateDomainKey(const DNSName& name, unsigned int keyID);
- bool deactivateDomainKey(const DNSName& name, unsigned int keyID);
- bool publishDomainKey(const DNSName& name, unsigned int keyID);
- bool unpublishDomainKey(const DNSName& name, unsigned int keyID);
-
- void alsoNotifies(const DNSName& domain, set<string>* ips);
+ bool addDomainKey(const ZoneName& name, const DNSBackend::KeyData& key, int64_t& keyID);
+ bool getDomainKeys(const ZoneName& name, std::vector<DNSBackend::KeyData>& keys);
+ bool getAllDomainMetadata(const ZoneName& name, std::map<std::string, std::vector<std::string>>& meta);
+ bool getDomainMetadata(const ZoneName& name, const std::string& kind, std::vector<std::string>& meta);
+ bool getDomainMetadata(const ZoneName& name, const std::string& kind, std::string& meta);
+ bool setDomainMetadata(const ZoneName& name, const std::string& kind, const std::vector<std::string>& meta);
+ bool setDomainMetadata(const ZoneName& name, const std::string& kind, const std::string& meta);
+
+ bool removeDomainKey(const ZoneName& name, unsigned int keyID);
+ bool activateDomainKey(const ZoneName& name, unsigned int keyID);
+ bool deactivateDomainKey(const ZoneName& name, unsigned int keyID);
+ bool publishDomainKey(const ZoneName& name, unsigned int keyID);
+ bool unpublishDomainKey(const ZoneName& name, unsigned int keyID);
+
+ void alsoNotifies(const ZoneName& domain, set<string>* ips);
void rediscover(string* status = nullptr);
void reload();
void addNegCache(const Question& question) const;
void addCache(const Question& question, vector<DNSZoneRecord>&& rrs) const;
- bool fillSOAFromZoneRecord(DNSName& shorter, int zoneId, SOAData* soaData);
- CacheResult fillSOAFromCache(SOAData* soaData, DNSName& shorter);
+ bool fillSOAFromZoneRecord(ZoneName& shorter, int zoneId, SOAData* soaData);
+ CacheResult fillSOAFromCache(SOAData* soaData, ZoneName& shorter);
};
}
}
-DNSName apiZoneIdToName(const string& identifier)
+ZoneName apiZoneIdToName(const string& identifier)
{
string zonename;
ostringstream outputStringStream;
zonename = outputStringStream.str();
try {
- return DNSName(zonename);
+ return ZoneName(zonename);
}
catch (...) {
throw ApiException("Unable to parse DNS Name '" + zonename + "'");
}
}
-string apiZoneNameToId(const DNSName& dname)
+string apiZoneNameToId(const ZoneName& dname)
{
string name = dname.toString();
ostringstream outputStringStream;
void apiServerStatistics(HttpRequest* req, HttpResponse* resp);
// helpers
-DNSName apiZoneIdToName(const string& identifier);
-string apiZoneNameToId(const DNSName& name);
+ZoneName apiZoneIdToName(const string& identifier);
+string apiZoneNameToId(const ZoneName& name);
void apiCheckNameAllowedCharacters(const string& name);
void apiCheckQNameAllowedCharacters(const string& name);
DNSName apiNameToDNSName(const string& name);
return d_max;
}
-static void patchZone(UeberBackend& backend, const DNSName& zonename, DomainInfo& domainInfo, HttpRequest* req, HttpResponse* resp);
+static void patchZone(UeberBackend& backend, const ZoneName& zonename, DomainInfo& domainInfo, HttpRequest* req, HttpResponse* resp);
// QTypes that MUST NOT have multiple records of the same type in a given RRset.
static const std::set<uint16_t> onlyOneEntryTypes = {QType::CNAME, QType::DNAME, QType::SOA};
throw ApiException("'rrsets' request parameter value '" + req->getvars["rrsets"] + "' is not supported");
}
-static void fillZone(UeberBackend& backend, const DNSName& zonename, HttpResponse* resp, HttpRequest* req)
+static void fillZone(UeberBackend& backend, const ZoneName& zonename, HttpResponse* resp, HttpRequest* req)
{
DomainInfo domainInfo;
}
}
-static void throwUnableToSecure(const DNSName& zonename)
+static void throwUnableToSecure(const ZoneName& zonename)
{
throw ApiException("No backend was able to secure '" + zonename.toString() + "', most likely because no DNSSEC"
+ "capable backends are loaded, or because the backends have DNSSEC disabled. Check your configuration.");
/*
* Add KSK and ZSK to an existing zone. Algorithms and sizes will be chosen per configuration.
*/
-static void addDefaultDNSSECKeys(DNSSECKeeper& dnssecKeeper, const DNSName& zonename)
+static void addDefaultDNSSECKeys(DNSSECKeeper& dnssecKeeper, const ZoneName& zonename)
{
checkDefaultDNSSECAlgos();
int k_algo = DNSSECKeeper::shorthand2algorithm(::arg()["default-ksk-algorithm"]);
return api_rectify == "1";
}
-static void extractDomainInfoFromDocument(const Json& document, std::optional<DomainInfo::DomainKind>& kind, std::optional<vector<ComboAddress>>& primaries, std::optional<DNSName>& catalog, std::optional<string>& account)
+static void extractDomainInfoFromDocument(const Json& document, std::optional<DomainInfo::DomainKind>& kind, std::optional<vector<ComboAddress>>& primaries, std::optional<ZoneName>& catalog, std::optional<string>& account)
{
if (document["kind"].is_string()) {
kind = DomainInfo::stringToKind(stringFromJson(document, "kind"));
if (document["catalog"].is_string()) {
string catstring = document["catalog"].string_value();
- catalog = (!catstring.empty() ? DNSName(catstring) : DNSName());
+ catalog = (!catstring.empty() ? ZoneName(catstring) : ZoneName());
}
else {
catalog = std::nullopt;
}
// Must be called within backend transaction.
-static void updateDomainSettingsFromDocument(UeberBackend& backend, DomainInfo& domainInfo, const DNSName& zonename, const Json& document, bool zoneWasModified)
+static void updateDomainSettingsFromDocument(UeberBackend& backend, DomainInfo& domainInfo, const ZoneName& zonename, const Json& document, bool zoneWasModified)
{
std::optional<DomainInfo::DomainKind> kind;
std::optional<vector<ComboAddress>> primaries;
- std::optional<DNSName> catalog;
+ std::optional<ZoneName> catalog;
std::optional<string> account;
extractDomainInfoFromDocument(document, kind, primaries, catalog, account);
}
}
- DNSName zoneName;
+ ZoneName zoneName;
UeberBackend backend{};
DNSSECKeeper dnssecKeeper;
DomainInfo domainInfo{};
}
// Throws 404 if the key with inquireKeyId does not exist
-static void apiZoneCryptoKeysCheckKeyExists(const DNSName& zonename, int inquireKeyId, DNSSECKeeper* dnssecKeeper)
+static void apiZoneCryptoKeysCheckKeyExists(const ZoneName& zonename, int inquireKeyId, DNSSECKeeper* dnssecKeeper)
{
DNSSECKeeper::keyset_t keyset = dnssecKeeper->getKeys(zonename, false);
bool found = false;
}
}
-static inline int getInquireKeyId(HttpRequest* req, const DNSName& zonename, DNSSECKeeper* dnsseckeeper)
+static inline int getInquireKeyId(HttpRequest* req, const ZoneName& zonename, DNSSECKeeper* dnsseckeeper)
{
int inquireKeyId = -1;
if (req->parameters.count("key_id") == 1) {
return inquireKeyId;
}
-static void apiZoneCryptokeysExport(const DNSName& zonename, int64_t inquireKeyId, HttpResponse* resp, DNSSECKeeper* dnssec_dk)
+static void apiZoneCryptokeysExport(const ZoneName& zonename, int64_t inquireKeyId, HttpResponse* resp, DNSSECKeeper* dnssec_dk)
{
DNSSECKeeper::keyset_t keyset = dnssec_dk->getKeys(zonename, false);
resp->status = 204;
}
-static void gatherRecordsFromZone(const std::string& zonestring, vector<DNSResourceRecord>& new_records, const DNSName& zonename)
+static void gatherRecordsFromZone(const std::string& zonestring, vector<DNSResourceRecord>& new_records, const ZoneName& zonename)
{
DNSResourceRecord resourceRecord;
vector<string> zonedata;
* *) no duplicates for QTypes that can only be present once per RRset
* *) hostnames are hostnames
*/
-static void checkNewRecords(vector<DNSResourceRecord>& records, const DNSName& zone)
+static void checkNewRecords(vector<DNSResourceRecord>& records, const ZoneName& zone)
{
sort(records.begin(), records.end(),
[](const DNSResourceRecord& rec_a, const DNSResourceRecord& rec_b) -> bool {
DNSSECKeeper dnssecKeeper(&backend);
DomainInfo domainInfo;
const auto& document = req->json();
- DNSName zonename = apiNameToDNSName(stringFromJson(document, "name"));
+ ZoneName zonename = apiNameToDNSName(stringFromJson(document, "name"));
apiCheckNameAllowedCharacters(zonename.toString());
zonename.makeUsLowerCase();
std::optional<DomainInfo::DomainKind> kind;
std::optional<vector<ComboAddress>> primaries;
- std::optional<DNSName> catalog;
+ std::optional<ZoneName> catalog;
std::optional<string> account;
extractDomainInfoFromDocument(document, kind, primaries, catalog, account);
if (req->getvars.count("zone") != 0) {
string zone = req->getvars["zone"];
apiCheckNameAllowedCharacters(zone);
- DNSName zonename = apiNameToDNSName(zone);
+ ZoneName zonename = apiNameToDNSName(zone);
zonename.makeUsLowerCase();
DomainInfo domainInfo;
if (backend.getDomainInfo(zonename, domainInfo)) {
}
// NOLINTNEXTLINE(readability-function-cognitive-complexity): TODO Refactor this function.
-static void patchZone(UeberBackend& backend, const DNSName& zonename, DomainInfo& domainInfo, HttpRequest* req, HttpResponse* resp)
+static void patchZone(UeberBackend& backend, const ZoneName& zonename, DomainInfo& domainInfo, HttpRequest* req, HttpResponse* resp)
{
bool zone_disabled = false;
SOAData soaData;
domainInfo.backend->getDomainMetadataOne(zonename, "SOA-EDIT", soa_edit_kind);
bool soa_edit_done = false;
- set<std::tuple<DNSName, QType, string>> seen;
+ set<std::tuple<ZoneName, QType, string>> seen;
for (const auto& rrset : rrsets.array_items()) {
string changetype = toUpper(stringFromJson(rrset, "changetype"));
- DNSName qname = apiNameToDNSName(stringFromJson(rrset, "name"));
+ ZoneName qname = apiNameToDNSName(stringFromJson(rrset, "name"));
apiCheckQNameAllowedCharacters(qname.toString());
QType qtype;
qtype = stringFromJson(rrset, "type");
static void apiServerCacheFlush(HttpRequest* req, HttpResponse* resp)
{
- DNSName canon = apiNameToDNSName(req->getvars["domain"]);
+ ZoneName canon = apiNameToDNSName(req->getvars["domain"]);
if (g_zoneCache.isEnabled()) {
DomainInfo domainInfo;
cerr<<"\r100% done\033\133\113"<<endl;
}
else {
- ZoneParserTNG zpt(zonefile, DNSName(::arg()["zone-name"]));
+ ZoneParserTNG zpt(zonefile, ZoneName(::arg()["zone-name"]));
zpt.setMaxGenerateSteps(::arg().asNum("max-generate-steps"));
DNSResourceRecord rr;
string zname;
unsigned int g_domainid;
string g_basedn;
string g_metadatadn;
-DNSName g_zonename;
+ZoneName g_zonename;
map<DNSName,bool> g_objects;
map<string, bool> g_entries;
map<DNSName,bool> g_recorddata;
return 1;
}
- g_zonename = DNSName(args["zone-name"]);
+ g_zonename = ZoneName(args["zone-name"]);
ZoneParserTNG zpt(args["zone-file"], g_zonename);
zpt.setMaxGenerateSteps(args.asNum("max-generate-steps"));
DNSResourceRecord rr;
cout<<"BEGIN TRANSACTION;"<<endl;
}
-static void emitDomain(const DNSName& domain, const vector<ComboAddress>* primaries = nullptr)
+static void emitDomain(const ZoneName& domain, const vector<ComboAddress>* primaries = nullptr)
{
string iDomain = domain.toStringRootDot();
if (!::arg().mustDo("secondary")) {
}
bool g_doJSONComments;
-static void emitRecord(const DNSName& zoneName, const DNSName &DNSqname, const string &qtype, const string &ocontent, int ttl, const string& comment="")
+static void emitRecord(const ZoneName& zoneName, const DNSName &DNSqname, const string &qtype, const string &ocontent, int ttl, const string& comment="")
{
string qname = DNSqname.toStringRootDot();
string zname = zoneName.toStringRootDot();
cerr<<"\r100% done\033\133\113"<<endl;
}
else {
- DNSName zonename;
+ ZoneName zonename;
if(!::arg()["zone-name"].empty())
- zonename = DNSName(::arg()["zone-name"]);
+ zonename = ZoneName(::arg()["zone-name"]);
ZoneParserTNG zpt(zonefile, zonename);
zpt.setMaxGenerateSteps(::arg().asNum("max-generate-steps"));
ValidationFailure
};
- ZoneMD(DNSName zone) :
+ ZoneMD(ZoneName zone) :
d_zone(std::move(zone))
{}
void readRecords(ZoneParserTNG& zpt);
ContentSigPair d_nsecs;
map<DNSName, ContentSigPair> d_nsec3s;
DNSName d_nsec3label;
- const DNSName d_zone;
+ const ZoneName d_zone;
const ContentSigPair empty;
};
const static string g_INstr("IN");
-ZoneParserTNG::ZoneParserTNG(const string& fname, DNSName zname, string reldir, bool upgradeContent):
+ZoneParserTNG::ZoneParserTNG(const string& fname, ZoneName zname, string reldir, bool upgradeContent):
d_reldir(std::move(reldir)), d_zonename(std::move(zname)), d_defaultttl(3600),
d_templatecounter(0), d_templatestop(0), d_templatestep(0),
d_havedollarttl(false), d_fromfile(true), d_upgradeContent(upgradeContent)
stackFile(fname);
}
-ZoneParserTNG::ZoneParserTNG(const vector<string>& zonedata, DNSName zname, bool upgradeContent):
+ZoneParserTNG::ZoneParserTNG(const vector<string>& zonedata, ZoneName zname, bool upgradeContent):
d_zonename(std::move(zname)), d_zonedata(zonedata), d_defaultttl(3600),
d_templatecounter(0), d_templatestop(0), d_templatestep(0),
d_havedollarttl(false), d_fromfile(false), d_upgradeContent(upgradeContent)
return false;
}
-DNSName ZoneParserTNG::getZoneName()
+ZoneName ZoneParserTNG::getZoneName()
{
return d_zonename;
}
stackFile(fname);
}
else if(pdns_iequals(command, "$ORIGIN") && d_parts.size() > 1) {
- d_zonename = DNSName(makeString(d_line, d_parts[1]));
+ d_zonename = ZoneName(makeString(d_line, d_parts[1]));
}
else if(pdns_iequals(command, "$GENERATE") && d_parts.size() > 2) {
if (!d_generateEnabled) {
class ZoneParserTNG
{
public:
- ZoneParserTNG(const string& fname, DNSName zname=g_rootdnsname, string reldir="", bool upgradeContent=false);
- ZoneParserTNG(const vector<string>& zonedata, DNSName zname, bool upgradeContent=false);
+ ZoneParserTNG(const string& fname, ZoneName zname=g_rootdnsname, string reldir="", bool upgradeContent=false);
+ ZoneParserTNG(const vector<string>& zonedata, ZoneName zname, bool upgradeContent=false);
~ZoneParserTNG();
bool get(DNSResourceRecord& rr, std::string* comment=0);
typedef runtime_error exception;
typedef std::deque<pair<string::size_type, string::size_type> > parts_t;
- DNSName getZoneName();
+ ZoneName getZoneName();
string getLineOfFile(); // for error reporting purposes
pair<string,int> getLineNumAndFile(); // idem
void disableGenerate()
string d_reldir;
string d_line;
DNSName d_prevqname;
- DNSName d_zonename;
+ ZoneName d_zonename;
string d_templateline;
vector<string> d_zonedata;
vector<string>::iterator d_zonedataline;