1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-06-26 15:07:43 +02:00

bump MSRV to 1.65 (#485)

This commit is contained in:
Rob Ede
2023-07-17 03:05:39 +01:00
committed by GitHub
parent 177590a7d8
commit 8d5d1dbf6f
60 changed files with 188 additions and 229 deletions

View File

@ -2,7 +2,7 @@
## Unreleased - 2023-xx-xx
- Minimum supported Rust version (MSRV) is now 1.60.
- Minimum supported Rust version (MSRV) is now 1.65.
## 3.0.4 - 2022-03-15

View File

@ -10,8 +10,8 @@ keywords = ["network", "tls", "ssl", "async", "transport"]
repository = "https://github.com/actix/actix-net.git"
categories = ["network-programming", "asynchronous", "cryptography"]
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.60"
edition.workspace = true
rust-version.workspace = true
[package.metadata.docs.rs]
all-features = true

View File

@ -56,6 +56,25 @@ pub enum TlsError<TlsErr, SvcErr> {
Service(SvcErr),
}
impl<TlsErr> TlsError<TlsErr, Infallible> {
/// Casts the infallible service error type returned from acceptors into caller's type.
///
/// # Examples
/// ```
/// # use std::convert::Infallible;
/// # use actix_tls::accept::TlsError;
/// let a: TlsError<u32, Infallible> = TlsError::Tls(42);
/// let _b: TlsError<u32, u64> = a.into_service_error();
/// ```
pub fn into_service_error<SvcErr>(self) -> TlsError<TlsErr, SvcErr> {
match self {
Self::Timeout => TlsError::Timeout,
Self::Tls(err) => TlsError::Tls(err),
Self::Service(err) => match err {},
}
}
}
impl<TlsErr, SvcErr> fmt::Display for TlsError<TlsErr, SvcErr> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
@ -80,25 +99,6 @@ where
}
}
impl<TlsErr> TlsError<TlsErr, Infallible> {
/// Casts the infallible service error type returned from acceptors into caller's type.
///
/// # Examples
/// ```
/// # use std::convert::Infallible;
/// # use actix_tls::accept::TlsError;
/// let a: TlsError<u32, Infallible> = TlsError::Tls(42);
/// let _b: TlsError<u32, u64> = a.into_service_error();
/// ```
pub fn into_service_error<SvcErr>(self) -> TlsError<TlsErr, SvcErr> {
match self {
Self::Timeout => TlsError::Timeout,
Self::Tls(err) => TlsError::Tls(err),
Self::Service(err) => match err {},
}
}
}
#[cfg(test)]
mod tests {
use super::*;

View File

@ -23,8 +23,7 @@ use actix_utils::{
};
use pin_project_lite::pin_project;
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
use tokio_rustls::rustls::ServerConfig;
use tokio_rustls::{Accept, TlsAcceptor};
use tokio_rustls::{rustls::ServerConfig, Accept, TlsAcceptor};
use super::{TlsError, DEFAULT_TLS_HANDSHAKE_TIMEOUT, MAX_CONN_COUNTER};

View File

@ -33,10 +33,12 @@ pub mod rustls;
#[cfg(feature = "native-tls")]
pub mod native_tls;
pub use self::connection::Connection;
pub use self::connector::{Connector, ConnectorService};
pub use self::error::ConnectError;
pub use self::host::Host;
pub use self::info::ConnectInfo;
pub use self::resolve::Resolve;
pub use self::resolver::{Resolver, ResolverService};
pub use self::{
connection::Connection,
connector::{Connector, ConnectorService},
error::ConnectError,
host::Host,
info::ConnectInfo,
resolve::Resolve,
resolver::{Resolver, ResolverService},
};

View File

@ -19,8 +19,7 @@ use crate::connect::{Connection, Host};
pub mod reexports {
//! Re-exports from `native-tls` and `tokio-native-tls` that are useful for connectors.
pub use tokio_native_tls::native_tls::TlsConnector;
pub use tokio_native_tls::TlsStream as AsyncTlsStream;
pub use tokio_native_tls::{native_tls::TlsConnector, TlsStream as AsyncTlsStream};
}
/// Connector service and factory using `native-tls`.

View File

@ -22,9 +22,7 @@ use crate::connect::{Connection, Host};
pub mod reexports {
//! Re-exports from `openssl` and `tokio-openssl` that are useful for connectors.
pub use openssl::ssl::{
Error, HandshakeError, SslConnector, SslConnectorBuilder, SslMethod,
};
pub use openssl::ssl::{Error, HandshakeError, SslConnector, SslConnectorBuilder, SslMethod};
pub use tokio_openssl::SslStream as AsyncSslStream;
}

View File

@ -15,9 +15,11 @@ use actix_rt::net::ActixStream;
use actix_service::{Service, ServiceFactory};
use actix_utils::future::{ok, Ready};
use futures_core::ready;
use tokio_rustls::rustls::{client::ServerName, OwnedTrustAnchor, RootCertStore};
use tokio_rustls::{client::TlsStream as AsyncTlsStream, rustls::ClientConfig};
use tokio_rustls::{Connect as RustlsConnect, TlsConnector as RustlsTlsConnector};
use tokio_rustls::{
client::TlsStream as AsyncTlsStream,
rustls::{client::ServerName, ClientConfig, OwnedTrustAnchor, RootCertStore},
Connect as RustlsConnect, TlsConnector as RustlsTlsConnector,
};
use tracing::trace;
use webpki_roots::TLS_SERVER_ROOTS;
@ -26,8 +28,7 @@ use crate::connect::{Connection, Host};
pub mod reexports {
//! Re-exports from `rustls` and `webpki_roots` that are useful for connectors.
pub use tokio_rustls::client::TlsStream as AsyncTlsStream;
pub use tokio_rustls::rustls::ClientConfig;
pub use tokio_rustls::{client::TlsStream as AsyncTlsStream, rustls::ClientConfig};
pub use webpki_roots::TLS_SERVER_ROOTS;
}

View File

@ -17,11 +17,9 @@ use actix_utils::future::ok;
use tokio_rustls::rustls::{Certificate, ClientConfig, RootCertStore, ServerName};
fn new_cert_and_key() -> (String, String) {
let cert = rcgen::generate_simple_self_signed(vec![
"127.0.0.1".to_owned(),
"localhost".to_owned(),
])
.unwrap();
let cert =
rcgen::generate_simple_self_signed(vec!["127.0.0.1".to_owned(), "localhost".to_owned()])
.unwrap();
let key = cert.serialize_private_key_pem();
let cert = cert.serialize_pem().unwrap();

View File

@ -14,19 +14,19 @@ use std::io::{BufReader, Write};
use actix_rt::net::TcpStream;
use actix_server::TestServer;
use actix_service::ServiceFactoryExt as _;
use actix_tls::accept::rustls::{Acceptor, TlsStream};
use actix_tls::connect::openssl::reexports::SslConnector;
use actix_tls::{
accept::rustls::{Acceptor, TlsStream},
connect::openssl::reexports::SslConnector,
};
use actix_utils::future::ok;
use rustls_pemfile::{certs, pkcs8_private_keys};
use tls_openssl::ssl::SslVerifyMode;
use tokio_rustls::rustls::{self, Certificate, PrivateKey, ServerConfig};
fn new_cert_and_key() -> (String, String) {
let cert = rcgen::generate_simple_self_signed(vec![
"127.0.0.1".to_owned(),
"localhost".to_owned(),
])
.unwrap();
let cert =
rcgen::generate_simple_self_signed(vec!["127.0.0.1".to_owned(), "localhost".to_owned()])
.unwrap();
let key = cert.serialize_private_key_pem();
let cert = cert.serialize_pem().unwrap();

View File

@ -51,8 +51,7 @@ async fn custom_resolver_connect() {
use trust_dns_resolver::TokioAsyncResolver;
let srv =
TestServer::start(|| fn_service(|_io: TcpStream| async { Ok::<_, io::Error>(()) }));
let srv = TestServer::start(|| fn_service(|_io: TcpStream| async { Ok::<_, io::Error>(()) }));
struct MyResolver {
trust_dns: TokioAsyncResolver,