Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dep: Upgrade trust-dns-resolver from v0.22 to v0.23 #1965

Merged
merged 2 commits into from Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
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
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
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