]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Explain two somewhat puzzling pieces of code in comments
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 6 May 2024 15:04:01 +0000 (17:04 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 6 May 2024 15:04:01 +0000 (17:04 +0200)
pdns/recursordist/settings/cxxsupport.cc

index 6f206a3d7a42faf8a858e61c1b9019ed8eed083b..38c3553de8c21077f229dd1b8fb6e208aaca65e2 100644 (file)
@@ -634,7 +634,10 @@ std::string pdns::settings::rec::defaultsToYaml()
   // Should be generated
   auto def = [&](const string& section, const string& name, const string& type) {
     pdns::rust::settings::rec::Value rustvalue{};
-    rustvalue.u64_val = 24; // XXX
+    // Dirty hack: trustanchorfile_interval is the only u64 value, set the right default for it.
+    // All for all other values below, the default is either an empty string or an empty vector.
+    // Once we get more u64 values below with different default values this hack no longer works.
+    rustvalue.u64_val = 24;
     map.emplace(std::pair{std::pair{section, name}, pdns::rust::settings::rec::OldStyle{section, name, name, type, rustvalue, false}});
   };
   def("dnssec", "trustanchors", "Vec<TrustAnchor>");
@@ -1062,6 +1065,13 @@ namespace
 {
 void fromRustToLuaConfig(const pdns::rust::settings::rec::Dnssec& dnssec, LuaConfigItems& luaConfig)
 {
+  // This function fills a luaConfig equivalent to the given YAML config, assuming luaConfig has
+  // it's default content.  The docs say: "If the sequence contains an entry for the root zone, the
+  // default root zone trust anchor is not included."  By default, a newly created luaConfig has the
+  // TAs for the root in it.  If the YAML config has an entry for these, clear them from
+  // luaConfig. Otherwise the default TA's would remain even if the YAML config is trying to set
+  // them.  This code actually clears all of the TAs in luaConfig mentioned in the YAML config, but
+  // as the luaConfig only contains the root TAs, this is equivalent (but not *very* efficient).
   for (const auto& trustAnchor : dnssec.trustanchors) {
     auto name = DNSName(std::string(trustAnchor.name));
     luaConfig.dsAnchors.erase(name);