]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Add views configuration setting and reject non-working configuration.
authorMiod Vallat <miod.vallat@powerdns.com>
Mon, 7 Apr 2025 09:55:35 +0000 (11:55 +0200)
committerMiod Vallat <miod.vallat@powerdns.com>
Fri, 23 May 2025 09:52:46 +0000 (11:52 +0200)
pdns/auth-main.cc
pdns/auth-main.hh

index 2f276179e87ad0c099dbe929db224f94f579c29a..adaeb3cc8e1686c017030e5fae081add701b9e3a 100644 (file)
@@ -116,6 +116,7 @@ time_t g_luaConsistentHashesCleanupInterval{3600};
 #ifdef ENABLE_GSS_TSIG
 bool g_doGssTSIG;
 #endif
+bool g_views;
 typedef Distributor<DNSPacket, DNSPacket, PacketHandler> DNSDistributor;
 
 ArgvMap theArg;
@@ -343,6 +344,9 @@ static void declareArguments()
 #ifdef ENABLE_GSS_TSIG
   ::arg().setSwitch("enable-gss-tsig", "Enable GSS TSIG processing") = "no";
 #endif
+
+  ::arg().setSwitch("views", "Enable views (variants) of zones, for backends which support them") = "no";
+
   ::arg().setDefaults();
 }
 
@@ -719,6 +723,7 @@ static void mainthread()
 #ifdef ENABLE_GSS_TSIG
   g_doGssTSIG = ::arg().mustDo("enable-gss-tsig");
 #endif
+  g_views = ::arg().mustDo("views");
 
   DNSPacket::s_udpTruncationThreshold = std::max(512, ::arg().asNum("udp-truncation-threshold"));
   DNSPacket::s_doEDNSSubnetProcessing = ::arg().mustDo("edns-subnet-processing");
@@ -747,6 +752,16 @@ static void mainthread()
 #endif
   }
 
+  // Check for mutually incompatible settings:
+  // - enabling views currently requires the zone cache to be active
+  if (g_views) {
+    if (::arg().asNum("zone-cache-refresh-interval") == 0) {
+      g_log << Logger::Error << R"(Error: use of views requires the zone cache to be enabled, please set "zone-cache-refresh-interval" to a nonzero value.)" << endl;
+      exit(1); // NOLINT(concurrency-mt-unsafe) we're single threaded at this point
+    }
+  }
+  // (no more checks yet)
+
   PC.setTTL(::arg().asNum("cache-ttl"));
   PC.setMaxEntries(::arg().asNum("max-packet-cache-entries"));
   QC.setMaxEntries(::arg().asNum("max-cache-entries"));
index bc3d90c0d77d344fa01ea8fe4274ef96db916338..e368601a217f1a021c492d35e4c5def9abe1746a 100644 (file)
@@ -56,3 +56,4 @@ extern time_t g_luaHealthChecksExpireDelay;
 extern time_t g_luaConsistentHashesExpireDelay;
 extern time_t g_luaConsistentHashesCleanupInterval;
 #endif // HAVE_LUA_RECORDS
+extern bool g_views;