10
0
Fork 0
mirror of https://github.com/ZeusWPI/ZNS.git synced 2024-11-21 21:41:10 +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> { 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(); let zlen = question.qname.len();
zlen >= auth_zone.len() if !(zlen >= auth_zone.len()
&& vec_equal(&question.qname[zlen - auth_zone.len()..], auth_zone) && vec_equal(&question.qname[zlen - auth_zone.len()..], auth_zone))
}); {
return Err(ZNSError::Refused {
if !authoritative { message: format!("Not authoritative for: {}", question.qname.join(".")),
return Err(ZNSError::Refused { });
message: "Not authoritative".to_string(), }
});
} }
Ok(()) Ok(())
} }
} }