Skip to content

Commit

Permalink
auth: add a configurable delay for notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
chbruyand committed Dec 18, 2023
1 parent 926a220 commit 7bd9b30
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions pdns/auth-main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ static void declareArguments()
::arg().setSwitch("prevent-self-notification", "Don't send notifications to what we think is ourself") = "yes";
::arg().setSwitch("any-to-tcp", "Answer ANY queries with tc=1, shunting to TCP") = "yes";
::arg().setSwitch("edns-subnet-processing", "If we should act on EDNS Subnet options") = "no";
::arg().set("delay-notifications", "Configure a delay to send out notifications, no delay by default") = "0";

::arg().set("edns-cookie-secret", "When set, set a server cookie when responding to a query with a Client cookie (in hex)") = "";

Expand Down Expand Up @@ -326,6 +327,7 @@ static void declareArguments()
::arg().set("rng", "Specify the random number generator to use. Valid values are auto,sodium,openssl,getrandom,arc4random,urandom.") = "auto";

::arg().set("default-catalog-zone", "Catalog zone to assign newly created primary zones (via the API) to") = "";

#ifdef ENABLE_GSS_TSIG
::arg().setSwitch("enable-gss-tsig", "Enable GSS TSIG processing") = "no";
#endif
Expand Down
4 changes: 2 additions & 2 deletions pdns/auth-primarycommunicator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void CommunicatorClass::queueNotifyDomain(const DomainInfo& di, UeberBackend* B)

for (const auto& ip : ips) {
g_log << Logger::Notice << "Queued notification of domain '" << di.zone << "' to " << ip << endl;
d_nq.add(di.zone, ip);
d_nq.add(di.zone, ip, d_delayNotifications);
hasQueuedItem = true;
}
}
Expand All @@ -98,7 +98,7 @@ void CommunicatorClass::queueNotifyDomain(const DomainInfo& di, UeberBackend* B)
g_log << Logger::Notice << "Queued also-notification of domain '" << di.zone << "' to " << caIp.toStringWithPort() << endl;
if (!ips.count(caIp.toStringWithPort())) {
ips.insert(caIp.toStringWithPort());
d_nq.add(di.zone, caIp.toStringWithPort());
d_nq.add(di.zone, caIp.toStringWithPort(), d_delayNotifications);
}
hasQueuedItem = true;
}
Expand Down
5 changes: 5 additions & 0 deletions pdns/communicator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ void CommunicatorClass::go()

d_preventSelfNotification = ::arg().mustDo("prevent-self-notification");

auto delay = ::arg().asNum("delay-notifications");
if (delay > 0) {
d_delayNotifications = static_cast<time_t>(delay);
}

try {
d_onlyNotify.toMasks(::arg()["only-notify"]);
}
Expand Down
5 changes: 3 additions & 2 deletions pdns/communicator.hh
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ typedef UniQueue::index<IDTag>::type domains_by_name_t;
class NotificationQueue
{
public:
void add(const DNSName &domain, const string &ip)
void add(const DNSName &domain, const string &ip, time_t delay = 0)
{
const ComboAddress caIp(ip);

Expand All @@ -77,7 +77,7 @@ public:
nr.ip = caIp.toStringWithPort();
nr.attempts = 0;
nr.id = dns_random_uint16();
nr.next = time(0);
nr.next = time(nullptr) + delay;

d_nqueue.push_back(nr);
}
Expand Down Expand Up @@ -195,6 +195,7 @@ private:
time_t d_tickinterval;
bool d_secondarieschanged;
bool d_preventSelfNotification;
time_t d_delayNotifications{0};

struct Data
{
Expand Down

0 comments on commit 7bd9b30

Please sign in to comment.