From 23e13304ef60be061da5199cd8d12810eda62785 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Fri, 11 Jan 2019 10:48:47 -0800 Subject: [PATCH] Disable trust-dns on Windows Closes #431 --- Cargo.toml | 2 +- src/connect.rs | 10 +++++----- src/error.rs | 6 ++++++ src/lib.rs | 4 ++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0a0425d..a750d37 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ tokio-rustls = { version = "0.8", optional = true } webpki-roots = { version = "0.15", optional = true } rustls = { version = "0.14", features = ["dangerous_configuration"], optional = true } -[target.'cfg(not(target_os = "android"))'.dependencies] +[target.'cfg(not(any(target_os = "android", windows)))'.dependencies] trust-dns-resolver = "0.10" [dev-dependencies] diff --git a/src/connect.rs b/src/connect.rs index a979a85..48c26e1 100644 --- a/src/connect.rs +++ b/src/connect.rs @@ -13,13 +13,13 @@ use bytes::BufMut; use std::io; use std::sync::Arc; -#[cfg(not(target_os = "android"))] +#[cfg(not(any(target_os = "android", windows)))] use dns::TrustDnsResolver; use Proxy; -#[cfg(not(target_os = "android"))] +#[cfg(not(any(target_os = "android", windows)))] type HttpConnector = ::hyper::client::HttpConnector; -#[cfg(target_os = "android")] +#[cfg(any(target_os = "android", windows))] type HttpConnector = ::hyper::client::HttpConnector; @@ -74,14 +74,14 @@ impl Connector { } } -#[cfg(not(target_os = "android"))] +#[cfg(not(any(target_os = "android", windows)))] fn http_connector() -> ::Result { TrustDnsResolver::new() .map(HttpConnector::new_with_resolver) .map_err(::error::dns_system_conf) } -#[cfg(target_os = "android")] +#[cfg(any(target_os = "android", windows))] fn http_connector() -> ::Result { Ok(HttpConnector::new(4)) } diff --git a/src/error.rs b/src/error.rs index af4a1bd..7107ef4 100644 --- a/src/error.rs +++ b/src/error.rs @@ -140,6 +140,7 @@ impl Error { Kind::NativeTls(ref e) => Some(e), #[cfg(feature = "rustls-tls")] Kind::Rustls(ref e) => Some(e), + #[cfg(not(any(target_os = "android", windows)))] Kind::DnsSystemConf(ref e) => Some(e), Kind::Io(ref e) => Some(e), Kind::UrlEncoded(ref e) => Some(e), @@ -238,6 +239,7 @@ impl fmt::Display for Error { Kind::NativeTls(ref e) => fmt::Display::fmt(e, f), #[cfg(feature = "rustls-tls")] Kind::Rustls(ref e) => fmt::Display::fmt(e, f), + #[cfg(not(any(target_os = "android", windows)))] Kind::DnsSystemConf(ref e) => { write!(f, "failed to load DNS system conf: {}", e) }, @@ -272,6 +274,7 @@ impl StdError for Error { Kind::NativeTls(ref e) => e.description(), #[cfg(feature = "rustls-tls")] Kind::Rustls(ref e) => e.description(), + #[cfg(not(any(target_os = "android", windows)))] Kind::DnsSystemConf(_) => "failed to load DNS system conf", Kind::Io(ref e) => e.description(), Kind::UrlEncoded(ref e) => e.description(), @@ -296,6 +299,7 @@ impl StdError for Error { Kind::NativeTls(ref e) => e.cause(), #[cfg(feature = "rustls-tls")] Kind::Rustls(ref e) => e.cause(), + #[cfg(not(any(target_os = "android", windows)))] Kind::DnsSystemConf(ref e) => e.cause(), Kind::Io(ref e) => e.cause(), Kind::UrlEncoded(ref e) => e.cause(), @@ -322,6 +326,7 @@ pub(crate) enum Kind { NativeTls(::native_tls::Error), #[cfg(feature = "rustls-tls")] Rustls(::rustls::TLSError), + #[cfg(not(any(target_os = "android", windows)))] DnsSystemConf(io::Error), Io(io::Error), UrlEncoded(::serde_urlencoded::ser::Error), @@ -496,6 +501,7 @@ pub(crate) fn url_bad_scheme(url: Url) -> Error { Error::new(Kind::UrlBadScheme, Some(url)) } +#[cfg(not(any(target_os = "android", windows)))] pub(crate) fn dns_system_conf(io: io::Error) -> Error { Error::new(Kind::DnsSystemConf(io), None) } diff --git a/src/lib.rs b/src/lib.rs index f779ac1..107d3eb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -196,7 +196,7 @@ extern crate serde_urlencoded; extern crate tokio; #[cfg_attr(feature = "default-tls", macro_use)] extern crate tokio_io; -#[cfg(not(target_os = "android"))] +#[cfg(not(any(target_os = "android", windows)))] extern crate trust_dns_resolver; extern crate url; extern crate uuid; @@ -238,7 +238,7 @@ mod connect; mod connect_async; mod body; mod client; -#[cfg(not(target_os = "android"))] +#[cfg(not(any(target_os = "android", windows)))] mod dns; mod into_url; mod proxy;