From: Otto Moerbeek Date: Tue, 28 Oct 2025 11:18:15 +0000 (+0100) Subject: Add missing pieces for for default printing X-Git-Tag: rec-5.4.0-alpha1~108^2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=91416fd99024127d83a6b79bd05a49e81bb8e162;p=thirdparty%2Fpdns.git Add missing pieces for for default printing Signed-off-by: Otto Moerbeek --- diff --git a/pdns/recursordist/rec-rust-lib/cxxsupport.cc b/pdns/recursordist/rec-rust-lib/cxxsupport.cc index cfe7a7dfaf..0211735858 100644 --- a/pdns/recursordist/rec-rust-lib/cxxsupport.cc +++ b/pdns/recursordist/rec-rust-lib/cxxsupport.cc @@ -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}}); @@ -677,6 +677,8 @@ std::string pdns::settings::rec::defaultsToYaml() def("recursor", "allowed_additional_qtypes", "Vec"); def("incoming", "proxymappings", "Vec"); def("recursor", "forwarding_catalog_zones", "Vec"); + def("webservice", "listen", "Vec"); + def("recursor", "tls_configurations", "Vec"); // End of should be generated XXX // Convert the map to a vector, as CXX does not have any dictionary like support. diff --git a/pdns/recursordist/rec-rust-lib/generate.py b/pdns/recursordist/rec-rust-lib/generate.py index 902c344fd6..e0afd99095 100644 --- a/pdns/recursordist/rec-rust-lib/generate.py +++ b/pdns/recursordist/rec-rust-lib/generate.py @@ -313,7 +313,7 @@ def gen_cxx_oldstylesettingstobridgestruct(file, entries): elif rust_type == 'Vec': file.write(f'getAuthZones("{oldname}")') else: - file.write(f'Unknown type {rust_type}\n') + file.write(f'Unknown3 type {rust_type}\n') file.write(';\n') file.write('}\n\n') @@ -367,7 +367,7 @@ def gen_cxx_oldkvtobridgestruct(file, entries): file.write(f' to_yaml(rustvalue.vec_authzone_val, value{extra});\n') file.write(' return true;\n }\n') else: - file.write(f'Unknown type {rust_type}\n') + file.write(f'Unknown4 type {rust_type}\n') file.write(' return false;\n') file.write('}\n\n') diff --git a/pdns/recursordist/rec-rust-lib/rust-bridge-in.rs b/pdns/recursordist/rec-rust-lib/rust-bridge-in.rs index b1e8a2214b..abe35bdd8b 100644 --- a/pdns/recursordist/rec-rust-lib/rust-bridge-in.rs +++ b/pdns/recursordist/rec-rust-lib/rust-bridge-in.rs @@ -371,6 +371,8 @@ struct Value { vec_allowedadditionalqtype_val: Vec, vec_proxymapping_val: Vec, vec_forwardingcatalogzone_val: Vec, + vec_incomingwsconfig_val: Vec, + vec_outgoingtlsconfiguration_val: Vec, } struct OldStyle { diff --git a/pdns/recursordist/rec-rust-lib/rust/src/bridge.rs b/pdns/recursordist/rec-rust-lib/rust/src/bridge.rs index 95b8b43a56..89dd401ee0 100644 --- a/pdns/recursordist/rec-rust-lib/rust/src/bridge.rs +++ b/pdns/recursordist/rec-rust-lib/rust/src/bridge.rs @@ -767,6 +767,13 @@ impl ForwardingCatalogZone { } impl IncomingWSConfig { + + fn to_yaml_map(&self) -> serde_yaml::Value { + // XXX + let map = serde_yaml::Mapping::new(); + serde_yaml::Value::Mapping(map) + } + pub fn validate(&self, _field: &str) -> Result<(), ValidationError> { // XXX Ok(()) @@ -774,6 +781,13 @@ impl IncomingWSConfig { } impl OutgoingTLSConfiguration { + + fn to_yaml_map(&self) -> serde_yaml::Value { + // XXX + let map = serde_yaml::Mapping::new(); + serde_yaml::Value::Mapping(map) + } + pub fn validate(&self, field: &str) -> Result<(), ValidationError> { if self.name.is_empty() { let msg = format!("{}: value may not be empty", field); @@ -1021,6 +1035,20 @@ pub fn map_to_yaml_string(vec: &Vec) -> Result" => { + let mut seq = serde_yaml::Sequence::new(); + for element in &entry.value.vec_outgoingtlsconfiguration_val { + seq.push(element.to_yaml_map()); + } + serde_yaml::Value::Sequence(seq) + } + "Vec" => { + let mut seq = serde_yaml::Sequence::new(); + for element in &entry.value.vec_incomingwsconfig_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, ), diff --git a/pdns/recursordist/rec_channel_rec.cc b/pdns/recursordist/rec_channel_rec.cc index 51782812cc..c235fd6535 100644 --- a/pdns/recursordist/rec_channel_rec.cc +++ b/pdns/recursordist/rec_channel_rec.cc @@ -297,18 +297,23 @@ static Answer doGet(ArgIterator begin, ArgIterator end) static Answer doGetParameter(ArgIterator begin, ArgIterator end) { - std::stringstream ret; + if (!g_yamlSettings) { + std::stringstream ret; - for (auto i = begin; i != end; ++i) { - if (::arg().parmIsset(*i)) { - const auto& parm = arg()[*i]; - ret << *i << '=' << parm << endl; - } - else { - ret << *i << " not known" << endl; + for (auto i = begin; i != end; ++i) { + if (::arg().parmIsset(*i)) { + const auto& parm = arg()[*i]; + ret << *i << '=' << parm << endl; + } + else { + ret << *i << " not known" << endl; + } } + return {0, ret.str()}; } - return {0, ret.str()}; + auto settings = g_yamlStruct.lock(); + auto yaml = settings->to_yaml_string(); + return {0, std::string(yaml)}; } /* Read an (open) fd from the control channel */