Remove the rustls-tls feature flag

pull/217/head
Dominik Nakamura 3 years ago
parent 3fbd583f29
commit 3efb0544c6
No known key found for this signature in database
GPG Key ID: E4C6A749B2491910
  1. 5
      Cargo.toml
  2. 11
      src/client.rs
  3. 4
      src/error.rs
  4. 4
      src/stream.rs
  5. 11
      tests/connection_reset.rs

@ -19,9 +19,8 @@ all-features = true
default = [] default = []
native-tls = ["native-tls-crate"] native-tls = ["native-tls-crate"]
native-tls-vendored = ["native-tls", "native-tls-crate/vendored"] native-tls-vendored = ["native-tls", "native-tls-crate/vendored"]
rustls-tls = ["rustls", "webpki"] rustls-tls-native-roots = ["rustls", "webpki", "rustls-native-certs"]
rustls-tls-native-roots = ["rustls-tls", "rustls-native-certs"] rustls-tls-webpki-roots = ["rustls", "webpki", "webpki-roots"]
rustls-tls-webpki-roots = ["rustls-tls", "webpki-roots"]
[dependencies] [dependencies]
base64 = "0.13.0" base64 = "0.13.0"

@ -50,7 +50,10 @@ mod encryption {
} }
} }
#[cfg(all(feature = "rustls-tls", not(feature = "native-tls")))] #[cfg(all(
any(feature = "rustls-tls-native-roots", feature = "rustls-tls-webpki-roots"),
not(feature = "native-tls")
))]
mod encryption { mod encryption {
use rustls::ClientConfig; use rustls::ClientConfig;
pub use rustls::{ClientSession, StreamOwned}; pub use rustls::{ClientSession, StreamOwned};
@ -96,7 +99,11 @@ mod encryption {
} }
} }
#[cfg(not(any(feature = "native-tls", feature = "rustls-tls")))] #[cfg(not(any(
feature = "native-tls",
feature = "rustls-tls-native-roots",
feature = "rustls-tls-webpki-roots"
)))]
mod encryption { mod encryption {
use std::net::TcpStream; use std::net::TcpStream;

@ -253,11 +253,11 @@ pub enum TlsError {
#[error("native-tls error: {0}")] #[error("native-tls error: {0}")]
Native(#[from] native_tls_crate::Error), Native(#[from] native_tls_crate::Error),
/// Rustls error. /// Rustls error.
#[cfg(feature = "rustls-tls")] #[cfg(any(feature = "rustls-tls-native-roots", feature = "rustls-tls-webpki-roots"))]
#[error("rustls error: {0}")] #[error("rustls error: {0}")]
Rustls(#[from] rustls::TLSError), Rustls(#[from] rustls::TLSError),
/// DNS name resolution error. /// DNS name resolution error.
#[cfg(feature = "rustls-tls")] #[cfg(any(feature = "rustls-tls-native-roots", feature = "rustls-tls-webpki-roots"))]
#[error("Invalid DNS name: {0}")] #[error("Invalid DNS name: {0}")]
Dns(#[from] webpki::InvalidDNSNameError), Dns(#[from] webpki::InvalidDNSNameError),
} }

@ -10,7 +10,7 @@ use std::net::TcpStream;
#[cfg(feature = "native-tls")] #[cfg(feature = "native-tls")]
use native_tls_crate::TlsStream; use native_tls_crate::TlsStream;
#[cfg(feature = "rustls-tls")] #[cfg(any(feature = "rustls-tls-native-roots", feature = "rustls-tls-webpki-roots"))]
use rustls::StreamOwned; use rustls::StreamOwned;
/// Stream mode, either plain TCP or TLS. /// Stream mode, either plain TCP or TLS.
@ -41,7 +41,7 @@ impl<S: Read + Write + NoDelay> NoDelay for TlsStream<S> {
} }
} }
#[cfg(feature = "rustls-tls")] #[cfg(any(feature = "rustls-tls-native-roots", feature = "rustls-tls-webpki-roots"))]
impl<S: rustls::Session, T: Read + Write + NoDelay> NoDelay for StreamOwned<S, T> { impl<S: rustls::Session, T: Read + Write + NoDelay> NoDelay for StreamOwned<S, T> {
fn set_nodelay(&mut self, nodelay: bool) -> IoResult<()> { fn set_nodelay(&mut self, nodelay: bool) -> IoResult<()> {
self.sock.set_nodelay(nodelay) self.sock.set_nodelay(nodelay)

@ -1,6 +1,10 @@
//! Verifies that the server returns a `ConnectionClosed` error when the connection //! Verifies that the server returns a `ConnectionClosed` error when the connection
//! is closed from the server's point of view and drop the underlying tcp socket. //! is closed from the server's point of view and drop the underlying tcp socket.
#![cfg(any(feature = "native-tls", feature = "rustls-tls"))] #![cfg(any(
feature = "native-tls",
feature = "rustls-tls-native-roots",
feature = "rustls-tls-webpki-roots"
))]
use std::{ use std::{
net::{TcpListener, TcpStream}, net::{TcpListener, TcpStream},
@ -15,7 +19,10 @@ use url::Url;
#[cfg(feature = "native-tls")] #[cfg(feature = "native-tls")]
type Sock = WebSocket<Stream<TcpStream, native_tls_crate::TlsStream<TcpStream>>>; type Sock = WebSocket<Stream<TcpStream, native_tls_crate::TlsStream<TcpStream>>>;
#[cfg(all(feature = "rustls-tls", not(feature = "native-tls")))] #[cfg(all(
any(feature = "rustls-tls-native-roots", feature = "rustls-tls-webpki-roots"),
not(feature = "native-tls")
))]
type Sock = WebSocket<Stream<TcpStream, rustls::StreamOwned<rustls::ClientSession, TcpStream>>>; type Sock = WebSocket<Stream<TcpStream, rustls::StreamOwned<rustls::ClientSession, TcpStream>>>;
fn do_test<CT, ST>(port: u16, client_task: CT, server_task: ST) fn do_test<CT, ST>(port: u16, client_task: CT, server_task: ST)

Loading…
Cancel
Save