Skip to content

Commit

Permalink
Merge pull request #42 from angelybo/return_all_on_query
Browse files Browse the repository at this point in the history
On querytype:All - return all records instead of just hostname record
  • Loading branch information
willstott101 authored Feb 10, 2023
2 parents b80c575 + 701951e commit 2ade588
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/fsm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,27 @@ impl<AF: AddressFamily> FSM<AF> {
let services = self.services.read().unwrap();

match question.qtype {
QueryType::A | QueryType::AAAA | QueryType::All
QueryType::A | QueryType::AAAA
if question.qname == *services.get_hostname() =>
{
builder = self.add_ip_rr(services.get_hostname(), builder, DEFAULT_TTL);
},
QueryType::All => {
// A / AAAA
builder = self.add_ip_rr(services.get_hostname(), builder, DEFAULT_TTL);
// PTR
builder = Self::handle_service_type_enumeration(question, services.into_iter(), builder);
for svc in services.find_by_type(&question.qname) {
builder = svc.add_ptr_rr(builder, DEFAULT_TTL);
builder = svc.add_srv_rr(services.get_hostname(), builder, DEFAULT_TTL);
builder = svc.add_txt_rr(builder, DEFAULT_TTL);
builder = self.add_ip_rr(services.get_hostname(), builder, DEFAULT_TTL);
}
// SRV
if let Some(svc) = services.find_by_name(&question.qname) {
builder = svc.add_srv_rr(services.get_hostname(), builder, DEFAULT_TTL);
builder = self.add_ip_rr(services.get_hostname(), builder, DEFAULT_TTL);
}
}
QueryType::PTR => {
builder =
Expand Down

0 comments on commit 2ade588

Please sign in to comment.