Skip to content

Commit

Permalink
minor: migrate from trust-dns to hickory, bump MSRV to 1.67 (#1156)
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelatkinson authored Jun 27, 2024
1 parent 08821ef commit a025f54
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 40 deletions.
14 changes: 0 additions & 14 deletions .evergreen/MSRV-Cargo.toml.diff
Original file line number Diff line number Diff line change
@@ -1,14 +0,0 @@
79c79
< derive_more = "0.99.17"
---
> derive_more = "=0.99.17"
100c100
< serde_with = "3.8.1"
---
> serde_with = "=3.5.1"
115a116
> url = "=2.5.0"
170c171
< time = "0.3.9"
---
> time = "=0.3.20"
2 changes: 1 addition & 1 deletion .evergreen/aws-lambda-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ To deploy the application, you need the folllowing tools:

* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html)
* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community)
* [Rust](https://www.rust-lang.org/) version 1.64.0 or newer
* [Rust](https://www.rust-lang.org/) version 1.67.0 or newer
* [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda) for cross-compilation

To build and deploy your application for the first time, run the following in your shell:
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ tasks:
- func: "compile only"
vars:
# Our minimum supported Rust version. This should be updated whenever the MSRV is bumped.
RUST_VERSION: 1.64.0
RUST_VERSION: 1.67.0

This comment has been minimized.

Copy link
@qm3ster

qm3ster Jun 27, 2024

please change this in clippy.toml as well


- name: check-cargo-deny
tags: [lint]
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ compat-3-0-0 = []
sync = []
rustls-tls = ["dep:rustls", "dep:rustls-pemfile", "dep:tokio-rustls"]
openssl-tls = ["dep:openssl", "dep:openssl-probe", "dep:tokio-openssl"]
dns-resolver = ["dep:trust-dns-resolver", "dep:trust-dns-proto"]
dns-resolver = ["dep:hickory-resolver", "dep:hickory-proto"]

# Enable support for MONGODB-AWS authentication.
# This can only be used with the tokio-runtime feature flag.
Expand Down Expand Up @@ -83,6 +83,8 @@ futures-core = "0.3.14"
futures-util = { version = "0.3.14", features = ["io"] }
futures-executor = "0.3.14"
hex = "0.4.0"
hickory-proto = { version = "0.24.1", optional = true }
hickory-resolver = { version = "0.24.1", optional = true }
hmac = "0.12.1"
once_cell = "1.19.0"
log = { version = "0.4.17", optional = true }
Expand All @@ -108,8 +110,6 @@ take_mut = "0.2.2"
thiserror = "1.0.24"
tokio-openssl = { version = "0.6.3", optional = true }
tracing = { version = "0.1.36", optional = true }
trust-dns-proto = { version = "0.21.2", optional = true }
trust-dns-resolver = { version = "0.21.2", optional = true }
typed-builder = "0.10.0"
webpki-roots = "0.25.2"
zstd = { version = "0.11.2", optional = true }
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ For more details, including features, runnable examples, troubleshooting resourc

## Installation
### Requirements
- Rust 1.64+ (See the [MSRV policy](#minimum-supported-rust-version-msrv-policy) for more information)
- Rust 1.67+ (See the [MSRV policy](#minimum-supported-rust-version-msrv-policy) for more information)
- MongoDB 4.0+

#### Supported Platforms
Expand Down Expand Up @@ -148,7 +148,7 @@ Commits to main are run automatically on [evergreen](https://evergreen.mongodb.c

## Minimum supported Rust version (MSRV) policy

The MSRV for this crate is currently 1.64.0. This will rarely be increased, and if it ever is,
The MSRV for this crate is currently 1.67.0. This will rarely be increased, and if it ever is,
it will only happen in a minor or major version release.

## License
Expand Down
2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
msrv = "1.64.0"
msrv = "1.67.0"
6 changes: 3 additions & 3 deletions src/client/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,11 +569,11 @@ pub struct ClientOptions {
#[derivative(Debug = "ignore")]
pub(crate) original_uri: Option<String>,

/// Configuration of the trust-dns resolver used for SRV and TXT lookups.
/// Configuration of the DNS resolver used for SRV and TXT lookups.
/// By default, the host system's resolver configuration will be used.
///
/// On Windows, there is a known performance issue in trust-dns with using the default system
/// configuration, so a custom configuration is recommended.
/// On Windows, there is a known performance issue in [hickory_resolver] with using the default
/// system configuration, so a custom configuration is recommended.
#[builder(setter(skip))]
#[serde(skip)]
#[derivative(Debug = "ignore")]
Expand Down
12 changes: 6 additions & 6 deletions src/client/options/resolver_config.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#[cfg(feature = "dns-resolver")]
use trust_dns_resolver::config::ResolverConfig as TrustDnsResolverConfig;
use hickory_resolver::config::ResolverConfig as HickoryResolverConfig;

/// Configuration for the upstream nameservers to use for resolution.
///
/// This is a thin wrapper around a `trust_dns_resolver::config::ResolverConfig` provided to ensure
/// This is a thin wrapper around a `hickory_resolver::config::ResolverConfig` provided to ensure
/// API stability.
#[derive(Clone, Debug, PartialEq)]
pub struct ResolverConfig {
#[cfg(feature = "dns-resolver")]
pub(crate) inner: TrustDnsResolverConfig,
pub(crate) inner: HickoryResolverConfig,
}

#[cfg(feature = "dns-resolver")]
Expand All @@ -19,7 +19,7 @@ impl ResolverConfig {
/// Please see: <https://www.cloudflare.com/dns/>
pub fn cloudflare() -> Self {
ResolverConfig {
inner: TrustDnsResolverConfig::cloudflare(),
inner: HickoryResolverConfig::cloudflare(),
}
}

Expand All @@ -30,7 +30,7 @@ impl ResolverConfig {
/// ISP’s track similar information in DNS.
pub fn google() -> Self {
ResolverConfig {
inner: TrustDnsResolverConfig::google(),
inner: HickoryResolverConfig::google(),
}
}

Expand All @@ -40,7 +40,7 @@ impl ResolverConfig {
/// Please see: <https://www.quad9.net/faq/>
pub fn quad9() -> Self {
ResolverConfig {
inner: TrustDnsResolverConfig::quad9(),
inner: HickoryResolverConfig::quad9(),
}
}
}
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ impl Error {
}

#[cfg(feature = "dns-resolver")]
pub(crate) fn from_resolve_error(error: trust_dns_resolver::error::ResolveError) -> Self {
pub(crate) fn from_resolve_error(error: hickory_resolver::error::ResolveError) -> Self {
ErrorKind::DnsResolve {
message: error.to_string(),
}
Expand Down
11 changes: 4 additions & 7 deletions src/runtime/resolver.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use trust_dns_resolver::{
use hickory_resolver::{
config::ResolverConfig,
error::ResolveErrorKind,
lookup::{SrvLookup, TxtLookup},
Expand All @@ -9,17 +9,14 @@ use crate::error::{Error, Result};

/// An async runtime agnostic DNS resolver.
pub(crate) struct AsyncResolver {
resolver: trust_dns_resolver::TokioAsyncResolver,
resolver: hickory_resolver::TokioAsyncResolver,
}

impl AsyncResolver {
pub(crate) async fn new(config: Option<ResolverConfig>) -> Result<Self> {
let resolver = match config {
Some(config) => {
trust_dns_resolver::TokioAsyncResolver::tokio(config, Default::default())
.map_err(Error::from_resolve_error)?
}
None => trust_dns_resolver::TokioAsyncResolver::tokio_from_system_conf()
Some(config) => hickory_resolver::TokioAsyncResolver::tokio(config, Default::default()),
None => hickory_resolver::TokioAsyncResolver::tokio_from_system_conf()
.map_err(Error::from_resolve_error)?,
};

Expand Down
2 changes: 1 addition & 1 deletion src/srv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl SrvResolver {
original_hostname: &str,
dm: DomainMismatch,
) -> Result<LookupHosts> {
use trust_dns_proto::rr::RData;
use hickory_proto::rr::RData;

let hostname_parts: Vec<_> = original_hostname.split('.').collect();

Expand Down

0 comments on commit a025f54

Please sign in to comment.