Skip to content

Commit c3f7d0c

Browse files
committedApr 18, 2021
Switch back to DoH
Remove test workaround now that IPv6 is preferred in trust-dns hostname resolution
1 parent 8227837 commit c3f7d0c

File tree

4 files changed

+8
-19
lines changed

4 files changed

+8
-19
lines changed
 

‎Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ serde = "1"
3535
thiserror = "1"
3636
tokio = { version = "1", features = ["rt-multi-thread"] }
3737
trust-dns-resolver = { version = "0.20", default-features = false, features = [
38-
"dns-over-rustls",
38+
"dns-over-https-rustls",
3939
"dnssec-ring",
4040
"tokio-runtime",
4141
], optional = true }

‎clippy.toml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
doc-valid-idents = ["DoH", "IPv4", "IPv6"]

‎src/quic/endpoint/builder/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,8 @@ impl Builder {
6767
#[cfg(not(feature = "test"))]
6868
address: ([0; 8], 0).into(),
6969
// while testing always use the default loopback address
70-
// equals to `[::ffff:127.0.0.1]:0`
7170
#[cfg(feature = "test")]
72-
address: ([0, 0, 0, 0, 0, 0xffff, 0x7f00, 1], 0).into(),
71+
address: ([0, 0, 0, 0, 0, 0, 0, 1], 0).into(),
7372
root_certificates: Vec::new(),
7473
server_key_pair: None,
7574
client_key_pair: None,
@@ -489,7 +488,7 @@ mod test {
489488
async fn address() -> Result<()> {
490489
let mut builder = Builder::new();
491490

492-
let address = ([0, 0, 0, 0, 0, 0xffff, 0x7f00, 1], 5000).into();
491+
let address = ([0, 0, 0, 0, 0, 0, 0, 1], 5000).into();
493492
let _ = builder.set_address(address);
494493
assert_eq!(builder.address(), &address);
495494

‎src/quic/endpoint/mod.rs

+4-15
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl Endpoint {
149149
let _ = builder.set_address(([0; 8], port).into());
150150
// while testing always use the default loopback address
151151
#[cfg(feature = "test")]
152-
let _ = builder.set_address(([0, 0, 0, 0, 0, 0xffff, 0x7f00, 1], port).into());
152+
let _ = builder.set_address(([0, 0, 0, 0, 0, 0, 0, 1], port).into());
153153
let _ = builder.set_server_key_pair(Some(key_pair));
154154

155155
builder
@@ -191,8 +191,7 @@ impl Endpoint {
191191
/// The following settings are used when using
192192
/// [`trust-dns`](trust_dns_resolver):
193193
/// - all system configurations are ignored
194-
#[allow(clippy::doc_markdown)]
195-
/// - Cloudflare with DoT is used as the name server
194+
/// - Cloudflare with DoH is used as the name server
196195
/// - DNSSEC is enabled
197196
/// - IPv6 is preferred over IPv4 if the bound socket is IPv6
198197
///
@@ -324,7 +323,7 @@ impl Endpoint {
324323

325324
// build the `Resolver`
326325
#[allow(box_pointers)]
327-
let resolver = TokioAsyncResolver::tokio(ResolverConfig::cloudflare_tls(), opts)
326+
let resolver = TokioAsyncResolver::tokio(ResolverConfig::cloudflare_https(), opts)
328327
.map_err(|error| Error::ResolveTrustDns(Box::new(error)))?;
329328
// query the IP
330329
#[allow(box_pointers)]
@@ -362,17 +361,7 @@ impl Endpoint {
362361
/// # Errors
363362
/// [`Error::LocalAddress`] if aquiring the local address failed.
364363
pub fn local_address(&self) -> Result<SocketAddr> {
365-
let address = self.endpoint.local_addr().map_err(Error::LocalAddress)?;
366-
367-
#[cfg(not(feature = "test"))]
368-
return Ok(address);
369-
370-
#[cfg(feature = "test")]
371-
Ok(if address.ip().is_loopback() {
372-
([0, 0, 0, 0, 0, 0xffff, 0x7f00, 1], address.port()).into()
373-
} else {
374-
address
375-
})
364+
self.endpoint.local_addr().map_err(Error::LocalAddress)
376365
}
377366

378367
/// Close all of this [`Endpoint`]'s [`Connection`](crate::Connection)s

0 commit comments

Comments
 (0)