d_nqueue.push_back(nr);
}
- bool removeIf(const string &remote, uint16_t id, const DNSName &domain)
+ bool removeIf(const string& remote, uint16_t id, const DNSName& domain)
{
ServiceTuple stRemote, stQueued;
parseService(remote, stRemote);
- for(d_nqueue_t::iterator i=d_nqueue.begin(); i!=d_nqueue.end(); ++i) {
+ for (d_nqueue_t::iterator i = d_nqueue.begin(); i != d_nqueue.end(); ++i) {
parseService(i->ip, stQueued);
- if(i->id==id && stQueued.host == stRemote.host && i->domain==domain) {
+ if (i->id == id && stQueued.host == stRemote.host && i->domain == domain) {
d_nqueue.erase(i);
return true;
}
bool getOne(DNSName &domain, string &ip, uint16_t *id, bool &purged)
{
- for(d_nqueue_t::iterator i=d_nqueue.begin();i!=d_nqueue.end();++i)
+ for(d_nqueue_t::iterator i=d_nqueue.begin();i!=d_nqueue.end();++i)
if(i->next <= time(0)) {
i->attempts++;
purged=false;
time_t earliest()
{
- time_t early=std::numeric_limits<time_t>::max() - 1;
- for(d_nqueue_t::const_iterator i=d_nqueue.begin();i!=d_nqueue.end();++i)
+ time_t early=std::numeric_limits<time_t>::max() - 1;
+ for(d_nqueue_t::const_iterator i=d_nqueue.begin();i!=d_nqueue.end();++i)
early=min(early,i->next);
return early-time(0);
}
class CommunicatorClass
{
public:
- CommunicatorClass()
+ CommunicatorClass()
{
d_tickinterval=60;
d_slaveschanged = true;
}
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& master, SuckRequest::RequestPriority, bool force=false);
{
explicit RemoveSentinel(const DNSName& dn, CommunicatorClass* cc) : d_dn(dn), d_cc(cc)
{}
-
+
~RemoveSentinel()
{
try {
vector<string> addresses;
this->resolve_name(&addresses, name);
-
+
if(b) {
b->lookup(QType(QType::ANY),name,-1);
DNSZoneRecord rr;
if (di.serial != di.notified_serial)
di.backend->setNotified(di.id, di.serial);
- return true;
+ return true;
}
void NotificationQueue::dump()
}
}
-time_t CommunicatorClass::doNotifications(PacketHandler *P)
+time_t CommunicatorClass::doNotifications(PacketHandler* P)
{
- UeberBackend *B=P->getBackend();
+ UeberBackend* B = P->getBackend();
ComboAddress from;
Utility::socklen_t fromlen;
char buffer[1500];
set<int> fds = {d_nsock4, d_nsock6};
// receive incoming notifications on the nonblocking socket and take them off the list
- while(waitForMultiData(fds, 0, 0, &sock) > 0) {
- fromlen=sizeof(from);
- size=recvfrom(sock,buffer,sizeof(buffer),0,(struct sockaddr *)&from,&fromlen);
- if(size < 0)
+ while (waitForMultiData(fds, 0, 0, &sock) > 0) {
+ fromlen = sizeof(from);
+ size = recvfrom(sock, buffer, sizeof(buffer), 0, (struct sockaddr*)&from, &fromlen);
+ if (size < 0)
break;
DNSPacket p(true);
p.setRemote(&from);
- if(p.parse(buffer,(size_t)size)<0) {
- g_log<<Logger::Warning<<"Unable to parse SOA notification answer from "<<p.getRemote()<<endl;
+ if (p.parse(buffer, (size_t)size) < 0) {
+ g_log << Logger::Warning << "Unable to parse SOA notification answer from " << p.getRemote() << endl;
continue;
}
- if(p.d.rcode)
- g_log<<Logger::Warning<<"Received unsuccessful notification report for '"<<p.qdomain<<"' from "<<from.toStringWithPort()<<", error: "<<RCode::to_s(p.d.rcode)<<endl;
+ if (p.d.rcode)
+ g_log << Logger::Warning << "Received unsuccessful notification report for '" << p.qdomain << "' from " << from.toStringWithPort() << ", error: " << RCode::to_s(p.d.rcode) << endl;
- if(d_nq.removeIf(from.toStringWithPort(), p.d.id, p.qdomain))
- g_log<<Logger::Notice<<"Removed from notification list: '"<<p.qdomain<<"' to "<<from.toStringWithPort()<<" "<< (p.d.rcode ? RCode::to_s(p.d.rcode) : "(was acknowledged)")<<endl;
+ if (d_nq.removeIf(from.toStringWithPort(), p.d.id, p.qdomain))
+ g_log << Logger::Notice << "Removed from notification list: '" << p.qdomain << "' to " << from.toStringWithPort() << " " << (p.d.rcode ? RCode::to_s(p.d.rcode) : "(was acknowledged)") << endl;
else {
- g_log<<Logger::Warning<<"Received spurious notify answer for '"<<p.qdomain<<"' from "<< from.toStringWithPort()<<endl;
- //d_nq.dump();
+ g_log << Logger::Warning << "Received spurious notify answer for '" << p.qdomain << "' from " << from.toStringWithPort() << endl;
+ // d_nq.dump();
}
}
// send out possible new notifications
DNSName domain;
string ip;
- uint16_t id=0;
+ uint16_t id = 0;
bool purged;
- while(d_nq.getOne(domain, ip, &id, purged)) {
- if(!purged) {
+ while (d_nq.getOne(domain, ip, &id, purged)) {
+ if (!purged) {
try {
ComboAddress remote(ip, 53); // default to 53
- if((d_nsock6 < 0 && remote.sin4.sin_family == AF_INET6) ||
- (d_nsock4 < 0 && remote.sin4.sin_family == AF_INET)) {
- g_log<<Logger::Warning<<"Unable to notify "<<remote.toStringWithPort()<<" for domain '"<<domain<<"', address family is disabled. Is an IPv"<<(remote.sin4.sin_family == AF_INET ? "4" : "6")<<" address set in query-local-address?"<<endl;
- d_nq.removeIf(remote.toStringWithPort(), id, domain); // Remove, we'll never be able to notify
- continue; // don't try to notify what we can't!
+ if ((d_nsock6 < 0 && remote.sin4.sin_family == AF_INET6) || (d_nsock4 < 0 && remote.sin4.sin_family == AF_INET)) {
+ g_log << Logger::Warning << "Unable to notify " << remote.toStringWithPort() << " for domain '" << domain << "', address family is disabled. Is an IPv" << (remote.sin4.sin_family == AF_INET ? "4" : "6") << " address set in query-local-address?" << endl;
+ d_nq.removeIf(remote.toStringWithPort(), id, domain); // Remove, we'll never be able to notify
+ continue; // don't try to notify what we can't!
}
- if(d_preventSelfNotification && AddressIsUs(remote))
+ if (d_preventSelfNotification && AddressIsUs(remote))
continue;
sendNotification(remote.sin4.sin_family == AF_INET ? d_nsock4 : d_nsock6, domain, remote, id, B);
drillHole(domain, ip);
}
- catch(ResolverException &re) {
- g_log<<Logger::Warning<<"Error trying to resolve '"<<ip<<"' for notifying '"<<domain<<"' to server: "<<re.reason<<endl;
+ catch (ResolverException& re) {
+ g_log << Logger::Warning << "Error trying to resolve '" << ip << "' for notifying '" << domain << "' to server: " << re.reason << endl;
}
}
else
- g_log<<Logger::Warning<<"Notification for "<<domain<<" to "<<ip<<" failed after retries"<<endl;
+ g_log << Logger::Warning << "Notification for " << domain << " to " << ip << " failed after retries" << endl;
}
return d_nq.earliest();
vector<uint8_t> packet;
DNSPacketWriter pw(packet, domain, QType::SOA, 1, Opcode::Notify);
pw.getHeader()->id = id;
- pw.getHeader()->aa = true;
+ pw.getHeader()->aa = true;
if (tsigkeyname.empty() == false) {
if (!B->getTSIGKey(tsigkeyname, tsigalgorithm, tsigsecret64)) {
return true;
}
- // do we want to purge this? XXX FIXME
+ // do we want to purge this? XXX FIXME
return false;
}