use hickory_client::client::ClientHandle; use hickory_proto::xfer::{DnsHandle, DnsRequest}; #[cfg(feature = "dnssec")] use hickory_proto::{op::Edns, rr::rdata::opt::EdnsOption}; #[cfg(feature = "dnssec")] use hickory_server::authority::LookupOptions; #[derive(Clone)] pub struct MutMessageHandle { client: C, #[cfg(feature = "dnssec")] pub lookup_options: LookupOptions, } impl MutMessageHandle { #[allow(dead_code)] pub fn new(client: C) -> Self { MutMessageHandle { client, #[cfg(feature = "dnssec")] lookup_options: Default::default(), } } } impl DnsHandle for MutMessageHandle { type Response = ::Response; fn is_verifying_dnssec(&self) -> bool { true } #[allow(unused_mut)] fn send + Unpin>(&self, request: R) -> Self::Response { let mut request = request.into(); #[cfg(feature = "dnssec")] { // mutable block let edns = request.extensions_mut().get_or_insert_with(Edns::new); edns.set_dnssec_ok(true); edns.options_mut() .insert(EdnsOption::DAU(self.lookup_options.supported_algorithms())); } println!("sending message"); self.client.send(request) } }