message: Check rec.name() in answers
diff: use std::{
  + collections::HashSet,
  io,
  net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr},
  sync::Arc,
  @@ -102,15 +103,23 @@ fn should_forward_by_response(
  query: &Query,
  ) -> bool {
  if let Some(acl) = acl {
  + if let Ok(ref local_response) = local_response {
  + let mut names = HashSet::new();
  + names.insert(query.name());
  macro_rules! examine_record {
  ($rec:ident, $is_answer:expr) => {
  if let RData::CNAME(ref name) = $rec.rdata() {
  - match check_name_in_proxy_list(acl, name) {
  - Some(value) => return value,
  - None => continue,
  + if $is_answer {
  + if let Some(value) = check_name_in_proxy_list(acl, name) {
  + return value;
  + }
  + }
  + names.insert(name);
  + continue;
  }
  - } else if $is_answer && !query.query_type().is_any() && $rec.record_type() != query.query_type() {
  - warn!("local DNS response has inconsistent answer type {} for query {}", $rec.record_type(), query);
  + if $is_answer && !query.query_type().is_any() && $rec.record_type() != query.query_type() {
  + warn!("local DNS response has inconsistent answer type {} for query {}",
  + $rec.record_type(), query);
  return true;
  }
  let forward = match $rec.rdata() {
  @@ -124,12 +133,15 @@ fn should_forward_by_response(
  }
  };
  }
  - if let Ok(ref local_response) = local_response {
  for rec in local_response.answers() {
  + if !names.contains(rec.name()) {
  + warn!("local DNS response contains unexpected name {} for query {}", rec.name(), query);
  + return true;
  + }
  examine_record!(rec, true);
  }
  for rec in local_response.additionals() {
  - if rec.name() == query.name() {
  + if names.contains(rec.name()) {
  examine_record!(rec, false);
  }
  }
  