mirror of https://github.com/fafhrd91/actix-net
Merge branch 'master' into service/fix/aut-traits
This commit is contained in:
commit
e8edbb44a7
|
@ -5,18 +5,21 @@ ci-doctest = "test --workspace --all-features --doc --no-fail-fast -- --nocaptur
|
||||||
|
|
||||||
# just check the library (without dev deps)
|
# just check the library (without dev deps)
|
||||||
ci-check-min = "hack --workspace check --no-default-features"
|
ci-check-min = "hack --workspace check --no-default-features"
|
||||||
ci-check-lib = "hack --workspace --feature-powerset --exclude-features io-uring check"
|
ci-check-lib = "hack --workspace --feature-powerset --exclude-features=io-uring check"
|
||||||
ci-check-lib-linux = "hack --workspace --feature-powerset check"
|
ci-check-lib-linux = "hack --workspace --feature-powerset check"
|
||||||
|
|
||||||
# check everything
|
# check everything
|
||||||
ci-check = "hack --workspace --feature-powerset --exclude-features io-uring check --tests --examples"
|
ci-check = "hack --workspace --feature-powerset --exclude-features=io-uring check --tests --examples"
|
||||||
ci-check-linux = "hack --workspace --feature-powerset check --tests --examples"
|
ci-check-linux = "hack --workspace --feature-powerset check --tests --examples"
|
||||||
|
|
||||||
# tests avoiding io-uring feature
|
# tests avoiding io-uring feature
|
||||||
ci-test = "hack test --workspace --exclude=actix-rt --exclude=actix-server --all-features --lib --tests --no-fail-fast -- --nocapture"
|
ci-test = "hack test --workspace --exclude=actix-rt --exclude=actix-server --all-features --lib --tests --no-fail-fast -- --nocapture"
|
||||||
ci-test-rt = " hack --feature-powerset --exclude-features io-uring test --package=actix-rt --lib --tests --no-fail-fast -- --nocapture"
|
ci-test-rt = " hack --feature-powerset --exclude-features=io-uring test --package=actix-rt --lib --tests --no-fail-fast -- --nocapture"
|
||||||
ci-test-server = "hack --feature-powerset --exclude-features io-uring test --package=actix-server --lib --tests --no-fail-fast -- --nocapture"
|
ci-test-server = "hack --feature-powerset --exclude-features=io-uring test --package=actix-server --lib --tests --no-fail-fast -- --nocapture"
|
||||||
|
|
||||||
# test with io-uring feature
|
# test with io-uring feature
|
||||||
ci-test-rt-linux = " hack --feature-powerset test --package=actix-rt --lib --tests --no-fail-fast -- --nocapture"
|
ci-test-rt-linux = " hack --feature-powerset test --package=actix-rt --lib --tests --no-fail-fast -- --nocapture"
|
||||||
ci-test-server-linux = "hack --feature-powerset test --package=actix-server --lib --tests --no-fail-fast -- --nocapture"
|
ci-test-server-linux = "hack --feature-powerset test --package=actix-server --lib --tests --no-fail-fast -- --nocapture"
|
||||||
|
|
||||||
|
# test lower msrv
|
||||||
|
ci-test-lower-msrv = "hack --workspace --exclude=actix-server --exclude=actix-tls --feature-powerset test --lib --tests --no-fail-fast -- --nocapture"
|
||||||
|
|
|
@ -18,7 +18,7 @@ jobs:
|
||||||
- { name: Windows (MinGW), os: windows-latest, triple: x86_64-pc-windows-gnu }
|
- { name: Windows (MinGW), os: windows-latest, triple: x86_64-pc-windows-gnu }
|
||||||
- { name: Windows (32-bit), os: windows-latest, triple: i686-pc-windows-msvc }
|
- { name: Windows (32-bit), os: windows-latest, triple: i686-pc-windows-msvc }
|
||||||
version:
|
version:
|
||||||
- 1.46.0 # MSRV
|
- 1.52.0 # MSRV for -server and -tls
|
||||||
- stable
|
- stable
|
||||||
- nightly
|
- nightly
|
||||||
|
|
||||||
|
@ -64,8 +64,7 @@ jobs:
|
||||||
|
|
||||||
# - name: Generate Cargo.lock
|
# - name: Generate Cargo.lock
|
||||||
# uses: actions-rs/cargo@v1
|
# uses: actions-rs/cargo@v1
|
||||||
# with:
|
# with: { command: generate-lockfile }
|
||||||
# command: generate-lockfile
|
|
||||||
# - name: Cache Dependencies
|
# - name: Cache Dependencies
|
||||||
# uses: Swatinem/rust-cache@v1.2.0
|
# uses: Swatinem/rust-cache@v1.2.0
|
||||||
|
|
||||||
|
@ -117,26 +116,66 @@ jobs:
|
||||||
cargo ci-test-rt-linux
|
cargo ci-test-rt-linux
|
||||||
cargo ci-test-server-linux
|
cargo ci-test-server-linux
|
||||||
|
|
||||||
- name: Generate coverage file
|
- name: Clear the cargo caches
|
||||||
if: >
|
|
||||||
matrix.target.os == 'ubuntu-latest'
|
|
||||||
&& matrix.version == 'stable'
|
|
||||||
&& github.ref == 'refs/heads/master'
|
|
||||||
run: |
|
run: |
|
||||||
cargo install cargo-tarpaulin
|
cargo install cargo-cache --version 0.6.2 --no-default-features --features ci-autoclean
|
||||||
cargo tarpaulin --out Xml --verbose
|
cargo-cache
|
||||||
- name: Upload to Codecov
|
|
||||||
if: >
|
build_and_test_lower_msrv:
|
||||||
matrix.target.os == 'ubuntu-latest'
|
name: Linux / 1.46 (lower MSRV)
|
||||||
&& matrix.version == 'stable'
|
runs-on: ubuntu-latest
|
||||||
&& github.ref == 'refs/heads/master'
|
steps:
|
||||||
uses: codecov/codecov-action@v1
|
- uses: actions/checkout@v2
|
||||||
with: { file: cobertura.xml }
|
|
||||||
|
- name: Install 1.46.0 # MSRV for all but -server and -tls
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: 1.46.0-x86_64-unknown-linux-gnu
|
||||||
|
profile: minimal
|
||||||
|
override: true
|
||||||
|
|
||||||
|
- name: Install cargo-hack
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: install
|
||||||
|
args: cargo-hack
|
||||||
|
|
||||||
|
- name: tests
|
||||||
|
run: cargo ci-test-lower-msrv
|
||||||
|
|
||||||
- name: Clear the cargo caches
|
- name: Clear the cargo caches
|
||||||
run: |
|
run: |
|
||||||
cargo install cargo-cache --version 0.6.2 --no-default-features --features ci-autoclean
|
cargo install cargo-cache --version 0.6.2 --no-default-features --features ci-autoclean
|
||||||
cargo-cache
|
cargo-cache
|
||||||
|
|
||||||
|
coverage:
|
||||||
|
name: coverage
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install Rust (nightly)
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: stable-x86_64-unknown-linux-gnu
|
||||||
|
profile: minimal
|
||||||
|
override: true
|
||||||
|
|
||||||
|
- name: Generate Cargo.lock
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with: { command: generate-lockfile }
|
||||||
|
- name: Cache Dependencies
|
||||||
|
uses: Swatinem/rust-cache@v1.3.0
|
||||||
|
|
||||||
|
- name: Generate coverage file
|
||||||
|
if: github.ref == 'refs/heads/master'
|
||||||
|
run: |
|
||||||
|
cargo install cargo-tarpaulin
|
||||||
|
cargo tarpaulin --out Xml --verbose
|
||||||
|
- name: Upload to Codecov
|
||||||
|
if: github.ref == 'refs/heads/master'
|
||||||
|
uses: codecov/codecov-action@v1
|
||||||
|
with: { file: cobertura.xml }
|
||||||
|
|
||||||
rustdoc:
|
rustdoc:
|
||||||
name: rustdoc
|
name: rustdoc
|
||||||
|
|
|
@ -178,7 +178,7 @@ impl<T, U> Framed<T, U> {
|
||||||
U: Decoder,
|
U: Decoder,
|
||||||
{
|
{
|
||||||
loop {
|
loop {
|
||||||
let mut this = self.as_mut().project();
|
let this = self.as_mut().project();
|
||||||
// Repeatedly call `decode` or `decode_eof` as long as it is "readable". Readable is
|
// Repeatedly call `decode` or `decode_eof` as long as it is "readable". Readable is
|
||||||
// defined as not having returned `None`. If the upstream has returned EOF, and the
|
// defined as not having returned `None`. If the upstream has returned EOF, and the
|
||||||
// decoder is no longer readable, it can be assumed that the decoder will never become
|
// decoder is no longer readable, it can be assumed that the decoder will never become
|
||||||
|
@ -186,7 +186,7 @@ impl<T, U> Framed<T, U> {
|
||||||
|
|
||||||
if this.flags.contains(Flags::READABLE) {
|
if this.flags.contains(Flags::READABLE) {
|
||||||
if this.flags.contains(Flags::EOF) {
|
if this.flags.contains(Flags::EOF) {
|
||||||
match this.codec.decode_eof(&mut this.read_buf) {
|
match this.codec.decode_eof(this.read_buf) {
|
||||||
Ok(Some(frame)) => return Poll::Ready(Some(Ok(frame))),
|
Ok(Some(frame)) => return Poll::Ready(Some(Ok(frame))),
|
||||||
Ok(None) => return Poll::Ready(None),
|
Ok(None) => return Poll::Ready(None),
|
||||||
Err(e) => return Poll::Ready(Some(Err(e))),
|
Err(e) => return Poll::Ready(Some(Err(e))),
|
||||||
|
@ -195,7 +195,7 @@ impl<T, U> Framed<T, U> {
|
||||||
|
|
||||||
log::trace!("attempting to decode a frame");
|
log::trace!("attempting to decode a frame");
|
||||||
|
|
||||||
match this.codec.decode(&mut this.read_buf) {
|
match this.codec.decode(this.read_buf) {
|
||||||
Ok(Some(frame)) => {
|
Ok(Some(frame)) => {
|
||||||
log::trace!("frame decoded from buffer");
|
log::trace!("frame decoded from buffer");
|
||||||
return Poll::Ready(Some(Ok(frame)));
|
return Poll::Ready(Some(Ok(frame)));
|
||||||
|
|
|
@ -3,6 +3,12 @@
|
||||||
## Unreleased - 2021-xx-xx
|
## Unreleased - 2021-xx-xx
|
||||||
|
|
||||||
|
|
||||||
|
## 0.2.3 - 2021-10-19
|
||||||
|
* Fix test macro in presence of other imports named "test". [#399]
|
||||||
|
|
||||||
|
[#399]: https://github.com/actix/actix-net/pull/399
|
||||||
|
|
||||||
|
|
||||||
## 0.2.2 - 2021-10-14
|
## 0.2.2 - 2021-10-14
|
||||||
* Improve error recovery potential when macro input is invalid. [#391]
|
* Improve error recovery potential when macro input is invalid. [#391]
|
||||||
* Allow custom `System`s on test macro. [#391]
|
* Allow custom `System`s on test macro. [#391]
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
[package]
|
[package]
|
||||||
name = "actix-macros"
|
name = "actix-macros"
|
||||||
version = "0.2.2"
|
version = "0.2.3"
|
||||||
authors = [
|
authors = [
|
||||||
"Nikolay Kim <fafhrd91@gmail.com>",
|
"Nikolay Kim <fafhrd91@gmail.com>",
|
||||||
"Ibraheem Ahmed <ibrah1440@gmail.com>",
|
"Ibraheem Ahmed <ibrah1440@gmail.com>",
|
||||||
|
"Rob Ede <robjtede@icloud.com>",
|
||||||
]
|
]
|
||||||
description = "Macros for Actix system and runtime"
|
description = "Macros for Actix system and runtime"
|
||||||
repository = "https://github.com/actix/actix-net.git"
|
repository = "https://github.com/actix/actix-net.git"
|
||||||
|
@ -22,4 +23,5 @@ syn = { version = "^1", features = ["full"] }
|
||||||
actix-rt = "2.0.0"
|
actix-rt = "2.0.0"
|
||||||
|
|
||||||
futures-util = { version = "0.3.7", default-features = false }
|
futures-util = { version = "0.3.7", default-features = false }
|
||||||
|
rustversion = "1"
|
||||||
trybuild = "1"
|
trybuild = "1"
|
||||||
|
|
|
@ -139,9 +139,9 @@ pub fn test(args: TokenStream, item: TokenStream) -> TokenStream {
|
||||||
sig.asyncness = None;
|
sig.asyncness = None;
|
||||||
|
|
||||||
let missing_test_attr = if has_test_attr {
|
let missing_test_attr = if has_test_attr {
|
||||||
quote!()
|
quote! {}
|
||||||
} else {
|
} else {
|
||||||
quote!(#[test])
|
quote! { #[::core::prelude::v1::test] }
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut system = syn::parse_str::<syn::Path>("::actix_rt::System").unwrap();
|
let mut system = syn::parse_str::<syn::Path>("::actix_rt::System").unwrap();
|
||||||
|
@ -198,5 +198,5 @@ pub fn test(args: TokenStream, item: TokenStream) -> TokenStream {
|
||||||
fn input_and_compile_error(mut item: TokenStream, err: syn::Error) -> TokenStream {
|
fn input_and_compile_error(mut item: TokenStream, err: syn::Error) -> TokenStream {
|
||||||
let compile_err = TokenStream::from(err.to_compile_error());
|
let compile_err = TokenStream::from(err.to_compile_error());
|
||||||
item.extend(compile_err);
|
item.extend(compile_err);
|
||||||
return item;
|
item
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#[rustversion::stable(1.46)] // MSRV
|
||||||
#[test]
|
#[test]
|
||||||
fn compile_macros() {
|
fn compile_macros() {
|
||||||
let t = trybuild::TestCases::new();
|
let t = trybuild::TestCases::new();
|
||||||
|
|
|
@ -23,7 +23,7 @@ macros = ["actix-macros"]
|
||||||
io-uring = ["tokio-uring"]
|
io-uring = ["tokio-uring"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-macros = { version = "0.2.0", optional = true }
|
actix-macros = { version = "0.2.3", optional = true }
|
||||||
|
|
||||||
futures-core = { version = "0.3", default-features = false }
|
futures-core = { version = "0.3", default-features = false }
|
||||||
tokio = { version = "1.5.1", features = ["rt", "net", "parking_lot", "signal", "sync", "time"] }
|
tokio = { version = "1.5.1", features = ["rt", "net", "parking_lot", "signal", "sync", "time"] }
|
||||||
|
|
|
@ -155,6 +155,7 @@ impl System {
|
||||||
pub struct SystemRunner {
|
pub struct SystemRunner {
|
||||||
rt: Runtime,
|
rt: Runtime,
|
||||||
stop_rx: oneshot::Receiver<i32>,
|
stop_rx: oneshot::Receiver<i32>,
|
||||||
|
#[allow(dead_code)]
|
||||||
system: System,
|
system: System,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
//! Checks that test macro does not cause problems in the presence of imports named "test" that
|
||||||
|
//! could be either a module with test items or the "test with runtime" macro itself.
|
||||||
|
//!
|
||||||
|
//! Before actix/actix-net#399 was implemented, this macro was running twice. The first run output
|
||||||
|
//! `#[test]` and it got run again and since it was in scope.
|
||||||
|
//!
|
||||||
|
//! Prevented by using the fully-qualified test marker (`#[::core::prelude::v1::test]`).
|
||||||
|
|
||||||
|
#![cfg(feature = "macros")]
|
||||||
|
|
||||||
|
use actix_rt::time as test;
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_naming_conflict() {
|
||||||
|
use test as time;
|
||||||
|
time::sleep(std::time::Duration::from_millis(2)).await;
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
## Unreleased - 2021-xx-xx
|
## Unreleased - 2021-xx-xx
|
||||||
|
* Minimum supported Rust version (MSRV) is now 1.52.
|
||||||
|
|
||||||
|
|
||||||
## 2.0.0-beta.6 - 2021-10-11
|
## 2.0.0-beta.6 - 2021-10-11
|
||||||
|
|
|
@ -32,7 +32,7 @@ num_cpus = "1.13"
|
||||||
tokio = { version = "1.5.1", features = ["sync"] }
|
tokio = { version = "1.5.1", features = ["sync"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-codec = "0.4.0-beta.1"
|
actix-codec = "0.4.0"
|
||||||
actix-rt = "2.0.0"
|
actix-rt = "2.0.0"
|
||||||
|
|
||||||
bytes = "1"
|
bytes = "1"
|
||||||
|
|
|
@ -81,14 +81,9 @@ struct Accept {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Array of u128 with every bit as marker for a worker handle's availability.
|
/// Array of u128 with every bit as marker for a worker handle's availability.
|
||||||
|
#[derive(Debug, Default)]
|
||||||
struct Availability([u128; 4]);
|
struct Availability([u128; 4]);
|
||||||
|
|
||||||
impl Default for Availability {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self([0; 4])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Availability {
|
impl Availability {
|
||||||
/// Check if any worker handle is available
|
/// Check if any worker handle is available
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
|
|
@ -181,6 +181,7 @@ impl WorkerHandleAccept {
|
||||||
/// Held by [ServerBuilder](crate::builder::ServerBuilder).
|
/// Held by [ServerBuilder](crate::builder::ServerBuilder).
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub(crate) struct WorkerHandleServer {
|
pub(crate) struct WorkerHandleServer {
|
||||||
|
#[allow(dead_code)]
|
||||||
idx: usize,
|
idx: usize,
|
||||||
tx: UnboundedSender<Stop>,
|
tx: UnboundedSender<Stop>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
use std::{future::Future, sync::mpsc, time::Duration};
|
||||||
|
|
||||||
|
async fn oracle<F, Fut>(f: F) -> (u32, u32)
|
||||||
|
where
|
||||||
|
F: FnOnce() -> Fut + Clone + Send + 'static,
|
||||||
|
Fut: Future<Output = u32> + 'static,
|
||||||
|
{
|
||||||
|
let f1 = actix_rt::spawn(f.clone()());
|
||||||
|
let f2 = actix_rt::spawn(f());
|
||||||
|
|
||||||
|
(f1.await.unwrap(), f2.await.unwrap())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::main]
|
||||||
|
async fn main() {
|
||||||
|
let (tx, rx) = mpsc::channel();
|
||||||
|
|
||||||
|
let (r1, r2) = oracle({
|
||||||
|
let tx = tx.clone();
|
||||||
|
|
||||||
|
|| async move {
|
||||||
|
tx.send(()).unwrap();
|
||||||
|
4 * 4
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
assert_eq!(r1, r2);
|
||||||
|
|
||||||
|
tx.send(()).unwrap();
|
||||||
|
|
||||||
|
rx.recv_timeout(Duration::from_millis(100)).unwrap();
|
||||||
|
rx.recv_timeout(Duration::from_millis(100)).unwrap();
|
||||||
|
}
|
|
@ -52,9 +52,9 @@ pub fn fn_factory<F, Cfg, Srv, Req, Fut, Err>(
|
||||||
f: F,
|
f: F,
|
||||||
) -> FnServiceNoConfig<F, Cfg, Srv, Req, Fut, Err>
|
) -> FnServiceNoConfig<F, Cfg, Srv, Req, Fut, Err>
|
||||||
where
|
where
|
||||||
Srv: Service<Req>,
|
|
||||||
F: Fn() -> Fut,
|
F: Fn() -> Fut,
|
||||||
Fut: Future<Output = Result<Srv, Err>>,
|
Fut: Future<Output = Result<Srv, Err>>,
|
||||||
|
Srv: Service<Req>,
|
||||||
{
|
{
|
||||||
FnServiceNoConfig::new(f)
|
FnServiceNoConfig::new(f)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,14 +3,22 @@
|
||||||
## Unreleased - 2021-xx-xx
|
## Unreleased - 2021-xx-xx
|
||||||
|
|
||||||
|
|
||||||
|
## 3.0.0-beta.6 - 2021-10-19
|
||||||
|
* Update `tokio-rustls` to `0.23` which uses `rustls` `0.20`. [#396]
|
||||||
|
* Removed a re-export of `Session` from `rustls` as it no longer exist. [#396]
|
||||||
|
* Minimum supported Rust version (MSRV) is now 1.52.
|
||||||
|
|
||||||
|
[#396]: https://github.com/actix/actix-net/pull/396
|
||||||
|
|
||||||
|
|
||||||
## 3.0.0-beta.5 - 2021-03-29
|
## 3.0.0-beta.5 - 2021-03-29
|
||||||
* Changed `connect::ssl::rustls::RustlsConnectorService` to return error when `DNSNameRef`
|
* Changed `connect::ssl::rustls::RustlsConnectorService` to return error when `DNSNameRef`
|
||||||
generation failed instead of panic. [#296]
|
generation failed instead of panic. [#296]
|
||||||
* Remove `connect::ssl::openssl::OpensslConnectServiceFactory`. [#297]
|
* Remove `connect::ssl::openssl::OpensslConnectServiceFactory`. [#297]
|
||||||
* Remove `connect::ssl::openssl::OpensslConnectService`. [#297]
|
* Remove `connect::ssl::openssl::OpensslConnectService`. [#297]
|
||||||
* Add `connect::ssl::native_tls` module for native tls support. [#295]
|
* Add `connect::ssl::native_tls` module for native tls support. [#295]
|
||||||
* Rename `accept::{nativetls => native_tls}`. [#295]
|
* Rename `accept::{nativetls => native_tls}`. [#295]
|
||||||
* Remove `connect::TcpConnectService` type. service caller expect a `TcpStream` should use
|
* Remove `connect::TcpConnectService` type. service caller expect a `TcpStream` should use
|
||||||
`connect::ConnectService` instead and call `Connection<T, TcpStream>::into_parts`. [#299]
|
`connect::ConnectService` instead and call `Connection<T, TcpStream>::into_parts`. [#299]
|
||||||
|
|
||||||
[#295]: https://github.com/actix/actix-net/pull/295
|
[#295]: https://github.com/actix/actix-net/pull/295
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
[package]
|
[package]
|
||||||
name = "actix-tls"
|
name = "actix-tls"
|
||||||
version = "3.0.0-beta.5"
|
version = "3.0.0-beta.6"
|
||||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||||
description = "TLS acceptor and connector services for Actix ecosystem"
|
description = "TLS acceptor and connector services for Actix ecosystem"
|
||||||
keywords = ["network", "tls", "ssl", "async", "transport"]
|
keywords = ["network", "tls", "ssl", "async", "transport"]
|
||||||
homepage = "https://actix.rs"
|
|
||||||
repository = "https://github.com/actix/actix-net.git"
|
repository = "https://github.com/actix/actix-net.git"
|
||||||
documentation = "https://docs.rs/actix-tls"
|
|
||||||
categories = ["network-programming", "asynchronous"]
|
categories = ["network-programming", "asynchronous"]
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
@ -40,7 +38,7 @@ native-tls = ["tokio-native-tls"]
|
||||||
uri = ["http"]
|
uri = ["http"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-codec = "0.4.0-beta.1"
|
actix-codec = "0.4.0"
|
||||||
actix-rt = { version = "2.2.0", default-features = false }
|
actix-rt = { version = "2.2.0", default-features = false }
|
||||||
actix-service = "2.0.0"
|
actix-service = "2.0.0"
|
||||||
actix-utils = "3.0.0"
|
actix-utils = "3.0.0"
|
||||||
|
@ -56,7 +54,7 @@ tls-openssl = { package = "openssl", version = "0.10.9", optional = true }
|
||||||
tokio-openssl = { version = "0.6", optional = true }
|
tokio-openssl = { version = "0.6", optional = true }
|
||||||
|
|
||||||
# rustls
|
# rustls
|
||||||
tokio-rustls = { version = "0.22", optional = true }
|
tokio-rustls = { version = "0.23", optional = true }
|
||||||
webpki-roots = { version = "0.21", optional = true }
|
webpki-roots = { version = "0.21", optional = true }
|
||||||
|
|
||||||
# native-tls
|
# native-tls
|
||||||
|
@ -69,6 +67,7 @@ bytes = "1"
|
||||||
env_logger = "0.8"
|
env_logger = "0.8"
|
||||||
futures-util = { version = "0.3.7", default-features = false, features = ["sink"] }
|
futures-util = { version = "0.3.7", default-features = false, features = ["sink"] }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
rustls-pemfile = "0.2.1"
|
||||||
trust-dns-resolver = "0.20.0"
|
trust-dns-resolver = "0.20.0"
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
|
|
|
@ -35,25 +35,29 @@ use actix_service::ServiceFactoryExt as _;
|
||||||
use actix_tls::accept::rustls::{Acceptor as RustlsAcceptor, TlsStream};
|
use actix_tls::accept::rustls::{Acceptor as RustlsAcceptor, TlsStream};
|
||||||
use futures_util::future::ok;
|
use futures_util::future::ok;
|
||||||
use log::info;
|
use log::info;
|
||||||
use rustls::{
|
use rustls::{server::ServerConfig, Certificate, PrivateKey};
|
||||||
internal::pemfile::certs, internal::pemfile::rsa_private_keys, NoClientAuth, ServerConfig,
|
use rustls_pemfile::{certs, rsa_private_keys};
|
||||||
};
|
|
||||||
|
|
||||||
#[actix_rt::main]
|
#[actix_rt::main]
|
||||||
async fn main() -> io::Result<()> {
|
async fn main() -> io::Result<()> {
|
||||||
env::set_var("RUST_LOG", "info");
|
env::set_var("RUST_LOG", "info");
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
|
|
||||||
let mut tls_config = ServerConfig::new(NoClientAuth::new());
|
|
||||||
|
|
||||||
// Load TLS key and cert files
|
// Load TLS key and cert files
|
||||||
let cert_file = &mut BufReader::new(File::open("./examples/cert.pem").unwrap());
|
let cert_file = &mut BufReader::new(File::open("./examples/cert.pem").unwrap());
|
||||||
let key_file = &mut BufReader::new(File::open("./examples/key.pem").unwrap());
|
let key_file = &mut BufReader::new(File::open("./examples/key.pem").unwrap());
|
||||||
|
|
||||||
let cert_chain = certs(cert_file).unwrap();
|
let cert_chain = certs(cert_file)
|
||||||
|
.unwrap()
|
||||||
|
.into_iter()
|
||||||
|
.map(Certificate)
|
||||||
|
.collect();
|
||||||
let mut keys = rsa_private_keys(key_file).unwrap();
|
let mut keys = rsa_private_keys(key_file).unwrap();
|
||||||
tls_config
|
|
||||||
.set_single_cert(cert_chain, keys.remove(0))
|
let tls_config = ServerConfig::builder()
|
||||||
|
.with_safe_defaults()
|
||||||
|
.with_no_client_auth()
|
||||||
|
.with_single_cert(cert_chain, PrivateKey(keys.remove(0)))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let tls_acceptor = RustlsAcceptor::new(tls_config);
|
let tls_acceptor = RustlsAcceptor::new(tls_config);
|
||||||
|
|
|
@ -14,7 +14,7 @@ use actix_utils::counter::{Counter, CounterGuard};
|
||||||
use futures_core::future::LocalBoxFuture;
|
use futures_core::future::LocalBoxFuture;
|
||||||
use tokio_rustls::{Accept, TlsAcceptor};
|
use tokio_rustls::{Accept, TlsAcceptor};
|
||||||
|
|
||||||
pub use tokio_rustls::rustls::{ServerConfig, Session};
|
pub use tokio_rustls::rustls::ServerConfig;
|
||||||
|
|
||||||
use super::MAX_CONN_COUNTER;
|
use super::MAX_CONN_COUNTER;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use std::{
|
use std::{
|
||||||
|
convert::TryFrom,
|
||||||
future::Future,
|
future::Future,
|
||||||
io,
|
io,
|
||||||
pin::Pin,
|
pin::Pin,
|
||||||
|
@ -6,7 +7,6 @@ use std::{
|
||||||
task::{Context, Poll},
|
task::{Context, Poll},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use tokio_rustls::rustls::Session;
|
|
||||||
pub use tokio_rustls::{client::TlsStream, rustls::ClientConfig};
|
pub use tokio_rustls::{client::TlsStream, rustls::ClientConfig};
|
||||||
pub use webpki_roots::TLS_SERVER_ROOTS;
|
pub use webpki_roots::TLS_SERVER_ROOTS;
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ use actix_rt::net::ActixStream;
|
||||||
use actix_service::{Service, ServiceFactory};
|
use actix_service::{Service, ServiceFactory};
|
||||||
use futures_core::{future::LocalBoxFuture, ready};
|
use futures_core::{future::LocalBoxFuture, ready};
|
||||||
use log::trace;
|
use log::trace;
|
||||||
use tokio_rustls::webpki::DNSNameRef;
|
use tokio_rustls::rustls::client::ServerName;
|
||||||
use tokio_rustls::{Connect, TlsConnector};
|
use tokio_rustls::{Connect, TlsConnector};
|
||||||
|
|
||||||
use crate::connect::{Address, Connection};
|
use crate::connect::{Address, Connection};
|
||||||
|
@ -89,7 +89,7 @@ where
|
||||||
trace!("SSL Handshake start for: {:?}", connection.host());
|
trace!("SSL Handshake start for: {:?}", connection.host());
|
||||||
let (stream, connection) = connection.replace_io(());
|
let (stream, connection) = connection.replace_io(());
|
||||||
|
|
||||||
match DNSNameRef::try_from_ascii_str(connection.host()) {
|
match ServerName::try_from(connection.host()) {
|
||||||
Ok(host) => RustlsConnectorServiceFuture::Future {
|
Ok(host) => RustlsConnectorServiceFuture::Future {
|
||||||
connect: TlsConnector::from(self.connector.clone()).connect(host, stream),
|
connect: TlsConnector::from(self.connector.clone()).connect(host, stream),
|
||||||
connection: Some(connection),
|
connection: Some(connection),
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
msrv = "1.48"
|
Loading…
Reference in New Issue