From 60ea5f109e0704224126dd95a70ae6efe43280ec Mon Sep 17 00:00:00 2001 From: Xander Bil Date: Fri, 23 Aug 2024 22:33:46 +0200 Subject: [PATCH] put invalid question name in error --- zns/src/message.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/zns/src/message.rs b/zns/src/message.rs index c24ccd2..2e4265f 100644 --- a/zns/src/message.rs +++ b/zns/src/message.rs @@ -20,18 +20,16 @@ impl Message { } pub fn check_authoritative(&self, auth_zone: &LabelString) -> Result<(), ZNSError> { - let authoritative = self.question.iter().all(|question| { + for question in &self.question { let zlen = question.qname.len(); - zlen >= auth_zone.len() - && vec_equal(&question.qname[zlen - auth_zone.len()..], auth_zone) - }); - - if !authoritative { - return Err(ZNSError::Refused { - message: "Not authoritative".to_string(), - }); + if !(zlen >= auth_zone.len() + && vec_equal(&question.qname[zlen - auth_zone.len()..], auth_zone)) + { + return Err(ZNSError::Refused { + message: format!("Not authoritative for: {}", question.qname.join(".")), + }); + } } - Ok(()) } }