diff --git a/actix-tls/CHANGES.md b/actix-tls/CHANGES.md index f6bc7d13..c320bc85 100644 --- a/actix-tls/CHANGES.md +++ b/actix-tls/CHANGES.md @@ -1,23 +1,30 @@ # Changes ## Unreleased - 2021-xx-xx -* There are now no default features. [#422] -* Implement `Default` for `connect::Resolver`. [#422] +### Added * Derive `Debug` for `connect::Connection`. [#422] -* Remove redundant `connect::Connection::from_parts` method. [#422] -* Rename TLS acceptor service future types and hide from docs. [#422] +* Implement `Default` for `connect::Resolver`. [#422] +* Implement `Display` for `TlsError`. [#422] * Implement `Error` for `ConnectError`. [#422] * Implement `Error` for `TlsError` where both types also implement `Error`. [#422] -* Rename `accept::native_tls::{NativeTlsAcceptorService => AcceptorService}`. [#422] + +### Changed +* There are now no default features. [#422] +* Useful re-exports from underlying TLS crates are exposed in a `reexports` modules in all acceptors and connectors. +* Convert `connect::ResolverService` from enum to struct. [#422] * Make `ConnectAddrsIter` private. [#422] +* Rename `accept::native_tls::{NativeTlsAcceptorService => AcceptorService}`. [#422] +* Rename `connect::{Address => Host}` trait. [#422] * Rename method `connect::Connection::{host => hostname}`. [#422] * Rename struct `connect::{Connect => ConnectionInfo}`. [#422] -* Rename struct `connect::{ConnectServiceFactory => Connector}`. [#422] * Rename struct `connect::{ConnectService => ConnectorService}`. [#422] +* Rename struct `connect::{ConnectServiceFactory => Connector}`. [#422] +* Rename TLS acceptor service future types and hide from docs. [#422] + +### Removed * Remove `connect::{new_connector, new_connector_factory, default_connector, default_connector_factory}` methods. [#422] -* Convert `connect::ResolverService` from enum to struct. [#422] * Remove `connect::native_tls::Connector::service` method. [#422] -* Rename `connect::{Address => Host}` trait. [#422] +* Remove redundant `connect::Connection::from_parts` method. [#422] [#422]: https://github.com/actix/actix-net/pull/422 diff --git a/actix-tls/Cargo.toml b/actix-tls/Cargo.toml index 29feff73..a878dcdc 100755 --- a/actix-tls/Cargo.toml +++ b/actix-tls/Cargo.toml @@ -21,7 +21,7 @@ name = "actix_tls" path = "src/lib.rs" [features] -default = [] +default = ["accept", "connect", "uri", "rustls", "openssl", "native-tls"] # enable acceptor services accept = [] diff --git a/actix-tls/src/accept/native_tls.rs b/actix-tls/src/accept/native_tls.rs index 664d33e5..534dc58d 100644 --- a/actix-tls/src/accept/native_tls.rs +++ b/actix-tls/src/accept/native_tls.rs @@ -22,10 +22,16 @@ use actix_utils::{ }; use derive_more::{Deref, DerefMut, From}; use futures_core::future::LocalBoxFuture; -pub use tokio_native_tls::{native_tls::Error, TlsAcceptor}; +use tokio_native_tls::{native_tls::Error, TlsAcceptor}; use super::{TlsError, DEFAULT_TLS_HANDSHAKE_TIMEOUT, MAX_CONN_COUNTER}; +pub mod reexports { + //! Re-exports from `native-tls` that are useful for acceptors. + + pub use tokio_native_tls::{native_tls::Error, TlsAcceptor}; +} + /// Wraps a `native-tls` based async TLS stream in order to implement [`ActixStream`]. #[derive(Deref, DerefMut, From)] pub struct TlsStream(tokio_native_tls::TlsStream); diff --git a/actix-tls/src/accept/openssl.rs b/actix-tls/src/accept/openssl.rs index 1c117367..a91000cc 100644 --- a/actix-tls/src/accept/openssl.rs +++ b/actix-tls/src/accept/openssl.rs @@ -22,13 +22,19 @@ use actix_utils::{ future::{ready, Ready as FutReady}, }; use derive_more::{Deref, DerefMut, From}; -pub use openssl::ssl::{ - AlpnError, Error, HandshakeError, Ssl, SslAcceptor, SslAcceptorBuilder, -}; +use openssl::ssl::{Error, Ssl, SslAcceptor}; use pin_project_lite::pin_project; use super::{TlsError, DEFAULT_TLS_HANDSHAKE_TIMEOUT, MAX_CONN_COUNTER}; +pub mod reexports { + //! Re-exports from `openssl` that are useful for acceptors. + + pub use openssl::ssl::{ + AlpnError, Error, HandshakeError, Ssl, SslAcceptor, SslAcceptorBuilder, + }; +} + /// Wraps an `openssl` based async TLS stream in order to implement [`ActixStream`]. #[derive(Deref, DerefMut, From)] pub struct TlsStream(tokio_openssl::SslStream); diff --git a/actix-tls/src/accept/rustls.rs b/actix-tls/src/accept/rustls.rs index 15e591b4..b6f3a8fe 100644 --- a/actix-tls/src/accept/rustls.rs +++ b/actix-tls/src/accept/rustls.rs @@ -24,11 +24,17 @@ use actix_utils::{ }; use derive_more::{Deref, DerefMut, From}; use pin_project_lite::pin_project; -pub use tokio_rustls::rustls::ServerConfig; +use tokio_rustls::rustls::ServerConfig; use tokio_rustls::{Accept, TlsAcceptor}; use super::{TlsError, DEFAULT_TLS_HANDSHAKE_TIMEOUT, MAX_CONN_COUNTER}; +pub mod reexports { + //! Re-exports from `rustls` that are useful for acceptors. + + pub use tokio_rustls::rustls::ServerConfig; +} + /// Wraps a `rustls` based async TLS stream in order to implement [`ActixStream`]. #[derive(Deref, DerefMut, From)] pub struct TlsStream(tokio_rustls::server::TlsStream); diff --git a/actix-tls/src/connect/connector.rs b/actix-tls/src/connect/connector.rs index 22f35029..d749a70f 100755 --- a/actix-tls/src/connect/connector.rs +++ b/actix-tls/src/connect/connector.rs @@ -18,7 +18,7 @@ use super::{ /// Combined resolver and TCP connector service factory. /// -/// Used to create [`ConnectService`]s which receive connection information, resolve DNS if +/// Used to create [`ConnectorService`]s which receive connection information, resolve DNS if /// required, and return a TCP stream. #[derive(Clone, Default)] pub struct Connector { diff --git a/actix-tls/src/connect/mod.rs b/actix-tls/src/connect/mod.rs index c2da8ffc..a66b750f 100644 --- a/actix-tls/src/connect/mod.rs +++ b/actix-tls/src/connect/mod.rs @@ -7,11 +7,9 @@ //! # Stages of TLS connector services: //! 1. Resolve DNS and establish a [`TcpStream`] with the TCP connector service. //! 1. Wrap the stream and perform connect handshake with remote peer. -//! 1. Return wrapped stream type that implements [`AsyncRead`] and [`AsyncWrite`]. +//! 1. Return wrapped stream type that implements `AsyncRead` and `AsyncWrite`. //! //! [`TcpStream`]: actix_rt::net::TcpStream -//! [`AsyncRead`]: actix_rt::net::AsyncRead -//! [`AsyncWrite`]: actix_rt::net::AsyncWrite mod connect_addrs; mod connection; diff --git a/actix-tls/src/connect/native_tls.rs b/actix-tls/src/connect/native_tls.rs index 99b276d1..eba89cb2 100644 --- a/actix-tls/src/connect/native_tls.rs +++ b/actix-tls/src/connect/native_tls.rs @@ -1,6 +1,6 @@ //! Native-TLS based connector service. //! -//! See [`Connector`] for main connector service factory docs. +//! See [`TlsConnector`] for main connector service factory docs. use std::io; diff --git a/actix-tls/src/connect/openssl.rs b/actix-tls/src/connect/openssl.rs index 1ab6e79d..3db37284 100755 --- a/actix-tls/src/connect/openssl.rs +++ b/actix-tls/src/connect/openssl.rs @@ -1,6 +1,6 @@ //! OpenSSL based connector service. //! -//! See [`Connector`] for main connector service factory docs. +//! See [`TlsConnector`] for main connector service factory docs. use std::{ future::Future, @@ -26,23 +26,23 @@ pub mod reexports { } /// Connector service factory using `openssl`. -pub struct Connector { +pub struct TlsConnector { connector: SslConnector, } -impl Connector { +impl TlsConnector { /// Constructs new connector service factory from an `openssl` connector. pub fn new(connector: SslConnector) -> Self { - Connector { connector } + TlsConnector { connector } } /// Constructs new connector service from an `openssl` connector. - pub fn service(connector: SslConnector) -> ConnectorService { - ConnectorService { connector } + pub fn service(connector: SslConnector) -> TlsConnectorService { + TlsConnectorService { connector } } } -impl Clone for Connector { +impl Clone for TlsConnector { fn clone(&self) -> Self { Self { connector: self.connector.clone(), @@ -50,7 +50,7 @@ impl Clone for Connector { } } -impl ServiceFactory> for Connector +impl ServiceFactory> for TlsConnector where R: Host, IO: ActixStream + 'static, @@ -58,23 +58,23 @@ where type Response = Connection>; type Error = io::Error; type Config = (); - type Service = ConnectorService; + type Service = TlsConnectorService; type InitError = (); type Future = Ready>; fn new_service(&self, _: ()) -> Self::Future { - ok(ConnectorService { + ok(TlsConnectorService { connector: self.connector.clone(), }) } } /// Connector service using `openssl`. -pub struct ConnectorService { +pub struct TlsConnectorService { connector: SslConnector, } -impl Clone for ConnectorService { +impl Clone for TlsConnectorService { fn clone(&self) -> Self { Self { connector: self.connector.clone(), @@ -82,7 +82,7 @@ impl Clone for ConnectorService { } } -impl Service> for ConnectorService +impl Service> for TlsConnectorService where R: Host, IO: ActixStream, diff --git a/actix-tls/src/connect/rustls.rs b/actix-tls/src/connect/rustls.rs index c422ce1f..a98ae04e 100755 --- a/actix-tls/src/connect/rustls.rs +++ b/actix-tls/src/connect/rustls.rs @@ -1,6 +1,6 @@ //! Rustls based connector service. //! -//! See [`Connector`] for main connector service factory docs. +//! See [`TlsConnector`] for main connector service factory docs. use std::{ convert::TryFrom, @@ -48,23 +48,23 @@ pub fn webpki_roots_cert_store() -> RootCertStore { /// Connector service factory using `rustls`. #[derive(Clone)] -pub struct Connector { +pub struct TlsConnector { connector: Arc, } -impl Connector { +impl TlsConnector { /// Constructs new connector service factory from a `rustls` client configuration. pub fn new(connector: Arc) -> Self { - Connector { connector } + TlsConnector { connector } } /// Constructs new connector service from a `rustls` client configuration. - pub fn service(connector: Arc) -> ConnectorService { - ConnectorService { connector } + pub fn service(connector: Arc) -> TlsConnectorService { + TlsConnectorService { connector } } } -impl ServiceFactory> for Connector +impl ServiceFactory> for TlsConnector where R: Host, IO: ActixStream + 'static, @@ -72,12 +72,12 @@ where type Response = Connection>; type Error = io::Error; type Config = (); - type Service = ConnectorService; + type Service = TlsConnectorService; type InitError = (); type Future = Ready>; fn new_service(&self, _: ()) -> Self::Future { - ok(ConnectorService { + ok(TlsConnectorService { connector: self.connector.clone(), }) } @@ -85,11 +85,11 @@ where /// Connector service using `rustls`. #[derive(Clone)] -pub struct ConnectorService { +pub struct TlsConnectorService { connector: Arc, } -impl Service> for ConnectorService +impl Service> for TlsConnectorService where R: Host, IO: ActixStream,