From: Miod Vallat Date: Mon, 7 Apr 2025 09:55:35 +0000 (+0200) Subject: Add views configuration setting and reject non-working configuration. X-Git-Tag: auth-5.0.0-alpha1~1^2~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f22859787329e0e0b47102a86c9e747e18d21bf;p=thirdparty%2Fpdns.git Add views configuration setting and reject non-working configuration. --- diff --git a/pdns/auth-main.cc b/pdns/auth-main.cc index 2f276179e8..adaeb3cc8e 100644 --- a/pdns/auth-main.cc +++ b/pdns/auth-main.cc @@ -116,6 +116,7 @@ time_t g_luaConsistentHashesCleanupInterval{3600}; #ifdef ENABLE_GSS_TSIG bool g_doGssTSIG; #endif +bool g_views; typedef Distributor 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")); diff --git a/pdns/auth-main.hh b/pdns/auth-main.hh index bc3d90c0d7..e368601a21 100644 --- a/pdns/auth-main.hh +++ b/pdns/auth-main.hh @@ -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;