}
vector<DomainInfo> allMasters;
- int numanswers=d_result.size();
- for(int n=0;n<numanswers;++n) { // id,name,master,last_check,notified_serial
+ size_t numanswers=d_result.size();
+ for(size_t n=0;n<numanswers;++n) { // id,name,master,last_check,notified_serial
DomainInfo sd;
ASSERT_ROW_COLUMNS("info-all-master-query", d_result[n], 6);
sd.id=pdns_stou(d_result[n][0]);
d_masterschanged=d_slaveschanged=true;
d_nsock4 = -1;
d_nsock6 = -1;
- d_havepriosuckrequest = false;
d_preventSelfNotification = false;
}
time_t doNotifications();
bool notifyDomain(const DNSName &domain);
private:
void makeNotifySockets();
- void queueNotifyDomain(const DNSName &domain, UeberBackend *B);
+ void queueNotifyDomain(const DomainInfo& di, UeberBackend* B);
int d_nsock4, d_nsock6;
map<pair<DNSName,string>,time_t>d_holes;
pthread_mutex_t d_holelock;
- void launchRetrievalThreads();
void suck(const DNSName &domain, const string &remote);
void ixfrSuck(const DNSName &domain, const TSIGTriplet& tt, const ComboAddress& laddr, const ComboAddress& remote, boost::scoped_ptr<AuthLua>& pdl,
ZoneStatus& zs, vector<DNSRecord>* axfr);
set<string> d_alsoNotify;
NotificationQueue d_nq;
NetmaskGroup d_onlyNotify;
- bool d_havepriosuckrequest;
bool d_masterschanged, d_slaveschanged;
bool d_preventSelfNotification;
return addresses;
}
- vector<string> lookup(const DNSName &name, UeberBackend *b)
- {
- vector<string> addresses;
-
- this->resolve_name(&addresses, name);
-
- if(b) {
- b->lookup(QType(QType::ANY),name);
- DNSResourceRecord rr;
- while(b->get(rr))
- if(rr.qtype.getCode() == QType::A || rr.qtype.getCode()==QType::AAAA)
- addresses.push_back(rr.content); // SOL if you have a CNAME for an NS
- }
- return addresses;
- }
-
private:
void resolve_name(vector<string>* addresses, const DNSName& name)
{
#include "namespaces.hh"
-void CommunicatorClass::queueNotifyDomain(const DNSName &domain, UeberBackend *B)
+void CommunicatorClass::queueNotifyDomain(const DomainInfo& di, UeberBackend* B)
{
bool hasQueuedItem=false;
set<string> nsset, ips;
DNSResourceRecord rr;
FindNS fns;
- B->lookup(QType(QType::NS),domain);
- while(B->get(rr))
+ di.backend->lookup(QType(QType::NS), di.zone);
+ while(di.backend->get(rr))
nsset.insert(rr.content);
for(set<string>::const_iterator j=nsset.begin();j!=nsset.end();++j) {
- vector<string> nsips=fns.lookup(DNSName(*j), B);
+ vector<string> nsips=fns.lookup(DNSName(*j), di.backend);
if(nsips.empty())
- L<<Logger::Warning<<"Unable to queue notification of domain '"<<domain<<"': nameservers do not resolve!"<<endl;
+ L<<Logger::Warning<<"Unable to queue notification of domain '"<<di.zone<<"': nameservers do not resolve!"<<endl;
else
for(vector<string>::const_iterator k=nsips.begin();k!=nsips.end();++k) {
const ComboAddress caIp(*k, 53);
if(!d_preventSelfNotification || !AddressIsUs(caIp)) {
if(!d_onlyNotify.match(&caIp))
- L<<Logger::Info<<"Skipped notification of domain '"<<domain<<"' to "<<*j<<" because it does not match only-notify."<<endl;
+ L<<Logger::Info<<"Skipped notification of domain '"<<di.zone<<"' to "<<*j<<" because it does not match only-notify."<<endl;
else
ips.insert(caIp.toStringWithPort());
}
}
for(set<string>::const_iterator j=ips.begin();j!=ips.end();++j) {
- L<<Logger::Warning<<"Queued notification of domain '"<<domain<<"' to "<<*j<<endl;
- d_nq.add(domain,*j);
+ L<<Logger::Warning<<"Queued notification of domain '"<<di.zone<<"' to "<<*j<<endl;
+ d_nq.add(di.zone,*j);
hasQueuedItem=true;
}
set<string> alsoNotify(d_alsoNotify);
- B->alsoNotifies(domain, &alsoNotify);
+ B->alsoNotifies(di.zone, &alsoNotify);
for(set<string>::const_iterator j=alsoNotify.begin();j!=alsoNotify.end();++j) {
try {
const ComboAddress caIp(*j, 53);
- L<<Logger::Warning<<"Queued also-notification of domain '"<<domain<<"' to "<<caIp.toStringWithPort()<<endl;
+ L<<Logger::Warning<<"Queued also-notification of domain '"<<di.zone<<"' to "<<caIp.toStringWithPort()<<endl;
if (!ips.count(caIp.toStringWithPort())) {
ips.insert(caIp.toStringWithPort());
- d_nq.add(domain, caIp.toStringWithPort());
+ d_nq.add(di.zone, caIp.toStringWithPort());
}
hasQueuedItem=true;
}
catch(PDNSException &e) {
- L<<Logger::Warning<<"Unparseable IP in ALSO-NOTIFY metadata of domain '"<<domain<<"'. Warning: "<<e.reason<<endl;
+ L<<Logger::Warning<<"Unparseable IP in ALSO-NOTIFY metadata of domain '"<<di.zone<<"'. Warning: "<<e.reason<<endl;
}
}
if (!hasQueuedItem)
- L<<Logger::Warning<<"Request to queue notification for domain '"<<domain<<"' was processed, but no valid nameservers or ALSO-NOTIFYs found. Not notifying!"<<endl;
+ L<<Logger::Warning<<"Request to queue notification for domain '"<<di.zone<<"' was processed, but no valid nameservers or ALSO-NOTIFYs found. Not notifying!"<<endl;
}
L<<Logger::Error<<"No such domain '"<<domain<<"' in our database"<<endl;
return false;
}
- queueNotifyDomain(domain, &B);
+ queueNotifyDomain(di, &B);
// call backend and tell them we sent out the notification - even though that is premature
di.backend->setNotified(di.id, di.serial);
// figure out A records of everybody needing notification
// do this via the FindNS class, d_fns
- for(vector<DomainInfo>::const_iterator i=cmdomains.begin();i!=cmdomains.end();++i) {
+ for(auto& di : cmdomains) {
extern PacketCache PC;
- PC.purgeExact(i->zone);
- queueNotifyDomain(i->zone,P->getBackend());
- i->backend->setNotified(i->id,i->serial);
+ PC.purgeExact(di.zone);
+ queueNotifyDomain(di, B);
+ di.backend->setNotified(di.id, di.serial);
}
}
di.backend->startTransaction(domain, -1);
for(const auto g : grouped) {
- DNSResourceRecord rr;
vector<DNSRecord> rrset;
- B.lookup(QType(g.first.second), g.first.first, 0, di.id);
- while(B.get(rr)) {
- rrset.push_back(DNSRecord{rr});
+ {
+ DNSZoneRecord zrr;
+ B.lookup(QType(g.first.second), g.first.first, 0, di.id);
+ while(B.get(zrr)) {
+ rrset.push_back(zrr.dr);
+ }
}
// O(N^2)!
rrset.erase(remove_if(rrset.begin(), rrset.end(),
}
else {
B->lookup(QType(QType::RRSIG), di.zone); // can't use DK before we are done with this lookup!
- DNSResourceRecord rr;
+ DNSZoneRecord zr;
uint32_t maxExpire=0, maxInception=0;
- while(B->get(rr)) {
- RRSIGRecordContent rrc(rr.content);
- if(rrc.d_type == QType::SOA) {
- maxInception = std::max(maxInception, rrc.d_siginception);
- maxExpire = std::max(maxExpire, rrc.d_sigexpire);
+ while(B->get(zr)) {
+ auto rrsig = getRR<RRSIGRecordContent>(zr.dr);
+ if(rrsig->d_type == QType::SOA) {
+ maxInception = std::max(maxInception, rrsig->d_siginception);
+ maxExpire = std::max(maxExpire, rrsig->d_sigexpire);
}
}
if(maxInception == ssr.d_freshness[di.id].theirInception && maxExpire == ssr.d_freshness[di.id].theirExpire) {
}
}
-bool UeberBackend::get(DNSResourceRecord &rr)
-{
- // cout<<"UeberBackend::get(DNSResourceRecord&) called, translating to a DNSZoneRecord query"<<endl;
- DNSZoneRecord dzr;
- if(!this->get(dzr))
- return false;
-
- rr=DNSResourceRecord(dzr.dr);
- rr.auth = dzr.auth;
- rr.domain_id = dzr.domain_id;
- return true;
-}
-
bool UeberBackend::get(DNSZoneRecord &rr)
{
// cout<<"UeberBackend::get(DNSZoneRecord) called"<<endl;
bool getAuth(DNSPacket *p, SOAData *sd, const DNSName &target);
bool getSOA(const DNSName &domain, SOAData &sd, DNSPacket *p=0);
bool getSOAUncached(const DNSName &domain, SOAData &sd, DNSPacket *p=0); // same, but ignores cache
- bool get(DNSResourceRecord &r);
bool get(DNSZoneRecord &r);
void getAllDomains(vector<DomainInfo> *domains, bool include_disabled=false);