From f1fd0a984ae44a115b6c531b312e00c6fa781863 Mon Sep 17 00:00:00 2001 From: Jonas Platte <158304798+svix-jplatte@users.noreply.github.com> Date: Mon, 11 Mar 2024 16:17:29 +0100 Subject: [PATCH] Upgrade trust-dns-resolver -> hickory-resolver (#1263) Trust DNS was renamed: https://bluejekyll.github.io/blog/posts/announcing-hickory-dns/ --- server/Cargo.lock | 110 ++++++++---------- server/svix-server/Cargo.toml | 2 +- .../src/core/webhook_http_client.rs | 14 +-- 3 files changed, 56 insertions(+), 70 deletions(-) diff --git a/server/Cargo.lock b/server/Cargo.lock index 873402ff0..8d014396d 100644 --- a/server/Cargo.lock +++ b/server/Cargo.lock @@ -1168,18 +1168,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "enum-as-inner" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9720bba047d567ffc8a3cba48bf19126600e249ab7f128e9233e6376976a116" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "enum-as-inner" version = "0.6.0" @@ -1684,6 +1672,51 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hickory-proto" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "091a6fbccf4860009355e3efc52ff4acf37a63489aad7435372d44ceeb6fbbcf" +dependencies = [ + "async-trait", + "cfg-if", + "data-encoding", + "enum-as-inner", + "futures-channel", + "futures-io", + "futures-util", + "idna 0.4.0", + "ipnet", + "once_cell", + "rand", + "thiserror", + "tinyvec", + "tokio", + "tracing", + "url", +] + +[[package]] +name = "hickory-resolver" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35b8f021164e6a984c9030023544c57789c51760065cd510572fedcfb04164e8" +dependencies = [ + "cfg-if", + "futures-util", + "hickory-proto", + "ipconfig", + "lru-cache", + "once_cell", + "parking_lot", + "rand", + "resolv-conf", + "smallvec", + "thiserror", + "tokio", + "tracing", +] + [[package]] name = "hkdf" version = "0.12.4" @@ -3290,7 +3323,7 @@ dependencies = [ "tokio-native-tls", "tokio-rustls", "tower-service", - "trust-dns-resolver 0.23.2", + "trust-dns-resolver", "url", "wasm-bindgen", "wasm-bindgen-futures", @@ -4320,6 +4353,7 @@ dependencies = [ "figment", "form_urlencoded", "futures", + "hickory-resolver", "hmac-sha256", "http", "hyper", @@ -4360,7 +4394,6 @@ dependencies = [ "tracing", "tracing-opentelemetry", "tracing-subscriber", - "trust-dns-resolver 0.22.0", "url", "urlencoding", "validator", @@ -4858,31 +4891,6 @@ dependencies = [ "tracing-serde", ] -[[package]] -name = "trust-dns-proto" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f7f83d1e4a0e4358ac54c5c3681e5d7da5efc5a7a632c90bb6d6669ddd9bc26" -dependencies = [ - "async-trait", - "cfg-if", - "data-encoding", - "enum-as-inner 0.5.1", - "futures-channel", - "futures-io", - "futures-util", - "idna 0.2.3", - "ipnet", - "lazy_static", - "rand", - "smallvec", - "thiserror", - "tinyvec", - "tokio", - "tracing", - "url", -] - [[package]] name = "trust-dns-proto" version = "0.23.2" @@ -4892,7 +4900,7 @@ dependencies = [ "async-trait", "cfg-if", "data-encoding", - "enum-as-inner 0.6.0", + "enum-as-inner", "futures-channel", "futures-io", "futures-util", @@ -4908,26 +4916,6 @@ dependencies = [ "url", ] -[[package]] -name = "trust-dns-resolver" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aff21aa4dcefb0a1afbfac26deb0adc93888c7d295fb63ab273ef276ba2b7cfe" -dependencies = [ - "cfg-if", - "futures-util", - "ipconfig", - "lazy_static", - "lru-cache", - "parking_lot", - "resolv-conf", - "smallvec", - "thiserror", - "tokio", - "tracing", - "trust-dns-proto 0.22.0", -] - [[package]] name = "trust-dns-resolver" version = "0.23.2" @@ -4946,7 +4934,7 @@ dependencies = [ "thiserror", "tokio", "tracing", - "trust-dns-proto 0.23.2", + "trust-dns-proto", ] [[package]] diff --git a/server/svix-server/Cargo.toml b/server/svix-server/Cargo.toml index 7c8db2855..fa8df3a0c 100644 --- a/server/svix-server/Cargo.toml +++ b/server/svix-server/Cargo.toml @@ -66,7 +66,7 @@ jsonschema = "0.17.1" aide = { version = "0.12.0", features = ["axum", "redoc", "macros", "axum-headers"] } schemars = { version = "0.8.11", features = ["chrono", "url", "preserve_order"] } indexmap = "1.9.2" -trust-dns-resolver = "0.22.0" +hickory-resolver = "0.24.0" ipnet = { version = "2.5", features = ["serde"] } urlencoding = "2.1.2" form_urlencoded = "1.1.0" diff --git a/server/svix-server/src/core/webhook_http_client.rs b/server/svix-server/src/core/webhook_http_client.rs index a8bb355e3..106ea1368 100644 --- a/server/svix-server/src/core/webhook_http_client.rs +++ b/server/svix-server/src/core/webhook_http_client.rs @@ -12,6 +12,9 @@ use std::{ use axum::headers::{authorization::Credentials, Authorization}; use bytes::Bytes; use futures::{future::BoxFuture, FutureExt}; +use hickory_resolver::{ + error::ResolveError, lookup_ip::LookupIpIntoIter, AsyncResolver, TokioAsyncResolver, +}; use http::header::HeaderName; use http::{HeaderMap, HeaderValue, Method, Response, StatusCode, Version}; use hyper::{ @@ -26,10 +29,6 @@ use serde::Serialize; use thiserror::Error; use tokio::sync::Mutex; use tower::Service; -use trust_dns_resolver::{ - error::ResolveError, lookup_ip::LookupIpIntoIter, AsyncResolver, TokioConnection, - TokioConnectionProvider, TokioHandle, -}; pub type CaseSensitiveHeaderMap = HashMap; @@ -461,7 +460,7 @@ struct NonLocalDnsResolver { #[derive(Clone, Debug)] enum DnsState { Init, - Ready(Arc>), + Ready(Arc), } impl NonLocalDnsResolver { @@ -556,9 +555,8 @@ impl Iterator for SocketAddrs { } } -async fn new_resolver( -) -> Result>, ResolveError> { - Ok(Arc::new(AsyncResolver::from_system_conf(TokioHandle)?)) +async fn new_resolver() -> Result, ResolveError> { + Ok(Arc::new(AsyncResolver::tokio_from_system_conf()?)) } fn is_allowed(addr: IpAddr) -> bool {