From: Otto Moerbeek Date: Wed, 1 Apr 2026 08:30:01 +0000 (+0200) Subject: Add keepwarm to recordcache config X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e37d006002d07c36e81626b4012f2666c8d4e7cd;p=thirdparty%2Fpdns.git Add keepwarm to recordcache config Signed-off-by: Otto Moerbeek --- diff --git a/pdns/recursordist/rec-rust-lib/generate.py b/pdns/recursordist/rec-rust-lib/generate.py index f9acf90f61..03fd5f8d21 100644 --- a/pdns/recursordist/rec-rust-lib/generate.py +++ b/pdns/recursordist/rec-rust-lib/generate.py @@ -119,10 +119,10 @@ class LType(Enum): ListSubnets = auto() ListTrustAnchors = auto() ListZoneToCaches = auto() + ListQNameAndQTypes = auto() String = auto() Uint64 = auto() - listOfStringTypes = (LType.ListSocketAddresses, LType.ListStrings, LType.ListSubnets, LType.ListAddressAndInterfaces) listOfStructuredTypes = ( LType.ListAuthZones, @@ -141,6 +141,7 @@ listOfStructuredTypes = ( LType.ListIncomingWSConfigs, LType.ListOutgoingTLSConfigurations, LType.ListOpenTelemetryTraceConditions, + LType.ListQNameAndQTypes, ) @@ -219,6 +220,8 @@ def get_newdoc_typename(typ): return "Sequence of `OpenTelemetryTraceCondition`_" if typ == LType.ListAddressAndInterfaces: return "Sequence of address or address@interface_" + if typ == LType.ListQNameAndQTypes: + return "Sequence of `QNameAndQType`_" return "Unknown2" + str(typ) diff --git a/pdns/recursordist/rec-rust-lib/rust-bridge-in.rs b/pdns/recursordist/rec-rust-lib/rust-bridge-in.rs index 821b7a7d9e..edf470cc62 100644 --- a/pdns/recursordist/rec-rust-lib/rust-bridge-in.rs +++ b/pdns/recursordist/rec-rust-lib/rust-bridge-in.rs @@ -384,6 +384,15 @@ struct OpenTelemetryTraceCondition { traceid_only: bool, } +#[derive(Deserialize, Serialize, Clone, Debug, PartialEq)] +#[serde(deny_unknown_fields)] +struct QNameAndQType { + #[serde(default, skip_serializing_if = "crate::is_default")] + qname: String, + #[serde(default = "crate::def_qnameandqtype_qtype", skip_serializing_if = "crate::def_value_equals_qnameqtype_qtype")] + qtype: String, +} + // Two structs used to generated YAML based on a vector of name to value mappings // Cannot use Enum as CXX has only very basic Enum support struct Value { diff --git a/pdns/recursordist/rec-rust-lib/rust/src/bridge.rs b/pdns/recursordist/rec-rust-lib/rust/src/bridge.rs index 8ef3585070..e84561ebc1 100644 --- a/pdns/recursordist/rec-rust-lib/rust/src/bridge.rs +++ b/pdns/recursordist/rec-rust-lib/rust/src/bridge.rs @@ -897,6 +897,18 @@ impl OpenTelemetryTraceCondition { } } +impl QNameAndQType { + pub fn validate(&self, field: &str) -> Result<(), ValidationError> { + if self.qname.is_empty() { + let msg = format!("{}: value may not be empty", field); + return Err(ValidationError { msg }); + } + validate_qtype(&(field.to_string() + ".qtype"), &self.qtype)?; + Ok(()) + } +} + + #[allow(clippy::ptr_arg)] //# Avoids creating a rust::Slice object on the C++ side. pub fn validate_auth_zones(field: &str, vec: &Vec) -> Result<(), ValidationError> { validate_vec(field, vec, |field, element| element.validate(field)) @@ -1423,6 +1435,14 @@ pub fn def_value_equals_pb_strategy(value: &String) -> bool { &def_pb_strategy() == value } +pub fn def_qnameandqtype_qtype() -> String { + String::from("A") +} + +pub fn def_value_equals_qnameqtype_qtype(value: &String) -> bool { + &def_qnameandqtype_qtype() == value +} + pub fn validate_dnssec(dnssec: &recsettings::Dnssec) -> Result<(), ValidationError> { let val = dnssec.validation.as_str(); match val { diff --git a/pdns/recursordist/rec-rust-lib/table.py b/pdns/recursordist/rec-rust-lib/table.py index f0c88473f2..04bb2835bb 100644 --- a/pdns/recursordist/rec-rust-lib/table.py +++ b/pdns/recursordist/rec-rust-lib/table.py @@ -3690,4 +3690,17 @@ A DoT connection is matched against the subnets lists (using the remote IP) and "versionadded": "5.4.0", "runtime": ["reload-lua-config", "reload-yaml"], }, + { + "name": "keepwarm", + "section": "recordcache", + "type": LType.ListQNameAndQTypes, + "default": "", + "help": "Sequence of QNameAndQType", + "doc": """ + List of names to keep warm in the cache + """, + "skip-old": "No equivalent old style setting", + "versionadded": "5.5.0", + "runtime": ["reload-lua-config", "reload-yaml"], + }, ]