]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Add conversion functions (just to be complete)
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 13 May 2026 13:19:33 +0000 (15:19 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 27 Jul 2026 10:22:10 +0000 (12:22 +0200)
Signed-off-by: Otto Moerbeek <otto.moerbeek@open-xchange.com>
pdns/recursordist/rec-rust-lib/cxxsupport.cc
pdns/recursordist/rec-rust-lib/rust-bridge-in.rs
pdns/recursordist/rec-rust-lib/rust/src/bridge.rs

index 8107bfc637076784430522516371574b5c81d145..49c4a6494d318bd4b4f9170e368ed134023b82bb 100644 (file)
@@ -546,7 +546,7 @@ static void processLine(const std::string& arg, FieldMap& map, bool mainFile)
   ::rust::String section;
   ::rust::String fieldname;
   ::rust::String type_name;
-  pdns::rust::settings::rec::Value rustvalue = {false, 0, 0.0, "", {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}};
+  pdns::rust::settings::rec::Value rustvalue = {false, 0, 0.0, "", {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}};
   if (pdns::settings::rec::oldKVToBridgeStruct(var, val, section, fieldname, type_name, rustvalue)) {
     auto overriding = !mainFile && !incremental && !simpleRustType(type_name);
     auto [existing, inserted] = map.emplace(std::pair{std::pair{section, fieldname}, pdns::rust::settings::rec::OldStyle{section, fieldname, var, std::move(type_name), rustvalue, overriding}});
@@ -663,23 +663,24 @@ std::string pdns::settings::rec::defaultsToYaml(bool postProcess)
     rustvalue.u64_val = 24;
     map.emplace(std::pair{std::pair{section, name}, pdns::rust::settings::rec::OldStyle{section, name, name, type, std::move(rustvalue), false}});
   };
-  def("dnssec", "trustanchors", "Vec<TrustAnchor>");
   def("dnssec", "negative_trustanchors", "Vec<NegativeTrustAnchor>");
   def("dnssec", "trustanchorfile", "String");
   def("dnssec", "trustanchorfile_interval", "u64");
-  def("logging", "protobuf_servers", "Vec<ProtobufServer>");
-  def("logging", "outgoing_protobuf_servers", "Vec<ProtobufServer>");
+  def("dnssec", "trustanchors", "Vec<TrustAnchor>");
+  def("incoming", "proxymappings", "Vec<ProxyMapping>");
   def("logging", "dnstap_framestream_servers", "Vec<DNSTapFrameStreamServer>");
   def("logging", "dnstap_nod_framestream_servers", "Vec<DNSTapNODFrameStreamServer>");
   def("logging", "opentelemetry_trace_conditions", "Vec<OpenTelemetryTraceCondition>");
-  def("recursor", "rpzs", "Vec<RPZ>");
-  def("recursor", "sortlists", "Vec<SortList>");
+  def("logging", "outgoing_protobuf_servers", "Vec<ProtobufServer>");
+  def("logging", "protobuf_servers", "Vec<ProtobufServer>");
+  def("recordcache", "keepwarm", "Vec<QNameAndQType>");
   def("recordcache", "zonetocaches", "Vec<ZoneToCache>");
   def("recursor", "allowed_additional_qtypes", "Vec<AllowedAdditionalQType>");
-  def("incoming", "proxymappings", "Vec<ProxyMapping>");
   def("recursor", "forwarding_catalog_zones", "Vec<ForwardingCatalogZone>");
-  def("webservice", "listen", "Vec<IncomingWSConfig>");
+  def("recursor", "rpzs", "Vec<RPZ>");
+  def("recursor", "sortlists", "Vec<SortList>");
   def("recursor", "tls_configurations", "Vec<OutgoingTLSConfiguration>");
+  def("webservice", "listen", "Vec<IncomingWSConfig>");
   // End of should be generated XXX
 
   // Convert the map to a vector, as CXX does not have any dictionary like support.
index edf470cc62ce1ecc3abffd791c5bf188f813015c..3e05dca3ad05badbd935a57af52724227a1f7fb6 100644 (file)
@@ -417,6 +417,7 @@ struct Value {
     vec_incomingwsconfig_val: Vec<IncomingWSConfig>,
     vec_outgoingtlsconfiguration_val: Vec<OutgoingTLSConfiguration>,
     vec_opentelemetrytracecondition_val: Vec<OpenTelemetryTraceCondition>,
+    vec_qnameandqtype_val: Vec<QNameAndQType>,
 }
 
 struct OldStyle {
index e84561ebc1faedce1ec8f9676a5156893d13d47b..1be715cef10abc66f5074d8b728ae3d61ddb32cc 100644 (file)
@@ -801,7 +801,6 @@ impl IncomingWSConfig {
 }
 
 impl OutgoingTLSConfiguration {
-
     fn to_yaml_map(&self) -> serde_yaml::Value {
         let mut map = serde_yaml::Mapping::new();
         inserts(&mut map, "name", &self.name);
@@ -898,6 +897,13 @@ impl OpenTelemetryTraceCondition {
 }
 
 impl QNameAndQType {
+    fn to_yaml_map(&self) -> serde_yaml::Value {
+        let mut map = serde_yaml::Mapping::new();
+        inserts(&mut map, "qname", &self.qname);
+        inserts(&mut map, "qtype", &self.qtype);
+        serde_yaml::Value::Mapping(map)
+    }
+
     pub fn validate(&self, field: &str) -> Result<(), ValidationError> {
         if self.qname.is_empty() {
             let msg = format!("{}: value may not be empty", field);
@@ -1253,6 +1259,13 @@ pub fn map_to_yaml_string(vec: &Vec<OldStyle>) -> Result<String, serde_yaml::Err
                         }
                         serde_yaml::Value::Sequence(seq)
                     }
+                    "Vec<QNameAndQType>" => {
+                        let mut seq = serde_yaml::Sequence::new();
+                        for element in &entry.value.vec_qnameandqtype_val {
+                            seq.push(element.to_yaml_map());
+                        }
+                        serde_yaml::Value::Sequence(seq)
+                    }
                     other => serde_yaml::Value::String(
                         "map_to_yaml_string: Unknown type: ".to_owned() + other,
                     ),