Skip to content

Commit

Permalink
Allow overriding the DNS resolver for the blocking client. (#2260)
Browse files Browse the repository at this point in the history
  • Loading branch information
mger1 committed Apr 25, 2024
1 parent d3b27ac commit 81c0399
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/blocking/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use tokio::sync::{mpsc, oneshot};
use super::request::{Request, RequestBuilder};
use super::response::Response;
use super::wait;
use crate::dns::Resolve;
#[cfg(feature = "__tls")]
use crate::tls;
#[cfg(feature = "__tls")]
Expand Down Expand Up @@ -920,6 +921,15 @@ impl ClientBuilder {
self.with_inner(|inner| inner.resolve_to_addrs(domain, addrs))
}

/// Override the DNS resolver implementation.
///
/// Pass an `Arc` wrapping a trait object implementing `Resolve`.
/// Overrides for specific names passed to `resolve` and `resolve_to_addrs` will
/// still be applied on top of this resolver.
pub fn dns_resolver<R: Resolve + 'static>(self, resolver: Arc<R>) -> ClientBuilder {
self.with_inner(|inner| inner.dns_resolver(resolver))
}

// private

fn with_inner<F>(mut self, func: F) -> ClientBuilder
Expand Down

0 comments on commit 81c0399

Please sign in to comment.