Skip to content

Commit

Permalink
Rename feature tls to openssl.
Browse files Browse the repository at this point in the history
  • Loading branch information
0rangeFox committed Jun 17, 2024
1 parent d0bdfdc commit 69366fd
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion actix-settings/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Unreleased

- Use new feature named `tls` for TLS settings. [#380]
- Add new feature named `openssl` for TLS settings using `OpenSSL` dependency. [#380]
- Add new function `settings::tls::Tls::get_ssl_acceptor_builder()` to build `openssl::ssl::SslAcceptorBuilder`. [#380]
- Implement TLS logic for `ApplySettings<S>::try_apply_settings()`. [#380]
- Add `openssl` dependency;
Expand Down
2 changes: 1 addition & 1 deletion actix-settings/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ rust-version.workspace = true
rustdoc-args = ["--cfg", "docsrs"]

[features]
tls = ["openssl", "actix-web/openssl"]
openssl = ["dep:openssl", "actix-web/openssl"]

[dependencies]
actix-http = "3"
Expand Down
8 changes: 4 additions & 4 deletions actix-settings/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{env::VarError, io, num::ParseIntError, path::PathBuf, str::ParseBoolError};

use derive_more::{Display, Error};
#[cfg(feature = "tls")]
#[cfg(feature = "openssl")]
use openssl::error::ErrorStack as OpenSSLError;
use toml::de::Error as TomlError;

Expand Down Expand Up @@ -32,7 +32,7 @@ pub enum Error {
IoError(io::Error),

/// OpenSSL Error.
#[cfg(feature = "tls")]
#[cfg(feature = "openssl")]
#[display(fmt = "OpenSSL error: {_0}")]
OpenSSLError(OpenSSLError),

Expand Down Expand Up @@ -71,7 +71,7 @@ impl From<io::Error> for Error {
}
}

#[cfg(feature = "tls")]
#[cfg(feature = "openssl")]
impl From<OpenSSLError> for Error {
fn from(err: OpenSSLError) -> Self {
Self::OpenSSLError(err)
Expand Down Expand Up @@ -115,7 +115,7 @@ impl From<Error> for io::Error {

Error::IoError(io_error) => io_error,

#[cfg(feature = "tls")]
#[cfg(feature = "openssl")]
Error::OpenSSLError(ossl_error) => io::Error::new(io::ErrorKind::Other, ossl_error),

Error::ParseBoolError(_) => {
Expand Down
18 changes: 9 additions & 9 deletions actix-settings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ mod error;
mod parse;
mod settings;

#[cfg(feature = "tls")]
#[cfg(feature = "openssl")]
pub use self::settings::Tls;
pub use self::{
error::Error,
Expand Down Expand Up @@ -268,7 +268,7 @@ where

fn try_apply_settings(mut self, settings: &ActixSettings) -> AsResult<Self> {
for Address { host, port } in &settings.hosts {
#[cfg(feature = "tls")]
#[cfg(feature = "openssl")]
{
if settings.tls.enabled {
self = self.bind_openssl(
Expand All @@ -280,7 +280,7 @@ where
}
}

#[cfg(not(feature = "tls"))]
#[cfg(not(feature = "openssl"))]
{
self = self.bind(format!("{host}:{port}"))?;
}
Expand Down Expand Up @@ -683,7 +683,7 @@ mod tests {
assert_eq!(settings.actix.shutdown_timeout, Timeout::Seconds(42));
}

#[cfg(feature = "tls")]
#[cfg(feature = "openssl")]
#[test]
fn override_field_tls_enabled() {
let mut settings = Settings::from_default_template();
Expand All @@ -692,7 +692,7 @@ mod tests {
assert!(settings.actix.tls.enabled);
}

#[cfg(feature = "tls")]
#[cfg(feature = "openssl")]
#[test]
fn override_field_with_env_var_tls_enabled() {
let mut settings = Settings::from_default_template();
Expand All @@ -706,7 +706,7 @@ mod tests {
assert!(settings.actix.tls.enabled);
}

#[cfg(feature = "tls")]
#[cfg(feature = "openssl")]
#[test]
fn override_field_tls_certificate() {
let mut settings = Settings::from_default_template();
Expand All @@ -725,7 +725,7 @@ mod tests {
);
}

#[cfg(feature = "tls")]
#[cfg(feature = "openssl")]
#[test]
fn override_field_with_env_var_tls_certificate() {
let mut settings = Settings::from_default_template();
Expand All @@ -748,7 +748,7 @@ mod tests {
);
}

#[cfg(feature = "tls")]
#[cfg(feature = "openssl")]
#[test]
fn override_field_tls_private_key() {
let mut settings = Settings::from_default_template();
Expand All @@ -767,7 +767,7 @@ mod tests {
);
}

#[cfg(feature = "tls")]
#[cfg(feature = "openssl")]
#[test]
fn override_field_with_env_var_tls_private_key() {
let mut settings = Settings::from_default_template();
Expand Down
6 changes: 3 additions & 3 deletions actix-settings/src/settings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ mod max_connections;
mod mode;
mod num_workers;
mod timeout;
#[cfg(feature = "tls")]
#[cfg(feature = "openssl")]
mod tls;

#[cfg(feature = "tls")]
#[cfg(feature = "openssl")]
pub use self::tls::Tls;
pub use self::{
address::Address, backlog::Backlog, keep_alive::KeepAlive,
Expand Down Expand Up @@ -60,6 +60,6 @@ pub struct ActixSettings {
pub shutdown_timeout: Timeout,

/// TLS (HTTPS) configuration.
#[cfg(feature = "tls")]
#[cfg(feature = "openssl")]
pub tls: Tls,
}

0 comments on commit 69366fd

Please sign in to comment.