]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: add a configurable delay for notifications
authorCharles-Henri Bruyand <charles-henri.bruyand@open-xchange.com>
Mon, 18 Dec 2023 13:40:44 +0000 (14:40 +0100)
committerCharles-Henri Bruyand <charles-henri.bruyand@open-xchange.com>
Mon, 18 Dec 2023 13:40:44 +0000 (14:40 +0100)
pdns/auth-main.cc
pdns/auth-primarycommunicator.cc
pdns/communicator.cc
pdns/communicator.hh

index 59a3e2111fd783240efc893498e50edf745d7ec2..3aa88e6a639f780cb06254d2a5af3d7d86197eb2 100644 (file)
@@ -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)") = "";
 
@@ -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
index 1ee65e0849a9d4d50d3f7757697ea50715284e15..1b9ff3b3a49362071b85f80eca3ae7f183fcb89e 100644 (file)
@@ -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;
       }
     }
@@ -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;
     }
index 20cadfd7bfbc2ae7f895656d84cf8925378df38d..2f43db2873f553242a761de3ff9cd6ab711aaaf3 100644 (file)
@@ -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"]);
   }
index 20ac6c572348cc8dce0386b9341a0d8baeaacb37..fcb13dd4f90f29e037f1709be0ce033bac09676e 100644 (file)
@@ -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);
 
@@ -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);
   }
@@ -195,6 +195,7 @@ private:
   time_t d_tickinterval;
   bool d_secondarieschanged;
   bool d_preventSelfNotification;
+  time_t d_delayNotifications{0};
 
   struct Data
   {