Skip to content

Commit 676c044

Browse files
authored
Merge pull request #689 from swimos/trust
Adds Hickory DNS support back into the server
2 parents d9700ca + c9b4c07 commit 676c044

File tree

7 files changed

+30
-27
lines changed

7 files changed

+30
-27
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ webpki = "0.22"
142142
webpki-roots = "0.26.3"
143143
tokio-rustls = "0.26"
144144
rustls-pemfile = "2.1.2"
145-
trust-dns-resolver = "0.23.2"
145+
hickory-resolver = "0.24.1"
146146
clap = "4.1"
147147
crossbeam-queue = { version = "0.3" }
148148
crossbeam-channel = { version = "0.5" }

runtime/swimos_remote/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ default = []
1313
tls = ["rustls", "webpki", "webpki-roots", "tokio-rustls", "rustls-pemfile"]
1414
ring_provider = []
1515
aws_lc_rs_provider = []
16+
hickory_dns = ["hickory-resolver"]
1617

1718
[dependencies]
1819
ratchet = { workspace = true, features = ["deflate", "split"] }
@@ -37,6 +38,7 @@ smallvec = { workspace = true }
3738
url = { workspace = true }
3839
pin-project = { workspace = true }
3940
hyper = { workspace = true }
41+
hickory-resolver = { workspace = true, optional = true }
4042

4143
rustls = { workspace = true, optional = true }
4244
webpki = { workspace = true, optional = true }

runtime/swimos_remote/src/dns.rs

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -75,25 +75,25 @@ impl DnsResolver for GetAddressInfoResolver {
7575
}
7676
}
7777

78-
/// The default DNS resolver. If the `trust-dns` feature flag is enabled, this will use the `trust_dns`
78+
/// The default DNS resolver. If the `hickory_dns` feature flag is enabled, this will use the `hickory_dns`
7979
/// implementation, otherwise it will use the operating system's built-in DNS support.
8080
#[derive(Debug, Clone)]
8181
pub struct Resolver {
82-
#[cfg(not(feature = "trust-dns"))]
82+
#[cfg(not(feature = "hickory_dns"))]
8383
inner: GetAddressInfoResolver,
84-
#[cfg(feature = "trust-dns")]
85-
inner: trust_dns_impl::TrustDnsResolver,
84+
#[cfg(feature = "hickory_dns")]
85+
inner: hickory_dns_impl::HickoryDnsResolver,
8686
}
8787

8888
impl Resolver {
89-
#[cfg(feature = "trust-dns")]
89+
#[cfg(feature = "hickory_dns")]
9090
pub async fn new() -> Resolver {
9191
Resolver {
92-
inner: trust_dns_impl::TrustDnsResolver::new().await,
92+
inner: hickory_dns_impl::HickoryDnsResolver::new().await,
9393
}
9494
}
9595

96-
#[cfg(not(feature = "trust-dns"))]
96+
#[cfg(not(feature = "hickory_dns"))]
9797
pub async fn new() -> Resolver {
9898
Resolver {
9999
inner: GetAddressInfoResolver,
@@ -109,31 +109,32 @@ impl DnsResolver for Resolver {
109109
}
110110
}
111111

112-
#[cfg(feature = "trust-dns")]
113-
mod trust_dns_impl {
114-
use crate::net::dns::DnsResolver;
112+
#[cfg(feature = "hickory_dns")]
113+
mod hickory_dns_impl {
114+
use crate::dns::DnsResolver;
115115
use futures::future::BoxFuture;
116+
use hickory_resolver::{system_conf, TokioAsyncResolver};
116117
use std::io;
117118
use std::net::{SocketAddr, ToSocketAddrs};
118-
use trust_dns_resolver::{system_conf, TokioAsyncResolver};
119119

120-
/// A DNS resolver built using the Trust-DNS Proto library.
120+
/// A DNS resolver built using the Hickory-DNS Proto library.
121121
#[derive(Clone, Debug)]
122-
pub struct TrustDnsResolver {
122+
pub struct HickoryDnsResolver {
123123
inner: TokioAsyncResolver,
124124
}
125125

126-
impl TrustDnsResolver {
127-
pub async fn new() -> TrustDnsResolver {
128-
let (config, opts) = system_conf::read_system_conf()
129-
.expect("Failed to retrieve host system configuration file for Trust DNS resolver");
130-
let resolver = TokioAsyncResolver::tokio(config, opts).unwrap();
131-
132-
TrustDnsResolver { inner: resolver }
126+
impl HickoryDnsResolver {
127+
pub async fn new() -> HickoryDnsResolver {
128+
let (config, opts) = system_conf::read_system_conf().expect(
129+
"Failed to retrieve host system configuration file for Hickory DNS resolver",
130+
);
131+
HickoryDnsResolver {
132+
inner: TokioAsyncResolver::tokio(config, opts),
133+
}
133134
}
134135
}
135136

136-
impl DnsResolver for TrustDnsResolver {
137+
impl DnsResolver for HickoryDnsResolver {
137138
type ResolveFuture = BoxFuture<'static, io::Result<Vec<SocketAddr>>>;
138139

139140
fn resolve(&self, host: String, port: u16) -> Self::ResolveFuture {

runtime/swimos_runtime/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ homepage.workspace = true
1010

1111
[features]
1212
default = []
13-
trust_dns = ["trust-dns-resolver"]
13+
hickory_dns = ["swimos_remote/hickory_dns"]
1414

1515
[dependencies]
1616
bitflags = { workspace = true }
@@ -36,7 +36,6 @@ thiserror = { workspace = true }
3636
tokio-stream = { workspace = true, features = ["sync"] }
3737
uuid = { workspace = true }
3838
static_assertions = { workspace = true }
39-
trust-dns-resolver = { workspace = true, optional = true }
4039
nom = { workspace = true }
4140
percent-encoding = { workspace = true }
4241

server/swimos_server_app/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ homepage.workspace = true
1111
[features]
1212
default = ["aws_lc_rs_provider", "signal"]
1313
rocks_store = ["swimos_rocks_store"]
14-
trust_dns = ["swimos_runtime/trust_dns"]
14+
hickory_dns = ["swimos_runtime/hickory_dns"]
1515
signal = ["tokio/signal"]
1616
ring_provider = ["swimos_remote/ring_provider"]
1717
aws_lc_rs_provider = ["swimos_remote/aws_lc_rs_provider"]

swimos/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ homepage.workspace = true
1010

1111
[features]
1212
default = ["aws_lc_rs_provider"]
13-
all = ["server", "agent", "json"]
13+
all = ["server", "agent", "json", "hickory_dns"]
1414
server = ["dep:swimos_server_app", "dep:swimos_remote"]
1515
agent = ["dep:swimos_agent", "dep:swimos_agent_derive"]
1616
json = ["agent", "swimos_agent/json"]
1717
ring_provider = ["swimos_server_app/ring_provider"]
1818
aws_lc_rs_provider = ["swimos_server_app/aws_lc_rs_provider"]
19+
hickory_dns = ["swimos_server_app/hickory_dns"]
1920

2021
[dependencies]
2122
swimos_utilities = { workspace = true, features = ["io", "text"] }

swimos_client/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ homepage.workspace = true
1010
[features]
1111
default = ["aws_lc_rs_provider"]
1212
deflate = ["ratchet/deflate"]
13-
trust_dns = ["swimos_runtime/trust_dns"]
13+
hickory_dns = ["swimos_runtime/hickory_dns"]
1414
ring_provider = ["swimos_remote/ring_provider"]
1515
aws_lc_rs_provider = ["swimos_remote/aws_lc_rs_provider"]
1616

0 commit comments

Comments
 (0)