for (auto& backend : backends) {
vector<DomainInfo> zones;
backend->getAllDomains(&zones, false, true);
- for (auto& di : zones) {
- zone_indices.emplace_back(std::move(di.zone), (int)di.id); // this cast should not be necessary
+ for (auto& domainInfo : zones) {
+ zone_indices.emplace_back(std::move(domainInfo.zone), (int)domainInfo.id); // this cast should not be necessary
}
}
g_zoneCache.replace(zone_indices);
void UeberBackend::rediscover(string* status)
{
- for (auto i = backends.begin(); i != backends.end(); ++i) {
+ for (auto backend = backends.begin(); backend != backends.end(); ++backend) {
string tmpstr;
- (*i)->rediscover(&tmpstr);
+ (*backend)->rediscover(&tmpstr);
if (status != nullptr) {
- *status += tmpstr + (i != backends.begin() ? "\n" : "");
+ *status += tmpstr + (backend != backends.begin() ? "\n" : "");
}
}
return false;
}
-bool UeberBackend::superMasterBackend(const string& ip, const DNSName& domain, const vector<DNSResourceRecord>& nsset, string* nameserver, string* account, DNSBackend** db)
+bool UeberBackend::superMasterBackend(const string& ip, const DNSName& domain, const vector<DNSResourceRecord>& nsset, string* nameserver, string* account, DNSBackend** dnsBackend)
{
for (auto* backend : backends) {
- if (backend->superMasterBackend(ip, domain, nsset, nameserver, account, db)) {
+ if (backend->superMasterBackend(ip, domain, nsset, nameserver, account, dnsBackend)) {
return true;
}
}
return false;
}
-UeberBackend::UeberBackend(const string& pname) :
- d_negcached(false), d_cached(false)
+UeberBackend::UeberBackend(const string& pname)
{
{
d_instances.lock()->push_back(this); // report to the static list of ourself
d_cache_ttl = ::arg().asNum("query-cache-ttl");
d_negcache_ttl = ::arg().asNum("negquery-cache-ttl");
- d_qtype = 0;
- d_stale = false;
backends = BackendMakers().all(pname == "key-only");
}
-static void del(DNSBackend* d)
+static void del(DNSBackend* backend)
{
- delete d;
+ delete backend;
}
void UeberBackend::cleanup()
return CacheResult::Hit;
}
-void UeberBackend::addNegCache(const Question& q) const
+void UeberBackend::addNegCache(const Question& question) const
{
extern AuthQueryCache QC;
if (d_negcache_ttl == 0) {
return;
}
// we should also not be storing negative answers if a pipebackend does scopeMask, but we can't pass a negative scopeMask in an empty set!
- QC.insert(q.qname, q.qtype, vector<DNSZoneRecord>(), d_negcache_ttl, q.zoneId);
+ QC.insert(question.qname, question.qtype, vector<DNSZoneRecord>(), d_negcache_ttl, question.zoneId);
}
-void UeberBackend::addCache(const Question& q, vector<DNSZoneRecord>&& rrs) const
+void UeberBackend::addCache(const Question& question, vector<DNSZoneRecord>&& rrs) const
{
extern AuthQueryCache QC;
return;
}
- for (const auto& rr : rrs) {
- if (rr.scopeMask) {
+ for (const auto& resourceRecord : rrs) {
+ if (resourceRecord.scopeMask != 0) {
return;
}
}
- QC.insert(q.qname, q.qtype, std::move(rrs), d_cache_ttl, q.zoneId);
+ QC.insert(question.qname, question.qtype, std::move(rrs), d_cache_ttl, question.zoneId);
}
void UeberBackend::alsoNotifies(const DNSName& domain, set<string>* ips)
}
}
-bool UeberBackend::get(DNSZoneRecord& rr)
+bool UeberBackend::get(DNSZoneRecord& resourceRecord)
{
// cout<<"UeberBackend::get(DNSZoneRecord) called"<<endl;
if (d_negcached) {
if (d_cached) {
while (d_cachehandleiter != d_answers.end()) {
- rr = *d_cachehandleiter++;
- if ((d_qtype == QType::ANY || rr.dr.d_type == d_qtype)) {
+ resourceRecord = *d_cachehandleiter++;
+ if ((d_qtype == QType::ANY || resourceRecord.dr.d_type == d_qtype)) {
return true;
}
}
return false;
}
- while (d_handle.get(rr)) {
- rr.dr.d_place = DNSResourceRecord::ANSWER;
- d_answers.push_back(rr);
- if ((d_qtype == QType::ANY || rr.dr.d_type == d_qtype)) {
+ while (d_handle.get(resourceRecord)) {
+ resourceRecord.dr.d_place = DNSResourceRecord::ANSWER;
+ d_answers.push_back(resourceRecord);
+ if ((d_qtype == QType::ANY || resourceRecord.dr.d_type == d_qtype)) {
return true;
}
}
//
bool UeberBackend::searchRecords(const string& pattern, int maxResults, vector<DNSResourceRecord>& result)
{
- bool rc = false;
+ bool ret = false;
for (auto i = backends.begin(); result.size() < static_cast<vector<DNSResourceRecord>::size_type>(maxResults) && i != backends.end(); ++i) {
if ((*i)->searchRecords(pattern, maxResults - result.size(), result)) {
- rc = true;
+ ret = true;
}
}
- return rc;
+ return ret;
}
bool UeberBackend::searchComments(const string& pattern, int maxResults, vector<Comment>& result)
{
- bool rc = false;
+ bool ret = false;
for (auto i = backends.begin(); result.size() < static_cast<vector<Comment>::size_type>(maxResults) && i != backends.end(); ++i) {
if ((*i)->searchComments(pattern, maxResults - result.size(), result)) {
- rc = true;
+ ret = true;
}
}
- return rc;
+ return ret;
}
AtomicCounter UeberBackend::handle::instances(0);
{
// g_log<<Logger::Warning<<"Handle instances: "<<instances<<endl;
++instances;
- parent = nullptr;
- d_hinterBackend = nullptr;
- pkt_p = nullptr;
- i = 0;
- zoneId = -1;
}
UeberBackend::handle::~handle()
--instances;
}
-bool UeberBackend::handle::get(DNSZoneRecord& r)
+bool UeberBackend::handle::get(DNSZoneRecord& record)
{
DLOG(g_log << "Ueber get() was called for a " << qtype << " record" << endl);
bool isMore = false;
- while (d_hinterBackend && !(isMore = d_hinterBackend->get(r))) { // this backend out of answers
+ while (d_hinterBackend != nullptr && !(isMore = d_hinterBackend->get(record))) { // this backend out of answers
if (i < parent->backends.size()) {
DLOG(g_log << "Backend #" << i << " of " << parent->backends.size()
<< " out of answers, taking next" << endl);
UeberBackend(const string& pname = "default");
~UeberBackend();
- bool superMasterBackend(const string& ip, const DNSName& domain, const vector<DNSResourceRecord>& nsset, string* nameserver, string* account, DNSBackend** db);
+ bool superMasterBackend(const string& ip, const DNSName& domain, const vector<DNSResourceRecord>& nsset, string* nameserver, string* account, DNSBackend** dnsBackend);
bool superMasterAdd(const AutoPrimary& primary);
bool autoPrimaryRemove(const struct AutoPrimary& primary);
static bool loadmodule(const string& name);
static bool loadModules(const vector<string>& modules, const string& path);
- static void go(void);
+ static void go();
/** This contains all registered backends. The DynListener modifies this list for us when
new modules are loaded */
class handle
{
public:
- bool get(DNSZoneRecord& dr);
+ bool get(DNSZoneRecord& record);
handle();
~handle();
//! The UeberBackend class where this handle belongs to
- UeberBackend* parent;
+ UeberBackend* parent{nullptr};
//! The current real backend, which is answering questions
- DNSBackend* d_hinterBackend;
+ DNSBackend* d_hinterBackend{nullptr};
//! DNSPacket who asked this question
- DNSPacket* pkt_p;
+ DNSPacket* pkt_p{nullptr};
DNSName qname;
//! Index of the current backend within the backends vector
- unsigned int i;
+ unsigned int i{0};
QType qtype;
- int zoneId;
+ int zoneId{-1};
private:
static AtomicCounter instances;
bool getAuth(const DNSName& 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 get(DNSZoneRecord& r);
+ bool get(DNSZoneRecord& resourceRecord);
void getAllDomains(vector<DomainInfo>* domains, bool getSerial, bool include_disabled);
void getUnfreshSlaveInfos(vector<DomainInfo>* domains);
bool createDomain(const DNSName& domain, DomainInfo::DomainKind kind, const vector<ComboAddress>& masters, const string& account);
bool doesDNSSEC();
- bool addDomainKey(const DNSName& name, const DNSBackend::KeyData& key, int64_t& id);
+ 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 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 id);
- bool activateDomainKey(const DNSName& name, unsigned int id);
- bool deactivateDomainKey(const DNSName& name, unsigned int id);
- bool publishDomainKey(const DNSName& name, unsigned int id);
- bool unpublishDomainKey(const DNSName& name, unsigned int id);
+ 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);
- void rediscover(string* status = 0);
+ void rediscover(string* status = nullptr);
void reload();
bool setTSIGKey(const DNSName& name, const DNSName& algorithm, const string& content);
} d_question;
unsigned int d_cache_ttl, d_negcache_ttl;
- uint16_t d_qtype;
+ uint16_t d_qtype{0};
- bool d_negcached;
- bool d_cached;
+ bool d_negcached{false};
+ bool d_cached{false};
static AtomicCounter* s_backendQueries;
static bool d_go;
- bool d_stale;
+ bool d_stale{false};
static bool s_doANYLookupsOnly;
enum CacheResult
};
CacheResult cacheHas(const Question& question, vector<DNSZoneRecord>& resourceRecords) const;
- void addNegCache(const Question& q) const;
- void addCache(const Question& q, vector<DNSZoneRecord>&& rrs) const;
+ 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);