From 6c7c44bd9fe437b8dacf2b55ce562ba59bce8bdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCr=20Akkurt?= Date: Tue, 18 Apr 2023 20:09:15 +0000 Subject: [PATCH] Use `memmap2` instead of `memmap`, enable rustls on windows, fix typos in openssl api (#206) --- .github/workflows/ci.yml | 16 ++++++++++++++++ CHANGELOG.md | 19 +++++++++++++++++++ Cargo.lock | 11 +++++------ Cargo.toml | 6 +++--- src/fs/mmap.rs | 4 ++-- src/lib.rs | 4 ++-- src/openssl/connector.rs | 4 ++-- src/openssl/test.rs | 4 ++-- src/rust_tls.rs | 14 ++++++-------- 9 files changed, 57 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fe886a3..a30a36b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,21 @@ concurrency: cancel-in-progress: true jobs: + test-windows: + name: Run tests on Windows + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + - name: Install rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + - uses: Swatinem/rust-cache@v2 + with: + key: windows-latest-test + - name: Test + run: cargo test --features task,subscriber,fixture,task_unstable,io,sync,future,net,tls,rust_tls,timer,fs,zero_copy,mmap,retry test: name: Check ${{ matrix.check }} on (${{ matrix.os }}) runs-on: ${{ matrix.os }} @@ -97,6 +112,7 @@ jobs: done: name: Done needs: + - test-windows - test - wasm_test runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index aa9c9de..d004602 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ # Release Notes +## 0.5.0 +* Move to `memmap2` because `memmap` is unmaintained. +* Enable `rustls` on `windows` +* fixed typos in `openssl` api. ([#175](https://github.com/infinyon/future-aio/issues/175)) + +([#206](https://github.com/infinyon/future-aio/pull/206)) + +## 0.4.5 +* Doomsday timer to ensure crash ([#196](https://github.com/infinyon/future-aio/pull/196)) + +## 0.4.4 +* update rustls + +## 0.4.3 +* expose futures + +## 0.4.2 +* re-export async_std::sync structs + ## 0.4.1 * Make tcp connector `Send` for `wasm32` ([#165](https://github.com/infinyon/future-aio/pull/165)) diff --git a/Cargo.lock b/Cargo.lock index b7bf8a5..8640e4a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -339,7 +339,7 @@ dependencies = [ [[package]] name = "fluvio-future" -version = "0.4.5" +version = "0.5.0" dependencies = [ "async-fs", "async-io", @@ -361,7 +361,7 @@ dependencies = [ "futures-util", "lazy_static", "log", - "memmap", + "memmap2", "native-tls", "nix", "num_cpus", @@ -670,13 +670,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] -name = "memmap" -version = "0.7.0" +name = "memmap2" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" +checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" dependencies = [ "libc", - "winapi", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index aec7de0..714bd54 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fluvio-future" -version = "0.4.5" +version = "0.5.0" edition = "2021" authors = ["Fluvio Contributors "] description = "I/O futures for Fluvio project" @@ -46,7 +46,7 @@ openssl_tls = [ timer = ["async-io", "pin-project", "futures-lite"] fs = ["async-fs", "futures-lite", "pin-utils", "async-trait"] zero_copy = ["nix", "task_unstable"] -mmap = ["fs", "memmap", "task_unstable"] +mmap = ["fs", "memmap2", "task_unstable"] retry = [] doomsday = [] @@ -71,7 +71,7 @@ fluvio-async-tls = { version = "0.3.0", optional = true } async-std = { version = "1.6.2", default-features = false, optional = true } async-io = { version = "1.1.2", optional = true } async-net = { version = "1.6.0", optional = true } -memmap = { version = "0.7.0", optional = true } +memmap2 = { version = "0.5", optional = true } openssl = { version = "0.10.35", optional = true } async-native-tls = { version = "0.4.0", optional = true } native-tls = { version = "0.2.4", optional = true } diff --git a/src/fs/mmap.rs b/src/fs/mmap.rs index a7ce4de..f9f7239 100644 --- a/src/fs/mmap.rs +++ b/src/fs/mmap.rs @@ -9,8 +9,8 @@ use std::sync::RwLockReadGuard; use std::sync::RwLockWriteGuard; use async_fs::File; -use memmap::Mmap; -use memmap::MmapMut; +use memmap2::Mmap; +use memmap2::MmapMut; use crate::task::spawn_blocking; diff --git a/src/lib.rs b/src/lib.rs index 3698733..ff80f1a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32,10 +32,10 @@ pub mod zero_copy; #[cfg(feature = "net")] pub mod net; -#[cfg(all(unix, feature = "rust_tls"))] +#[cfg(all(any(unix, windows), feature = "rust_tls"))] pub mod rust_tls; -#[cfg(all(unix, feature = "rust_tls", not(feature = "native2_tls")))] +#[cfg(all(any(unix, windows), feature = "rust_tls", not(feature = "native2_tls")))] pub use rust_tls as tls; #[cfg(all(any(unix, windows), feature = "native2_tls"))] diff --git a/src/openssl/connector.rs b/src/openssl/connector.rs index f8438a2..17bc6db 100644 --- a/src/openssl/connector.rs +++ b/src/openssl/connector.rs @@ -194,12 +194,12 @@ pub struct TlsConnectorBuilder { } impl TlsConnectorBuilder { - pub fn with_hostname_vertification_disabled(mut self) -> Result { + pub fn with_hostname_verification_disabled(mut self) -> Result { self.verify_hostname = false; Ok(self) } - pub fn with_certificate_vertification_disabled(mut self) -> Result { + pub fn with_certificate_verification_disabled(mut self) -> Result { self.inner.set_verify(ssl::SslVerifyMode::NONE); Ok(self) } diff --git a/src/openssl/test.rs b/src/openssl/test.rs index 6ce7870..1f7c6f6 100644 --- a/src/openssl/test.rs +++ b/src/openssl/test.rs @@ -42,7 +42,7 @@ async fn test_tls() -> Result<(), TlsError> { )? .build(), TlsConnector::builder()? - .with_hostname_vertification_disabled()? + .with_hostname_verification_disabled()? .with_ca_from_pem_file(INTERMEDIATE_CA_PATH)? .build(), ) @@ -58,7 +58,7 @@ async fn test_tls() -> Result<(), TlsError> { )? .build(), TlsConnector::builder()? - .with_hostname_vertification_disabled()? + .with_hostname_verification_disabled()? .with_ca_from_pem_file(CA_PATH)? .build(), ) diff --git a/src/rust_tls.rs b/src/rust_tls.rs index 42f5d5d..bbf98ef 100644 --- a/src/rust_tls.rs +++ b/src/rust_tls.rs @@ -100,19 +100,17 @@ mod cert { } mod connector { - use std::io::Error as IoError; use std::io::ErrorKind; - use std::os::unix::io::AsRawFd; - use std::os::unix::io::RawFd; use async_rustls::rustls::ServerName; use async_trait::async_trait; use log::debug; use crate::net::{ - BoxReadConnection, BoxWriteConnection, DomainConnector, SplitConnection, TcpDomainConnector, + AsConnectionFd, BoxReadConnection, BoxWriteConnection, ConnectionFd, DomainConnector, + SplitConnection, TcpDomainConnector, }; use super::TcpStream; @@ -135,9 +133,9 @@ mod connector { async fn connect( &self, domain: &str, - ) -> Result<(BoxWriteConnection, BoxReadConnection, RawFd), IoError> { + ) -> Result<(BoxWriteConnection, BoxReadConnection, ConnectionFd), IoError> { let tcp_stream = TcpStream::connect(domain).await?; - let fd = tcp_stream.as_raw_fd(); + let fd = tcp_stream.as_connection_fd(); let (write, read) = self .0 .connect( @@ -180,10 +178,10 @@ mod connector { async fn connect( &self, addr: &str, - ) -> Result<(BoxWriteConnection, BoxReadConnection, RawFd), IoError> { + ) -> Result<(BoxWriteConnection, BoxReadConnection, ConnectionFd), IoError> { debug!("connect to tls addr: {}", addr); let tcp_stream = TcpStream::connect(addr).await?; - let fd = tcp_stream.as_raw_fd(); + let fd = tcp_stream.as_connection_fd(); debug!("connect to tls domain: {}", self.domain); let (write, read) = self .connector