From 701951eb4b9c70fa4d269ee50237ef5cb8625be6 Mon Sep 17 00:00:00 2001 From: Angel Yankov Date: Mon, 6 Feb 2023 15:04:50 +0200 Subject: [PATCH] On querytype:All - return all records instead of just hostname record --- src/fsm.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/fsm.rs b/src/fsm.rs index 9ee6661..8cb739a 100644 --- a/src/fsm.rs +++ b/src/fsm.rs @@ -168,10 +168,27 @@ impl FSM { 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 =