10
0
Fork 0
mirror of https://github.com/ZeusWPI/ZNS.git synced 2024-10-29 21:14:27 +01:00

put invalid question name in error

This commit is contained in:
Xander Bil 2024-08-23 22:33:46 +02:00
parent 4261d06248
commit 60ea5f109e
No known key found for this signature in database
GPG key ID: EC9706B54A278598

View file

@ -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 {
if !(zlen >= auth_zone.len()
&& vec_equal(&question.qname[zlen - auth_zone.len()..], auth_zone))
{
return Err(ZNSError::Refused {
message: "Not authoritative".to_string(),
message: format!("Not authoritative for: {}", question.qname.join(".")),
});
}
}
Ok(())
}
}