From: Remi Gacogne Date: Fri, 29 May 2026 08:00:09 +0000 (+0200) Subject: dnsdist: Properly deal with exceptions when registering objects from YAML X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bb6bddbde2f4875ac356d059be49eb1990e36812;p=thirdparty%2Fpdns.git dnsdist: Properly deal with exceptions when registering objects from YAML Signed-off-by: Remi Gacogne --- diff --git a/pdns/dnsdistdist/dnsdist-rust-lib/rust-middle-in.rs b/pdns/dnsdistdist/dnsdist-rust-lib/rust-middle-in.rs index 0ea5e5de2d..95d0cd6e7f 100644 --- a/pdns/dnsdistdist/dnsdist-rust-lib/rust-middle-in.rs +++ b/pdns/dnsdistdist/dnsdist-rust-lib/rust-middle-in.rs @@ -12,13 +12,13 @@ type DNSSelector; type DNSActionWrapper; type DNSResponseActionWrapper; - fn registerProtobufLogger(config: &ProtobufLoggerConfiguration); - fn registerDnstapLogger(config: &DnstapLoggerConfiguration); - fn registerOtlpLogger(config: &OtlpLoggerConfiguration); - fn registerKVSObjects(config: &KeyValueStoresConfiguration); - fn registerMMDBObjects(config: &Vec); - fn registerNMGObjects(nmgs: &Vec); - fn registerTimedIPSetObjects(sets: &Vec); + fn registerProtobufLogger(config: &ProtobufLoggerConfiguration) -> Result<()>; + fn registerDnstapLogger(config: &DnstapLoggerConfiguration) -> Result<()>; + fn registerOtlpLogger(config: &OtlpLoggerConfiguration) -> Result<()>; + fn registerKVSObjects(config: &KeyValueStoresConfiguration) -> Result<()>; + fn registerMMDBObjects(config: &Vec) -> Result<()>; + fn registerNMGObjects(nmgs: &Vec) -> Result<()>; + fn registerTimedIPSetObjects(sets: &Vec) -> Result<()>; } } diff --git a/pdns/dnsdistdist/dnsdist-rust-lib/rust-post-in.rs b/pdns/dnsdistdist/dnsdist-rust-lib/rust-post-in.rs index dbbc1a88bd..e777d4bbe7 100644 --- a/pdns/dnsdistdist/dnsdist-rust-lib/rust-post-in.rs +++ b/pdns/dnsdistdist/dnsdist-rust-lib/rust-post-in.rs @@ -47,16 +47,17 @@ fn get_response_rules_from_serde( fn register_remote_loggers( config: &dnsdistsettings::RemoteLoggingConfiguration, -) { +) -> Result<(), cxx::Exception> { for logger in &config.protobuf_loggers { - dnsdistsettings::registerProtobufLogger(logger); + dnsdistsettings::registerProtobufLogger(logger)?; } for logger in &config.dnstap_loggers { - dnsdistsettings::registerDnstapLogger(logger); + dnsdistsettings::registerDnstapLogger(logger)?; } for logger in &config.otlp_loggers { - dnsdistsettings::registerOtlpLogger(logger); + dnsdistsettings::registerOtlpLogger(logger)?; } + Ok(()) } fn get_global_configuration_from_serde( @@ -94,15 +95,15 @@ fn get_global_configuration_from_serde( ..Default::default() }; // this needs to be done before the rules so that they can refer to the loggers - register_remote_loggers(&config.remote_logging); + register_remote_loggers(&config.remote_logging)?; // this needs to be done before the KVS so they can refer to the DBs - dnsdistsettings::registerMMDBObjects(&config.mmdbs); + dnsdistsettings::registerMMDBObjects(&config.mmdbs)?; // this needs to be done before the rules so that they can refer to the KVS objects - dnsdistsettings::registerKVSObjects(&config.key_value_stores); + dnsdistsettings::registerKVSObjects(&config.key_value_stores)?; // this needs to be done before the rules so that they can refer to the NMG objects - dnsdistsettings::registerNMGObjects(&config.netmask_groups); + dnsdistsettings::registerNMGObjects(&config.netmask_groups)?; // this needs to be done before the rules so that they can refer to the TimeIPSet objects - dnsdistsettings::registerTimedIPSetObjects(&config.timed_ip_sets); + dnsdistsettings::registerTimedIPSetObjects(&config.timed_ip_sets)?; // this needs to be done BEFORE the rules so that they can refer to the selectors // by name config.selectors = get_selectors_from_serde(&serde.selectors)?;