1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-27 17:52:56 +01:00

tweak feature flags

This commit is contained in:
Rob Ede 2021-02-07 03:54:58 +00:00
parent 830fb2cdb2
commit 9eaea6a2fd
No known key found for this signature in database
GPG Key ID: C2A3B36E841A91E6
16 changed files with 73 additions and 44 deletions

View File

@ -47,10 +47,10 @@ compress = ["actix-http/compress", "awc/compress"]
secure-cookies = ["actix-http/secure-cookies"] secure-cookies = ["actix-http/secure-cookies"]
# openssl # openssl
openssl = ["actix-tls/accept", "actix-tls/openssl", "awc/openssl", "open-ssl"] openssl = ["tls_openssl", "actix-tls/accept", "actix-tls/openssl", "awc/openssl"]
# rustls # rustls
rustls = ["actix-tls/accept", "actix-tls/rustls", "awc/rustls", "rust-tls"] rustls = ["tls_rustls", "actix-tls/accept", "actix-tls/rustls", "awc/rustls"]
[[example]] [[example]]
name = "basic" name = "basic"
@ -86,7 +86,7 @@ actix-web-codegen = "0.4.0"
actix-http = "3.0.0-beta.1" actix-http = "3.0.0-beta.1"
awc = { version = "3.0.0-beta.1", default-features = false } awc = { version = "3.0.0-beta.1", default-features = false }
ahash = "0.6" ahash = "0.7"
bytes = "1" bytes = "1"
derive_more = "0.99.5" derive_more = "0.99.5"
either = "1.5.3" either = "1.5.3"
@ -101,10 +101,10 @@ regex = "1.4"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0" serde_json = "1.0"
serde_urlencoded = "0.7" serde_urlencoded = "0.7"
time = { version = "0.2.7", default-features = false, features = ["std"] } time = { version = "0.2.23", default-features = false, features = ["std"] }
url = "2.1" url = "2.1"
open-ssl = { package = "openssl", version = "0.10", optional = true } tls_openssl = { package = "openssl", version = "0.10.9", optional = true }
rust-tls = { package = "rustls", version = "0.19.0", optional = true } tls_rustls = { package = "rustls", version = "0.19.0", optional = true }
smallvec = "1.6" smallvec = "1.6"
[dev-dependencies] [dev-dependencies]

View File

@ -11,10 +11,9 @@
![License](https://img.shields.io/crates/l/actix-web.svg) ![License](https://img.shields.io/crates/l/actix-web.svg)
[![Dependency Status](https://deps.rs/crate/actix-web/3.3.2/status.svg)](https://deps.rs/crate/actix-web/3.3.2) [![Dependency Status](https://deps.rs/crate/actix-web/3.3.2/status.svg)](https://deps.rs/crate/actix-web/3.3.2)
<br /> <br />
[![Build Status](https://travis-ci.org/actix/actix-web.svg?branch=master)](https://travis-ci.org/actix/actix-web) [![build status](https://github.com/actix/actix-web/workflows/CI%20%28Linux%29/badge.svg?branch=master&event=push)](https://github.com/actix/actix-web/actions)
[![codecov](https://codecov.io/gh/actix/actix-web/branch/master/graph/badge.svg)](https://codecov.io/gh/actix/actix-web) [![codecov](https://codecov.io/gh/actix/actix-web/branch/master/graph/badge.svg)](https://codecov.io/gh/actix/actix-web)
[![Download](https://img.shields.io/crates/d/actix-web.svg)](https://crates.io/crates/actix-web) ![downloads](https://img.shields.io/crates/d/actix-web.svg)
[![Join the chat at https://gitter.im/actix/actix](https://badges.gitter.im/actix/actix.svg)](https://gitter.im/actix/actix?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x)
</p> </p>
@ -99,9 +98,9 @@ One of the fastest web frameworks available according to the
This project is licensed under either of This project is licensed under either of
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)) [http://www.apache.org/licenses/LICENSE-2.0])
* MIT license ([LICENSE-MIT](LICENSE-MIT) or * MIT license ([LICENSE-MIT](LICENSE-MIT) or
[http://opensource.org/licenses/MIT](http://opensource.org/licenses/MIT)) [http://opensource.org/licenses/MIT])
at your option. at your option.

View File

@ -26,7 +26,7 @@ path = "src/lib.rs"
default = [] default = []
# openssl # openssl
openssl = ["open-ssl", "awc/openssl"] openssl = ["tls-openssl", "awc/openssl"]
[dependencies] [dependencies]
actix-service = "2.0.0-beta.4" actix-service = "2.0.0-beta.4"
@ -47,8 +47,8 @@ serde = "1.0"
serde_json = "1.0" serde_json = "1.0"
slab = "0.4" slab = "0.4"
serde_urlencoded = "0.7" serde_urlencoded = "0.7"
time = { version = "0.2.7", default-features = false, features = ["std"] } time = { version = "0.2.23", default-features = false, features = ["std"] }
open-ssl = { version = "0.10", package = "openssl", optional = true } tls-openssl = { version = "0.10.9", package = "openssl", optional = true }
[dev-dependencies] [dev-dependencies]
actix-web = "4.0.0-beta.1" actix-web = "4.0.0-beta.1"

View File

@ -4,6 +4,9 @@
#![doc(html_logo_url = "https://actix.rs/img/logo.png")] #![doc(html_logo_url = "https://actix.rs/img/logo.png")]
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")] #![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
#[cfg(feature = "openssl")]
extern crate tls_openssl as openssl;
use std::sync::mpsc; use std::sync::mpsc;
use std::{net, thread, time}; use std::{net, thread, time};
@ -82,7 +85,7 @@ pub async fn test_server_with_addr<F: ServiceFactory<TcpStream>>(
let connector = { let connector = {
#[cfg(feature = "openssl")] #[cfg(feature = "openssl")]
{ {
use open_ssl::ssl::{SslConnector, SslMethod, SslVerifyMode}; use openssl::ssl::{SslConnector, SslMethod, SslVerifyMode};
let mut builder = SslConnector::builder(SslMethod::tls()).unwrap(); let mut builder = SslConnector::builder(SslMethod::tls()).unwrap();
builder.set_verify(SslVerifyMode::NONE); builder.set_verify(SslVerifyMode::NONE);

View File

@ -58,7 +58,7 @@ encoding_rs = "0.8"
futures-channel = { version = "0.3.7", default-features = false, features = ["alloc"] } futures-channel = { version = "0.3.7", default-features = false, features = ["alloc"] }
futures-core = { version = "0.3.7", default-features = false, features = ["alloc"] } futures-core = { version = "0.3.7", default-features = false, features = ["alloc"] }
futures-util = { version = "0.3.7", default-features = false, features = ["alloc", "sink"] } futures-util = { version = "0.3.7", default-features = false, features = ["alloc", "sink"] }
ahash = "0.6" ahash = "0.7"
h2 = "0.3.0" h2 = "0.3.0"
http = "0.2.2" http = "0.2.2"
httparse = "1.3" httparse = "1.3"
@ -78,7 +78,7 @@ sha-1 = "0.9"
smallvec = "1.6" smallvec = "1.6"
slab = "0.4" slab = "0.4"
serde_urlencoded = "0.7" serde_urlencoded = "0.7"
time = { version = "0.2.7", default-features = false, features = ["std"] } time = { version = "0.2.23", default-features = false, features = ["std"] }
# compression # compression
brotli2 = { version="0.3.2", optional = true } brotli2 = { version="0.3.2", optional = true }
@ -89,10 +89,10 @@ actix-server = "2.0.0-beta.3"
actix-http-test = { version = "3.0.0-beta.1", features = ["openssl"] } actix-http-test = { version = "3.0.0-beta.1", features = ["openssl"] }
actix-tls = { version = "3.0.0-beta.2", features = ["openssl"] } actix-tls = { version = "3.0.0-beta.2", features = ["openssl"] }
criterion = "0.3" criterion = "0.3"
env_logger = "0.7" env_logger = "0.8"
serde_derive = "1.0" serde_derive = "1.0"
open-ssl = { version="0.10", package = "openssl" } tls-openssl = { version = "0.10", package = "openssl" }
rust-tls = { version="0.19", package = "rustls" } tls-rustls = { version = "0.19", package = "rustls" }
[[bench]] [[bench]]
name = "write-camel-case" name = "write-camel-case"

View File

@ -1,4 +1,7 @@
#![cfg(feature = "openssl")] #![cfg(feature = "openssl")]
extern crate tls_openssl as openssl;
use std::io; use std::io;
use actix_http::error::{ErrorBadRequest, PayloadError}; use actix_http::error::{ErrorBadRequest, PayloadError};
@ -11,7 +14,7 @@ use actix_service::{fn_service, ServiceFactoryExt};
use bytes::{Bytes, BytesMut}; use bytes::{Bytes, BytesMut};
use futures_util::future::{err, ok, ready}; use futures_util::future::{err, ok, ready};
use futures_util::stream::{once, Stream, StreamExt}; use futures_util::stream::{once, Stream, StreamExt};
use open_ssl::ssl::{AlpnError, SslAcceptor, SslFiletype, SslMethod}; use openssl::ssl::{AlpnError, SslAcceptor, SslFiletype, SslMethod};
async fn load_body<S>(stream: S) -> Result<BytesMut, PayloadError> async fn load_body<S>(stream: S) -> Result<BytesMut, PayloadError>
where where

View File

@ -1,4 +1,7 @@
#![cfg(feature = "rustls")] #![cfg(feature = "rustls")]
extern crate tls_rustls as rustls;
use actix_http::error::PayloadError; use actix_http::error::PayloadError;
use actix_http::http::header::{self, HeaderName, HeaderValue}; use actix_http::http::header::{self, HeaderName, HeaderValue};
use actix_http::http::{Method, StatusCode, Version}; use actix_http::http::{Method, StatusCode, Version};
@ -9,7 +12,7 @@ use actix_service::{fn_factory_with_config, fn_service};
use bytes::{Bytes, BytesMut}; use bytes::{Bytes, BytesMut};
use futures_util::future::{self, err, ok}; use futures_util::future::{self, err, ok};
use futures_util::stream::{once, Stream, StreamExt}; use futures_util::stream::{once, Stream, StreamExt};
use rust_tls::{ use rustls::{
internal::pemfile::{certs, pkcs8_private_keys}, internal::pemfile::{certs, pkcs8_private_keys},
NoClientAuth, ServerConfig as RustlsServerConfig, NoClientAuth, ServerConfig as RustlsServerConfig,
}; };

View File

@ -29,5 +29,5 @@ tokio = { version = "1", features = ["sync"] }
[dev-dependencies] [dev-dependencies]
actix-rt = "2" actix-rt = "2"
env_logger = "0.7" env_logger = "0.8"
futures-util = { version = "0.3.7", default-features = false } futures-util = { version = "0.3.7", default-features = false }

View File

@ -28,10 +28,10 @@ features = ["openssl", "rustls", "compress"]
default = ["compress"] default = ["compress"]
# openssl # openssl
openssl = ["open-ssl", "actix-http/openssl"] openssl = ["tls-openssl", "actix-http/openssl"]
# rustls # rustls
rustls = ["rust-tls", "actix-http/rustls"] rustls = ["tls-rustls", "actix-http/rustls"]
# content-encoding support # content-encoding support
compress = ["actix-http/compress"] compress = ["actix-http/compress"]
@ -54,8 +54,8 @@ rand = "0.8"
serde = "1.0" serde = "1.0"
serde_json = "1.0" serde_json = "1.0"
serde_urlencoded = "0.7" serde_urlencoded = "0.7"
open-ssl = { version = "0.10", package = "openssl", optional = true } tls-openssl = { version = "0.10.9", package = "openssl", optional = true }
rust-tls = { version = "0.19.0", package = "rustls", optional = true, features = ["dangerous_configuration"] } tls-rustls = { version = "0.19.0", package = "rustls", optional = true, features = ["dangerous_configuration"] }
[dev-dependencies] [dev-dependencies]
actix-web = { version = "4.0.0-beta.1", features = ["openssl"] } actix-web = { version = "4.0.0-beta.1", features = ["openssl"] }
@ -68,6 +68,6 @@ actix-tls = { version = "3.0.0-beta.3", features = ["openssl", "rustls"] }
brotli2 = "0.3.2" brotli2 = "0.3.2"
flate2 = "1.0.13" flate2 = "1.0.13"
futures-util = { version = "0.3.7", default-features = false } futures-util = { version = "0.3.7", default-features = false }
env_logger = "0.7" env_logger = "0.8"
rcgen = "0.8" rcgen = "0.8"
webpki = "0.21" webpki = "0.21"

View File

@ -1,10 +1,13 @@
#![cfg(feature = "openssl")] #![cfg(feature = "openssl")]
extern crate tls_openssl as openssl;
use actix_http::HttpService; use actix_http::HttpService;
use actix_http_test::test_server; use actix_http_test::test_server;
use actix_service::{map_config, ServiceFactoryExt}; use actix_service::{map_config, ServiceFactoryExt};
use actix_web::http::Version; use actix_web::http::Version;
use actix_web::{dev::AppConfig, web, App, HttpResponse}; use actix_web::{dev::AppConfig, web, App, HttpResponse};
use open_ssl::ssl::{SslAcceptor, SslConnector, SslFiletype, SslMethod, SslVerifyMode}; use openssl::ssl::{SslAcceptor, SslConnector, SslFiletype, SslMethod, SslVerifyMode};
fn ssl_acceptor() -> SslAcceptor { fn ssl_acceptor() -> SslAcceptor {
// load ssl keys // load ssl keys
@ -20,7 +23,7 @@ fn ssl_acceptor() -> SslAcceptor {
if protos.windows(3).any(|window| window == H2) { if protos.windows(3).any(|window| window == H2) {
Ok(b"h2") Ok(b"h2")
} else { } else {
Err(open_ssl::ssl::AlpnError::NOACK) Err(openssl::ssl::AlpnError::NOACK)
} }
}); });
builder.set_alpn_protos(b"\x02h2").unwrap(); builder.set_alpn_protos(b"\x02h2").unwrap();

View File

@ -1,6 +1,6 @@
#![cfg(feature = "rustls")] #![cfg(feature = "rustls")]
extern crate rust_tls as rustls; extern crate tls_rustls as rustls;
use std::{ use std::{
io::BufReader, io::BufReader,

View File

@ -1,4 +1,7 @@
#![cfg(feature = "openssl")] #![cfg(feature = "openssl")]
extern crate tls_openssl as openssl;
use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc; use std::sync::Arc;
@ -8,7 +11,7 @@ use actix_service::{map_config, pipeline_factory, ServiceFactoryExt};
use actix_web::http::Version; use actix_web::http::Version;
use actix_web::{dev::AppConfig, web, App, HttpResponse}; use actix_web::{dev::AppConfig, web, App, HttpResponse};
use futures_util::future::ok; use futures_util::future::ok;
use open_ssl::ssl::{SslAcceptor, SslConnector, SslFiletype, SslMethod, SslVerifyMode}; use openssl::ssl::{SslAcceptor, SslConnector, SslFiletype, SslMethod, SslVerifyMode};
fn ssl_acceptor() -> SslAcceptor { fn ssl_acceptor() -> SslAcceptor {
// load ssl keys // load ssl keys
@ -24,7 +27,7 @@ fn ssl_acceptor() -> SslAcceptor {
if protos.windows(3).any(|window| window == H2) { if protos.windows(3).any(|window| window == H2) {
Ok(b"h2") Ok(b"h2")
} else { } else {
Err(open_ssl::ssl::AlpnError::NOACK) Err(openssl::ssl::AlpnError::NOACK)
} }
}); });
builder.set_alpn_protos(b"\x02h2").unwrap(); builder.set_alpn_protos(b"\x02h2").unwrap();

View File

@ -71,6 +71,11 @@
#![doc(html_logo_url = "https://actix.rs/img/logo.png")] #![doc(html_logo_url = "https://actix.rs/img/logo.png")]
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")] #![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
#[cfg(feature = "openssl")]
extern crate tls_openssl as openssl;
#[cfg(feature = "rustls")]
extern crate tls_rustls as rustls;
mod app; mod app;
mod app_service; mod app_service;
mod config; mod config;

View File

@ -773,7 +773,7 @@ where
let connector = { let connector = {
#[cfg(feature = "openssl")] #[cfg(feature = "openssl")]
{ {
use open_ssl::ssl::{SslConnector, SslMethod, SslVerifyMode}; use openssl::ssl::{SslConnector, SslMethod, SslVerifyMode};
let mut builder = SslConnector::builder(SslMethod::tls()).unwrap(); let mut builder = SslConnector::builder(SslMethod::tls()).unwrap();
builder.set_verify(SslVerifyMode::NONE); builder.set_verify(SslVerifyMode::NONE);
@ -825,9 +825,9 @@ enum HttpVer {
enum StreamType { enum StreamType {
Tcp, Tcp,
#[cfg(feature = "openssl")] #[cfg(feature = "openssl")]
Openssl(open_ssl::ssl::SslAcceptor), Openssl(openssl::ssl::SslAcceptor),
#[cfg(feature = "rustls")] #[cfg(feature = "rustls")]
Rustls(rust_tls::ServerConfig), Rustls(rustls::ServerConfig),
} }
impl Default for TestServerConfig { impl Default for TestServerConfig {
@ -865,14 +865,14 @@ impl TestServerConfig {
/// Start openssl server /// Start openssl server
#[cfg(feature = "openssl")] #[cfg(feature = "openssl")]
pub fn openssl(mut self, acceptor: open_ssl::ssl::SslAcceptor) -> Self { pub fn openssl(mut self, acceptor: openssl::ssl::SslAcceptor) -> Self {
self.stream = StreamType::Openssl(acceptor); self.stream = StreamType::Openssl(acceptor);
self self
} }
/// Start rustls server /// Start rustls server
#[cfg(feature = "rustls")] #[cfg(feature = "rustls")]
pub fn rustls(mut self, config: rust_tls::ServerConfig) -> Self { pub fn rustls(mut self, config: rustls::ServerConfig) -> Self {
self.stream = StreamType::Rustls(config); self.stream = StreamType::Rustls(config);
self self
} }

View File

@ -2,7 +2,12 @@ use std::sync::mpsc;
use std::{thread, time::Duration}; use std::{thread, time::Duration};
#[cfg(feature = "openssl")] #[cfg(feature = "openssl")]
use open_ssl::ssl::SslAcceptorBuilder; extern crate tls_openssl as openssl;
#[cfg(feature = "rustls")]
extern crate tls_rustls as rustls;
#[cfg(feature = "openssl")]
use openssl::ssl::SslAcceptorBuilder;
use actix_web::{test, web, App, HttpResponse, HttpServer}; use actix_web::{test, web, App, HttpResponse, HttpServer};
@ -70,7 +75,7 @@ async fn test_start() {
#[allow(clippy::unnecessary_wraps)] #[allow(clippy::unnecessary_wraps)]
#[cfg(feature = "openssl")] #[cfg(feature = "openssl")]
fn ssl_acceptor() -> std::io::Result<SslAcceptorBuilder> { fn ssl_acceptor() -> std::io::Result<SslAcceptorBuilder> {
use open_ssl::ssl::{SslAcceptor, SslFiletype, SslMethod}; use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
// load ssl keys // load ssl keys
let mut builder = SslAcceptor::mozilla_intermediate(SslMethod::tls()).unwrap(); let mut builder = SslAcceptor::mozilla_intermediate(SslMethod::tls()).unwrap();
builder builder
@ -116,7 +121,7 @@ async fn test_start_ssl() {
}); });
let (srv, sys) = rx.recv().unwrap(); let (srv, sys) = rx.recv().unwrap();
use open_ssl::ssl::{SslConnector, SslMethod, SslVerifyMode}; use openssl::ssl::{SslConnector, SslMethod, SslVerifyMode};
let mut builder = SslConnector::builder(SslMethod::tls()).unwrap(); let mut builder = SslConnector::builder(SslMethod::tls()).unwrap();
builder.set_verify(SslVerifyMode::NONE); builder.set_verify(SslVerifyMode::NONE);
let _ = builder let _ = builder

View File

@ -1,3 +1,8 @@
#[cfg(feature = "openssl")]
extern crate tls_openssl as openssl;
#[cfg(feature = "rustls")]
extern crate tls_rustls as rustls;
use std::{ use std::{
future::Future, future::Future,
io::{Read, Write}, io::{Read, Write},
@ -713,7 +718,7 @@ async fn test_brotli_encoding_large() {
#[actix_rt::test] #[actix_rt::test]
async fn test_brotli_encoding_large_openssl() { async fn test_brotli_encoding_large_openssl() {
// load ssl keys // load ssl keys
use open_ssl::ssl::{SslAcceptor, SslFiletype, SslMethod}; use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
let mut builder = SslAcceptor::mozilla_intermediate(SslMethod::tls()).unwrap(); let mut builder = SslAcceptor::mozilla_intermediate(SslMethod::tls()).unwrap();
builder builder
.set_private_key_file("tests/key.pem", SslFiletype::PEM) .set_private_key_file("tests/key.pem", SslFiletype::PEM)
@ -753,8 +758,8 @@ async fn test_brotli_encoding_large_openssl() {
#[cfg(all(feature = "rustls", feature = "openssl"))] #[cfg(all(feature = "rustls", feature = "openssl"))]
#[actix_rt::test] #[actix_rt::test]
async fn test_reading_deflate_encoding_large_random_rustls() { async fn test_reading_deflate_encoding_large_random_rustls() {
use rust_tls::internal::pemfile::{certs, pkcs8_private_keys}; use rustls::internal::pemfile::{certs, pkcs8_private_keys};
use rust_tls::{NoClientAuth, ServerConfig}; use rustls::{NoClientAuth, ServerConfig};
use std::fs::File; use std::fs::File;
use std::io::BufReader; use std::io::BufReader;