Skip to content

Commit

Permalink
dep: Upgrade trust-dns-resolver from v0.22 to v0.23 (#1965)
Browse files Browse the repository at this point in the history
  • Loading branch information
NobodyXu committed Sep 4, 2023
1 parent 70d100c commit 0292486
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ tokio-util = { version = "0.7.1", default-features = false, features = ["codec",
tokio-socks = { version = "0.5.1", optional = true }

## trust-dns
trust-dns-resolver = { version = "0.22", optional = true }
trust-dns-resolver = { version = "0.23", optional = true, features = ["tokio-runtime"] }

# HTTP/3 experimental support
h3 = { version="0.0.2", optional = true }
Expand Down
21 changes: 6 additions & 15 deletions src/dns/trust_dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,15 @@ use hyper::client::connect::dns::Name;
use once_cell::sync::Lazy;
use tokio::sync::Mutex;
pub use trust_dns_resolver::config::{ResolverConfig, ResolverOpts};
use trust_dns_resolver::{
lookup_ip::LookupIpIntoIter, system_conf, AsyncResolver, TokioConnection,
TokioConnectionProvider, TokioHandle,
};
use trust_dns_resolver::{lookup_ip::LookupIpIntoIter, system_conf, TokioAsyncResolver};

use std::io;
use std::net::SocketAddr;
use std::sync::Arc;

use super::{Addrs, Resolve, Resolving};

use crate::error::BoxError;

type SharedResolver = Arc<AsyncResolver<TokioConnection, TokioConnectionProvider>>;
type SharedResolver = Arc<TokioAsyncResolver>;

static SYSTEM_CONF: Lazy<io::Result<(ResolverConfig, ResolverOpts)>> =
Lazy::new(|| system_conf::read_system_conf().map_err(io::Error::from));
Expand Down Expand Up @@ -63,7 +58,7 @@ impl Resolve for TrustDnsResolver {

let resolver = match &*lock {
State::Init => {
let resolver = new_resolver().await?;
let resolver = new_resolver().await;
*lock = State::Ready(resolver.clone());
resolver
}
Expand Down Expand Up @@ -91,18 +86,14 @@ impl Iterator for SocketAddrs {
}
}

async fn new_resolver() -> Result<SharedResolver, BoxError> {
async fn new_resolver() -> SharedResolver {
let (config, opts) = SYSTEM_CONF
.as_ref()
.expect("can't construct TrustDnsResolver if SYSTEM_CONF is error")
.clone();
new_resolver_with_config(config, opts)
}

fn new_resolver_with_config(
config: ResolverConfig,
opts: ResolverOpts,
) -> Result<SharedResolver, BoxError> {
let resolver = AsyncResolver::new(config, opts, TokioHandle)?;
Ok(Arc::new(resolver))
fn new_resolver_with_config(config: ResolverConfig, opts: ResolverOpts) -> SharedResolver {
Arc::new(TokioAsyncResolver::tokio(config, opts))
}
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@
//! [`Identity`][Identity] type.
//! - Various parts of TLS can also be configured or even disabled on the
//! `ClientBuilder`.
//!
//!
//! ## WASM
//! The Client implementation automatically switches to the WASM one when the target_arch is wasm32,
//! the usage is basically the same as the async api. Some of the features are disabled in wasm
//! : [`tls`](tls) [`cookie`](cookie) [`blocking`](blocking).
//!
//!
//!
//! ## Optional Features
//!
Expand Down

0 comments on commit 0292486

Please sign in to comment.