Repository: swimos/swim-rust (language: rust)

Issue:
Trust DNS resolver no longer configured
The Trust DNS resolver is no longer setup correctly using cargo features as the argument is not passed to the swimos_remote crate.


Discussion / hints:

Fix patch:
diff --git a/Cargo.toml b/Cargo.toml
index 2f6a86d2c..11ec76b40 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -142,7 +142,7 @@ webpki = "0.22"
 webpki-roots = "0.26.3"
 tokio-rustls = "0.26"
 rustls-pemfile = "2.1.2"
-trust-dns-resolver = "0.23.2"
+hickory-resolver = "0.24.1"
 clap = "4.1"
 crossbeam-queue = { version = "0.3" }
 crossbeam-channel = { version = "0.5" }
diff --git a/runtime/swimos_remote/Cargo.toml b/runtime/swimos_remote/Cargo.toml
index fae7115aa..062fbe148 100644
--- a/runtime/swimos_remote/Cargo.toml
+++ b/runtime/swimos_remote/Cargo.toml
@@ -13,6 +13,7 @@ default = []
 tls = ["rustls", "webpki", "webpki-roots", "tokio-rustls", "rustls-pemfile"]
 ring_provider = []
 aws_lc_rs_provider = []
+hickory_dns = ["hickory-resolver"]
 
 [dependencies]
 ratchet = { workspace = true, features = ["deflate", "split"] }
@@ -37,6 +38,7 @@ smallvec = { workspace = true }
 url = { workspace = true }
 pin-project = { workspace = true }
 hyper = { workspace = true }
+hickory-resolver = { workspace = true, optional = true }
 
 rustls = { workspace = true, optional = true }
 webpki = { workspace = true, optional = true }
diff --git a/runtime/swimos_remote/src/dns.rs b/runtime/swimos_remote/src/dns.rs
index a8c1a3d50..d4c32675c 100644
--- a/runtime/swimos_remote/src/dns.rs
+++ b/runtime/swimos_remote/src/dns.rs
@@ -75,25 +75,25 @@ impl DnsResolver for GetAddressInfoResolver {
     }
 }
 
-/// The default DNS resolver. If the `trust-dns` feature flag is enabled, this will use the `trust_dns`
+/// The default DNS resolver. If the `hickory_dns` feature flag is enabled, this will use the `hickory_dns`
 /// implementation, otherwise it will use the operating system's built-in DNS support.
 #[derive(Debug, Clone)]
 pub struct Resolver {
-    #[cfg(not(feature = "trust-dns"))]
+    #[cfg(not(feature = "hickory_dns"))]
     inner: GetAddressInfoResolver,
-    #[cfg(feature = "trust-dns")]
-    inner: trust_dns_impl::TrustDnsResolver,
+    #[cfg(feature = "hickory_dns")]
+    inner: hickory_dns_impl::HickoryDnsResolver,
 }
 
 impl Resolver {
-    #[cfg(feature = "trust-dns")]
+    #[cfg(feature = "hickory_dns")]
     pub async fn new() -> Resolver {
         Resolver {
-            inner: trust_dns_impl::TrustDnsResolver::new().await,
+            inner: hickory_dns_impl::HickoryDnsResolver::new().await,
         }
     }
 
-    #[cfg(not(feature = "trust-dns"))]
+    #[cfg(not(feature = "hickory_dns"))]
     pub async fn new() -> Resolver {
         Resolver {
             inner: GetAddressInfoResolver,
@@ -109,31 +109,32 @@ impl DnsResolver for Resolver {
     }
 }
 
-#[cfg(feature = "trust-dns")]
-mod trust_dns_impl {
-    use crate::net::dns::DnsResolver;
+#[cfg(feature = "hickory_dns")]
+mod hickory_dns_impl {
+    use crate::dns::DnsResolver;
     use futures::future::BoxFuture;
+    use hickory_resolver::{system_conf, TokioAsyncResolver};
     use std::io;
     use std::net::{SocketAddr, ToSocketAddrs};
-    use trust_dns_resolver::{system_conf, TokioAsyncResolver};
 
-    /// A DNS resolver built using the Trust-DNS Proto library.
+    /// A DNS resolver built using the Hickory-DNS Proto library.
     #[derive(Clone, Debug)]
-    pub struct TrustDnsResolver {
+    pub struct HickoryDnsResolver {
         inner: TokioAsyncResolver,
     }
 
-    impl TrustDnsResolver {
-        pub async fn new() -> TrustDnsResolver {
-            let (config, opts) = system_conf::read_system_conf()
-                .expect("Failed to retrieve host system configuration file for Trust DNS resolver");
-            let resolver = TokioAsyncResolver::tokio(config, opts).unwrap();
-
-            TrustDnsResolver { inner: resolver }
+    impl HickoryDnsResolver {
+        pub async fn new() -> HickoryDnsResolver {
+            let (config, opts) = system_conf::read_system_conf().expect(
+                "Failed to retrieve host system configuration file for Hickory DNS resolver",
+            );
+            HickoryDnsResolver {
+                inner: TokioAsyncResolver::tokio(config, opts),
+            }
         }
     }
 
-    impl DnsResolver for TrustDnsResolver {
+    impl DnsResolver for HickoryDnsResolver {
         type ResolveFuture = BoxFuture<'static, io::Result<Vec<SocketAddr>>>;
 
         fn resolve(&self, host: String, port: u16) -> Self::ResolveFuture {
diff --git a/runtime/swimos_runtime/Cargo.toml b/runtime/swimos_runtime/Cargo.toml
index 08f8ffc8c..e925d6840 100644
--- a/runtime/swimos_runtime/Cargo.toml
+++ b/runtime/swimos_runtime/Cargo.toml
@@ -10,7 +10,7 @@ homepage.workspace = true
 
 [features]
 default = []
-trust_dns = ["trust-dns-resolver"]
+hickory_dns = ["swimos_remote/hickory_dns"]
 
 [dependencies]
 bitflags = { workspace = true }
@@ -36,7 +36,6 @@ thiserror = { workspace = true }
 tokio-stream = { workspace = true, features = ["sync"] }
 uuid = { workspace = true }
 static_assertions = { workspace = true }
-trust-dns-resolver = { workspace = true, optional = true }
 nom = { workspace = true }
 percent-encoding = { workspace = true }
 
diff --git a/server/swimos_server_app/Cargo.toml b/server/swimos_server_app/Cargo.toml
index 186a46421..51aabd2fc 100644
--- a/server/swimos_server_app/Cargo.toml
+++ b/server/swimos_server_app/Cargo.toml
@@ -11,7 +11,7 @@ homepage.workspace = true
 [features]
 default = ["aws_lc_rs_provider", "signal"]
 rocks_store = ["swimos_rocks_store"]
-trust_dns = ["swimos_runtime/trust_dns"]
+hickory_dns = ["swimos_runtime/hickory_dns"]
 signal = ["tokio/signal"]
 ring_provider = ["swimos_remote/ring_provider"]
 aws_lc_rs_provider = ["swimos_remote/aws_lc_rs_provider"]
diff --git a/swimos/Cargo.toml b/swimos/Cargo.toml
index 1e35de2dc..bcb98baa5 100644
--- a/swimos/Cargo.toml
+++ b/swimos/Cargo.toml
@@ -10,12 +10,13 @@ homepage.workspace = true
 
 [features]
 default = ["aws_lc_rs_provider"]
-all = ["server", "agent", "json"]
+all = ["server", "agent", "json", "hickory_dns"]
 server = ["dep:swimos_server_app", "dep:swimos_remote"]
 agent = ["dep:swimos_agent", "dep:swimos_agent_derive"]
 json = ["agent", "swimos_agent/json"]
 ring_provider = ["swimos_server_app/ring_provider"]
 aws_lc_rs_provider = ["swimos_server_app/aws_lc_rs_provider"]
+hickory_dns = ["swimos_server_app/hickory_dns"]
 
 [dependencies]
 swimos_utilities = { workspace = true, features = ["io", "text"] }
diff --git a/swimos_client/Cargo.toml b/swimos_client/Cargo.toml
index ceaa2f9d7..355e26f42 100644
--- a/swimos_client/Cargo.toml
+++ b/swimos_client/Cargo.toml
@@ -10,7 +10,7 @@ homepage.workspace = true
 [features]
 default = ["aws_lc_rs_provider"]
 deflate = ["ratchet/deflate"]
-trust_dns = ["swimos_runtime/trust_dns"]
+hickory_dns = ["swimos_runtime/hickory_dns"]
 ring_provider = ["swimos_remote/ring_provider"]
 aws_lc_rs_provider = ["swimos_remote/aws_lc_rs_provider"]
 


Test patch: