add DoH test for ClientFuture
This commit is contained in:
parent
16185b824e
commit
91fd17f9fc
@ -7,7 +7,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
### Changed
|
||||
|
||||
- *Breaking* Overhauled all ClientFuture implementations to align with new DnsExchange and DnsMultiplexer components in proto.
|
||||
- *breaking* Overhauled all `ClientFuture` implementations to align with new `DnsExchange` and `DnsMultiplexer` components in proto.
|
||||
- *breaking* `ClientFuture` after construction, now returns a "background" `ClientFuture` and a "foreground" `BasicClientHandle`
|
||||
- *breaking* `Client` has more type parameters, these match with the same types returned by the `*ClientConnection` constructors
|
||||
|
||||
## 0.14.0
|
||||
|
||||
|
@ -40,7 +40,9 @@ appveyor = { repository = "bluejekyll/trust-dns", branch = "master", service = "
|
||||
codecov = { repository = "bluejekyll/trust-dns", branch = "master", service = "github" }
|
||||
|
||||
[features]
|
||||
dns-over-https = ["trust-dns-https"]
|
||||
# TODO: the rustls and openssl crates are not deps... should we change that to make them easier to use?
|
||||
# or change this to also be external?
|
||||
dns-over-https = ["trust-dns-https", "rustls", "webpki"]
|
||||
dnssec-openssl = ["dnssec", "openssl", "trust-dns-proto/dnssec-openssl"]
|
||||
dnssec-ring = ["dnssec", "ring", "trust-dns-proto/dnssec-ring", "untrusted"]
|
||||
dnssec = []
|
||||
|
@ -27,6 +27,7 @@ use rr::{DNSClass, IntoRecordSet, Name, RData, Record, RecordType};
|
||||
// TODO: this should be configurable
|
||||
const MAX_PAYLOAD_LEN: u16 = 1500 - 40 - 8; // 1500 (general MTU) - 40 (ipv6 header) - 8 (udp header)
|
||||
|
||||
// TODO: ClientFuture to ClientAsync or AsyncClient?
|
||||
/// A DNS Client implemented over futures-rs.
|
||||
///
|
||||
/// This Client is generic and capable of wrapping UDP, TCP, and other underlying DNS protocol
|
||||
|
@ -53,6 +53,8 @@ dnssec = []
|
||||
# enables experimental the mDNS (multicast) feature
|
||||
mdns = ["trust-dns/mdns", "trust-dns-proto/mdns", "trust-dns-resolver/mdns"]
|
||||
|
||||
dns-over-https = ["trust-dns/dns-over-https", "trust-dns-resolver/dns-over-https", "webpki-roots"]
|
||||
|
||||
# TODO: need to make server support rustls and native-tls
|
||||
# dns-over-native-tls = ["dns-over-tls", "trust-dns-resolver/dns-over-native-tls", "trust-dns-server/dns-over-native-tls"]
|
||||
dns-over-openssl = ["dns-over-tls", "trust-dns-resolver/dns-over-openssl", "trust-dns-server/dns-over-openssl"]
|
||||
@ -74,9 +76,10 @@ tokio-tcp = "^0.1"
|
||||
tokio-timer = "^0.2"
|
||||
tokio-udp = "^0.1"
|
||||
trust-dns = { version = "0.15.0-alpha", path = "../client" }
|
||||
trust-dns-https = { version = "0.1.0-alpha", path = "../https" }
|
||||
trust-dns-openssl = { version = "0.4.0-alpha", path = "../openssl" }
|
||||
trust-dns-proto = { version = "0.5.0-alpha", path = "../proto" }
|
||||
trust-dns-resolver = { version = "0.10.0-alpha", path = "../resolver" }
|
||||
trust-dns-rustls = { version = "0.4.0-alpha", path = "../rustls" }
|
||||
trust-dns-server = { version = "0.15.0-alpha", path = "../server" }
|
||||
|
||||
webpki-roots = { version = "^0.15", optional = true }
|
||||
|
@ -3,11 +3,17 @@ extern crate env_logger;
|
||||
extern crate futures;
|
||||
extern crate log;
|
||||
extern crate openssl;
|
||||
#[cfg(feature = "dns-over-https")]
|
||||
extern crate rustls;
|
||||
extern crate tokio;
|
||||
extern crate trust_dns;
|
||||
#[cfg(feature = "dns-over-https")]
|
||||
extern crate trust_dns_https;
|
||||
extern crate trust_dns_integration;
|
||||
extern crate trust_dns_proto;
|
||||
extern crate trust_dns_server;
|
||||
#[cfg(feature = "dns-over-https")]
|
||||
extern crate webpki_roots;
|
||||
|
||||
use std::net::*;
|
||||
use std::str::FromStr;
|
||||
@ -51,7 +57,6 @@ fn test_query_nonet() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn test_query_udp_ipv4() {
|
||||
let mut io_loop = Runtime::new().unwrap();
|
||||
let addr: SocketAddr = ("8.8.8.8", 53).to_socket_addrs().unwrap().next().unwrap();
|
||||
@ -83,7 +88,6 @@ fn test_query_udp_ipv6() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn test_query_tcp_ipv4() {
|
||||
let mut io_loop = Runtime::new().unwrap();
|
||||
let addr: SocketAddr = ("8.8.8.8", 53).to_socket_addrs().unwrap().next().unwrap();
|
||||
@ -114,6 +118,37 @@ fn test_query_tcp_ipv6() {
|
||||
io_loop.block_on(test_query(&mut client)).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "dns-over-https")]
|
||||
fn test_query_https() {
|
||||
use rustls::{ClientConfig, ProtocolVersion, RootCertStore};
|
||||
use trust_dns_https::HttpsClientStreamBuilder;
|
||||
use trust_dns_proto::xfer::DnsExchange;
|
||||
|
||||
let mut io_loop = Runtime::new().unwrap();
|
||||
let addr: SocketAddr = ("1.1.1.1", 443).to_socket_addrs().unwrap().next().unwrap();
|
||||
|
||||
// using the mozilla default root store
|
||||
let mut root_store = RootCertStore::empty();
|
||||
root_store.add_server_trust_anchors(&self::webpki_roots::TLS_SERVER_ROOTS);
|
||||
let versions = vec![ProtocolVersion::TLSv1_2];
|
||||
|
||||
let mut client_config = ClientConfig::new();
|
||||
client_config.root_store = root_store;
|
||||
client_config.versions = versions;
|
||||
|
||||
let https_builder = HttpsClientStreamBuilder::with_client_config(client_config);
|
||||
let (stream, handle) =
|
||||
DnsExchange::connect(https_builder.build(addr, "cloudflare-dns.com".to_string()));
|
||||
|
||||
let (bg, mut client) = ClientFuture::from_exchange(stream, handle);
|
||||
io_loop.spawn(bg);
|
||||
|
||||
// TODO: timeouts on these requests so that the test doesn't hang
|
||||
io_loop.block_on(test_query(&mut client)).unwrap();
|
||||
io_loop.block_on(test_query(&mut client)).unwrap();
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn test_query<R>(client: &mut BasicClientHandle<R>) -> Box<Future<Item = (), Error = ()>>
|
||||
where
|
||||
|
@ -28,6 +28,7 @@ use lookup_ip::LookupIpFuture;
|
||||
|
||||
mod background;
|
||||
|
||||
// TODO: Consider renaming to ResolverAsync
|
||||
/// A handle for resolving DNS records.
|
||||
///
|
||||
/// Creating a `AsyncResolver` returns a new handle and a future that should
|
||||
|
Loading…
Reference in New Issue
Block a user