mirror of
https://github.com/ZeusWPI/ZNS.git
synced 2024-11-22 05:41:11 +01:00
Fix: NXDOMAIN only when domain does not exist
This commit is contained in:
parent
9c3d152618
commit
a4bf483a82
1 changed files with 37 additions and 32 deletions
|
@ -35,20 +35,31 @@ impl ResponseHandler for QueryHandler {
|
|||
match answers {
|
||||
Ok(mut rrs) => {
|
||||
if rrs.is_empty() {
|
||||
let domain_records = get_from_database(
|
||||
&question.qname,
|
||||
None,
|
||||
question.qclass.clone(),
|
||||
connection,
|
||||
)?;
|
||||
|
||||
if domain_records.is_empty() && !question.qname.is_empty() {
|
||||
rrs.extend(try_wildcard(question, connection)?);
|
||||
if rrs.is_empty() {
|
||||
if question.qtype == Type::Type(RRType::SOA)
|
||||
}
|
||||
|
||||
if rrs.is_empty()
|
||||
&& question.qtype == Type::Type(RRType::SOA)
|
||||
&& Config::get().default_soa
|
||||
{
|
||||
rrs.extend([get_soa(&question.qname)?])
|
||||
} else {
|
||||
}
|
||||
|
||||
if rrs.is_empty() && domain_records.is_empty() {
|
||||
return Err(ZNSError::NXDomain {
|
||||
domain: question.qname.to_string(),
|
||||
qtype: question.qtype.clone(),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
response.header.ancount += rrs.len() as u16;
|
||||
response.answer.extend(rrs)
|
||||
}
|
||||
|
@ -65,11 +76,6 @@ impl ResponseHandler for QueryHandler {
|
|||
}
|
||||
|
||||
fn try_wildcard(question: &Question, connection: &mut PgConnection) -> Result<Vec<RR>, ZNSError> {
|
||||
let records = get_from_database(&question.qname, None, question.qclass.clone(), connection)?;
|
||||
|
||||
if !records.is_empty() || question.qname.as_slice().is_empty() {
|
||||
Ok(vec![])
|
||||
} else {
|
||||
let qname = question.qname.clone().to_vec();
|
||||
qname.to_vec()[0] = String::from("*");
|
||||
Ok(get_from_database(
|
||||
|
@ -85,7 +91,6 @@ fn try_wildcard(question: &Question, connection: &mut PgConnection) -> Result<Ve
|
|||
})
|
||||
.collect())
|
||||
}
|
||||
}
|
||||
|
||||
fn get_soa(name: &LabelString) -> Result<RR, ZNSError> {
|
||||
let auth_zone = Config::get().authoritative_zone.clone();
|
||||
|
|
Loading…
Reference in a new issue