From d68ad0971e59839d9b5ab68f8ac044d753e118da Mon Sep 17 00:00:00 2001 From: Peter Cai Date: Mon, 5 Apr 2021 16:24:35 +0800 Subject: [PATCH] don't care about question type when overriding records * Even if the client wants A records, respond with AAAA anyway and vice-versa. Otherwise, our resolving client will fall back to upstream. --- src/override.rs | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/override.rs b/src/override.rs index eda3be9..8c5d506 100644 --- a/src/override.rs +++ b/src/override.rs @@ -79,22 +79,16 @@ impl OverrideResolver { IpAddr::V6(addr) => (Rtype::Aaaa, AllRecordData::Aaaa(Aaaa::new(addr.clone()))), }; - let qtype = question.qtype(); - if qtype == Rtype::Any || qtype == rtype { - // Convert AllRecordData to UnknownRecordData to match the type - // since our resolver client doesn't really care about the actual type - let mut rdata_buf: Vec = Vec::new(); - rdata.compose(&mut rdata_buf).ok()?; - let record = Record::new( - question.qname().clone(), - question.qclass(), - self.override_ttl, - UnknownRecordData::from_octets(rtype, rdata_buf), - ); - return Some(record); - } else { - // If the response and query types don't match, just return none - return None; - } + // Convert AllRecordData to UnknownRecordData to match the type + // since our resolver client doesn't really care about the actual type + let mut rdata_buf: Vec = Vec::new(); + rdata.compose(&mut rdata_buf).ok()?; + let record = Record::new( + question.qname().clone(), + question.qclass(), + self.override_ttl, + UnknownRecordData::from_octets(rtype, rdata_buf), + ); + return Some(record); } }