]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Allow setting notify_allowed on zones in Recursor API
authorNate Baker <nate.baker@logix.com>
Thu, 2 May 2024 00:35:30 +0000 (19:35 -0500)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 28 May 2024 07:48:26 +0000 (09:48 +0200)
Closes #14116

pdns/recursordist/docs/http-api/zone.rst
pdns/recursordist/ws-recursor.cc

index e478317da4f6b07b723eca4f64c98e14860d2328..456e09f8a9bf7e250d410a0ddf33d5d21daf0c1e 100644 (file)
@@ -22,6 +22,7 @@ Comments are per-RRset.
   :property [RRSet] rrsets: RRSets in this zone
   :property [str] servers: For zones of type "Forwarded", addresses to send the queries to
   :property bool recursion_desired: For zones of type "Forwarded", Whether or not the RD bit should be set in the query
+  :property bool notify_allowed: For zones of type "Forwarded", Whether or not to permit incoming NOTIFY to wipe cache for the domain
 
 To properly process new zones, the following conditions must
 be true:
index af2cbfee3ea25517e16594abd1100ffdb7e69f1b..16253f5729f78c7398d9cb6a433daeb0f2a62c42 100644 (file)
@@ -232,6 +232,7 @@ static void doCreateZone(const Json& document)
   string singleIPTarget = document["single_target_ip"].string_value();
   string kind = toUpper(stringFromJson(document, "kind"));
   bool rdFlag = boolFromJson(document, "recursion_desired");
+  bool notifyAllowed = boolFromJson(document, "notify_allowed", false);
   string confbasename = "zone-" + apiZoneNameToId(zone);
 
   const string yamlAPiZonesFile = ::arg()["api-config-dir"] + "/apizones";
@@ -280,7 +281,7 @@ static void doCreateZone(const Json& document)
       pdns::rust::settings::rec::ForwardZone forward;
       forward.zone = zonename;
       forward.recurse = rdFlag;
-      forward.notify_allowed = false;
+      forward.notify_allowed = notifyAllowed;
       for (const auto& value : document["servers"].array_items()) {
         forward.forwarders.emplace_back(value.string_value());
       }
@@ -308,11 +309,12 @@ static void doCreateZone(const Json& document)
         throw ApiException("Need at least one upstream server when forwarding");
       }
 
+      const string notifyAllowedConfig = notifyAllowed ? "\nallow-notify-for+=" + zonename : "";
       if (rdFlag) {
-        apiWriteConfigFile(confbasename, "forward-zones-recurse+=" + zonename + "=" + serverlist);
+        apiWriteConfigFile(confbasename, "forward-zones-recurse+=" + zonename + "=" + serverlist + notifyAllowedConfig);
       }
       else {
-        apiWriteConfigFile(confbasename, "forward-zones+=" + zonename + "=" + serverlist);
+        apiWriteConfigFile(confbasename, "forward-zones+=" + zonename + "=" + serverlist + notifyAllowedConfig);
       }
     }
   }