for(;;) {
slaveRefresh(&P);
masterUpdateCheck(&P);
- tick=doNotifications(); // this processes any notification acknowledgements and actually send out our own notifications
+ tick=doNotifications(&P); // this processes any notification acknowledgements and actually send out our own notifications
tick = min (tick, d_tickinterval);
break; // something happened
}
// this gets executed at least once every second
- doNotifications();
+ doNotifications(&P);
}
}
}
d_nsock6 = -1;
d_preventSelfNotification = false;
}
- time_t doNotifications();
+ time_t doNotifications(PacketHandler *P);
void go();
void notify(const DNSName &domain, const string &ip);
void mainloop();
void retrievalLoopThread();
- void sendNotification(int sock, const DNSName &domain, const ComboAddress& remote, uint16_t id);
+ void sendNotification(int sock, const DNSName &domain, const ComboAddress& remote, uint16_t id, UeberBackend* B);
static void *launchhelper(void *p)
{
static_cast<CommunicatorClass *>(p)->retrievalLoopThread();
return 0;
}
- bool notifyDomain(const DNSName &domain);
+ bool notifyDomain(const DNSName &domain, UeberBackend* B);
private:
void loadArgsIntoSet(const char *listname, set<string> &listset);
void makeNotifySockets();
for (const auto& di : domains) {
if (di.kind == DomainInfo::Master || di.kind == DomainInfo::Slave) { // MASTER and Slave if slave-renotify is enabled
total++;
- if(Communicator.notifyDomain(di.zone))
+ if(Communicator.notifyDomain(di.zone, &B))
notified++;
}
}
} catch (...) {
return "Failed to parse domain as valid DNS name";
}
- if(!Communicator.notifyDomain(DNSName(parts[1])))
+ if(!Communicator.notifyDomain(DNSName(parts[1]), &B))
return "Failed to add to the queue - see log";
return "Added to queue";
}
}
-bool CommunicatorClass::notifyDomain(const DNSName &domain)
+bool CommunicatorClass::notifyDomain(const DNSName &domain, UeberBackend* B)
{
DomainInfo di;
- UeberBackend B;
- if(!B.getDomainInfo(domain, di)) {
+ if(!B->getDomainInfo(domain, di)) {
g_log<<Logger::Error<<"No such domain '"<<domain<<"' in our database"<<endl;
return false;
}
- queueNotifyDomain(di, &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);
}
}
-time_t CommunicatorClass::doNotifications()
+time_t CommunicatorClass::doNotifications(PacketHandler *P)
{
+ UeberBackend *B=P->getBackend();
ComboAddress from;
Utility::socklen_t fromlen;
char buffer[1500];
if(d_preventSelfNotification && AddressIsUs(remote))
continue;
- sendNotification(remote.sin4.sin_family == AF_INET ? d_nsock4 : d_nsock6, domain, remote, id);
+ sendNotification(remote.sin4.sin_family == AF_INET ? d_nsock4 : d_nsock6, domain, remote, id, B);
drillHole(domain, ip);
}
catch(ResolverException &re) {
return d_nq.earliest();
}
-void CommunicatorClass::sendNotification(int sock, const DNSName& domain, const ComboAddress& remote, uint16_t id)
+void CommunicatorClass::sendNotification(int sock, const DNSName& domain, const ComboAddress& remote, uint16_t id, UeberBackend *B)
{
- UeberBackend B;
vector<string> meta;
DNSName tsigkeyname;
DNSName tsigalgorithm;
string tsigsecret64;
string tsigsecret;
- if (::arg().mustDo("send-signed-notify") && B.getDomainMetadata(domain, "TSIG-ALLOW-AXFR", meta) && meta.size() > 0) {
+ if (::arg().mustDo("send-signed-notify") && B->getDomainMetadata(domain, "TSIG-ALLOW-AXFR", meta) && meta.size() > 0) {
tsigkeyname = DNSName(meta[0]);
}
pw.getHeader()->aa = true;
if (tsigkeyname.empty() == false) {
- if (!B.getTSIGKey(tsigkeyname, &tsigalgorithm, &tsigsecret64)) {
+ if (!B->getTSIGKey(tsigkeyname, &tsigalgorithm, &tsigsecret64)) {
g_log<<Logger::Error<<"TSIG key '"<<tsigkeyname<<"' for domain '"<<domain<<"' not found"<<endl;
return;
}
vector<string> notify;
B.getDomainMetadata(p->qdomain, "NOTIFY-DNSUPDATE", notify);
if (!notify.empty() && notify.front() == "1") {
- Communicator.notifyDomain(di.zone);
+ Communicator.notifyDomain(di.zone, &B);
}
}
}
}
if(renotify)
- notifyDomain(domain);
+ notifyDomain(domain, &B);
}
catch(DBException &re) {
g_log<<Logger::Error<<"Unable to feed record during incoming AXFR of '" << domain<<"': "<<re.reason<<endl;
throw HttpNotFoundException();
}
- if(!Communicator.notifyDomain(zonename))
+ if(!Communicator.notifyDomain(zonename, &B))
throw ApiException("Failed to add to the queue - see server log");
resp->setSuccessResult("Notification queued");