From 95b3613a30398199dd11aa90e80db62fdbbbaf71 Mon Sep 17 00:00:00 2001 From: Brian Martin Date: Mon, 8 Apr 2024 15:28:13 -0700 Subject: [PATCH 1/5] remove protocol crate dependencies on boringssl The protocol crates transitively depend on boringssl through the default features in the config/common crates. This PR removes the transitive dependencies where possible by making boringssl an optional but default feature where it is required. --- src/common/Cargo.toml | 6 +++++- src/common/src/lib.rs | 1 + src/config/Cargo.toml | 6 +++++- src/config/src/lib.rs | 2 ++ src/config/src/pingproxy.rs | 3 +++ src/config/src/pingserver.rs | 3 +++ src/config/src/rds.rs | 3 +++ src/config/src/segcache.rs | 3 +++ src/logger/Cargo.toml | 4 ++-- src/protocol/common/Cargo.toml | 4 ++-- src/protocol/memcache/Cargo.toml | 2 +- src/protocol/ping/Cargo.toml | 6 +++--- 12 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/common/Cargo.toml b/src/common/Cargo.toml index 6fdf6bb3..cdba252d 100644 --- a/src/common/Cargo.toml +++ b/src/common/Cargo.toml @@ -13,6 +13,10 @@ license = { workspace = true } boring = { workspace = true } clocksource = { workspace = true } metriken = { workspace = true } -pelikan-net = { workspace = true, features = ["boringssl"] } +pelikan-net = { workspace = true, default-features = false } ringlog = { workspace = true } serde = { workspace = true, features = ["derive"] } + +[features] +default = ["boringssl"] +boringssl = ["pelikan-net/boringssl"] \ No newline at end of file diff --git a/src/common/src/lib.rs b/src/common/src/lib.rs index 1bf56a94..381efb3d 100644 --- a/src/common/src/lib.rs +++ b/src/common/src/lib.rs @@ -6,5 +6,6 @@ pub mod bytes; pub mod expiry; pub mod metrics; pub mod signal; +#[cfg(feature = "boringssl")] pub mod ssl; pub mod traits; diff --git a/src/config/Cargo.toml b/src/config/Cargo.toml index 8be5dda3..f8404daf 100644 --- a/src/config/Cargo.toml +++ b/src/config/Cargo.toml @@ -10,8 +10,12 @@ repository = { workspace = true } license = { workspace = true } [dependencies] -common = { path = "../common" } +common = { path = "../common", default-features = false } log = { workspace = true } serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } toml = { workspace = true } + +[features] +default = ["boringssl"] +boringssl = ["common/boringssl"] \ No newline at end of file diff --git a/src/config/src/lib.rs b/src/config/src/lib.rs index 4b3868b1..dd49a42a 100644 --- a/src/config/src/lib.rs +++ b/src/config/src/lib.rs @@ -23,6 +23,7 @@ mod sockio; mod stats_log; mod tcp; pub mod time; +#[cfg(feature = "boringssl")] mod tls; mod units; mod worker; @@ -44,5 +45,6 @@ pub use sockio::{Sockio, SockioConfig}; pub use stats_log::StatsLogConfig; pub use tcp::{Tcp, TcpConfig}; pub use time::{Time, TimeConfig, TimeType}; +#[cfg(feature = "boringssl")] pub use tls::{Tls, TlsConfig}; pub use worker::{Worker, WorkerConfig}; diff --git a/src/config/src/pingproxy.rs b/src/config/src/pingproxy.rs index 7f35c2ad..f335ca50 100644 --- a/src/config/src/pingproxy.rs +++ b/src/config/src/pingproxy.rs @@ -50,6 +50,7 @@ pub struct PingproxyConfig { #[serde(default)] time: Time, + #[cfg(feature = "boringssl")] #[serde(default)] tls: Tls, @@ -126,6 +127,7 @@ impl TimeConfig for PingproxyConfig { } } +#[cfg(feature = "boringssl")] impl TlsConfig for PingproxyConfig { fn tls(&self) -> &Tls { &self.tls @@ -183,6 +185,7 @@ impl Default for PingproxyConfig { klog: Default::default(), sockio: Default::default(), tcp: Default::default(), + #[cfg(feature = "boringssl")] tls: Default::default(), } } diff --git a/src/config/src/pingserver.rs b/src/config/src/pingserver.rs index 01c18c2d..953ec093 100644 --- a/src/config/src/pingserver.rs +++ b/src/config/src/pingserver.rs @@ -46,6 +46,7 @@ pub struct PingserverConfig { worker: Worker, #[serde(default)] time: Time, + #[cfg(feature = "boringssl")] #[serde(default)] tls: Tls, @@ -110,6 +111,7 @@ impl TimeConfig for PingserverConfig { } } +#[cfg(feature = "boringssl")] impl TlsConfig for PingserverConfig { fn tls(&self) -> &Tls { &self.tls @@ -175,6 +177,7 @@ impl Default for PingserverConfig { klog: Default::default(), sockio: Default::default(), tcp: Default::default(), + #[cfg(feature = "boringssl")] tls: Default::default(), } } diff --git a/src/config/src/rds.rs b/src/config/src/rds.rs index 247c7751..26658538 100644 --- a/src/config/src/rds.rs +++ b/src/config/src/rds.rs @@ -46,6 +46,7 @@ pub struct RdsConfig { worker: Worker, #[serde(default)] time: Time, + #[cfg(feature = "boringssl")] #[serde(default)] tls: Tls, #[serde(default)] @@ -160,6 +161,7 @@ impl TimeConfig for RdsConfig { } } +#[cfg(feature = "boringssl")] impl TlsConfig for RdsConfig { fn tls(&self) -> &Tls { &self.tls @@ -195,6 +197,7 @@ impl Default for RdsConfig { klog: Default::default(), sockio: Default::default(), tcp: Default::default(), + #[cfg(feature = "boringssl")] tls: Default::default(), } } diff --git a/src/config/src/segcache.rs b/src/config/src/segcache.rs index e4c1d308..e12dfefe 100644 --- a/src/config/src/segcache.rs +++ b/src/config/src/segcache.rs @@ -46,6 +46,7 @@ pub struct SegcacheConfig { worker: Worker, #[serde(default)] time: Time, + #[cfg(feature = "boringssl")] #[serde(default)] tls: Tls, #[serde(default)] @@ -160,6 +161,7 @@ impl TimeConfig for SegcacheConfig { } } +#[cfg(feature = "boringssl")] impl TlsConfig for SegcacheConfig { fn tls(&self) -> &Tls { &self.tls @@ -195,6 +197,7 @@ impl Default for SegcacheConfig { klog: Default::default(), sockio: Default::default(), tcp: Default::default(), + #[cfg(feature = "boringssl")] tls: Default::default(), } } diff --git a/src/logger/Cargo.toml b/src/logger/Cargo.toml index e7b0ed21..20661503 100644 --- a/src/logger/Cargo.toml +++ b/src/logger/Cargo.toml @@ -8,6 +8,6 @@ repository = { workspace = true } license = { workspace = true } [dependencies] -common = { path = "../common" } -config = { path = "../config" } +common = { path = "../common", default-features = false } +config = { path = "../config", default-features = false } ringlog = { workspace = true } diff --git a/src/protocol/common/Cargo.toml b/src/protocol/common/Cargo.toml index 953fbc94..3d944be3 100644 --- a/src/protocol/common/Cargo.toml +++ b/src/protocol/common/Cargo.toml @@ -11,8 +11,8 @@ license = { workspace = true } [dependencies] bytes = { workspace = true } -common = { path = "../../common" } -config = { path = "../../config" } +common = { path = "../../common", default-features = false } +config = { path = "../../config", default-features = false } logger = { path = "../../logger" } storage-types = { path = "../../storage/types" } diff --git a/src/protocol/memcache/Cargo.toml b/src/protocol/memcache/Cargo.toml index c3508b71..dd70df70 100644 --- a/src/protocol/memcache/Cargo.toml +++ b/src/protocol/memcache/Cargo.toml @@ -13,7 +13,7 @@ path = "benches/request_parsing.rs" harness = false [dependencies] -common = { path = "../../common" } +common = { path = "../../common", default-features = false } clocksource = { workspace = true } logger = { path = "../../logger" } metriken = { workspace = true } diff --git a/src/protocol/ping/Cargo.toml b/src/protocol/ping/Cargo.toml index 433618f6..8b8df156 100644 --- a/src/protocol/ping/Cargo.toml +++ b/src/protocol/ping/Cargo.toml @@ -14,9 +14,9 @@ path = "benches/ping.rs" harness = false [dependencies] -common = { path = "../../common" } -config = { path = "../../config" } -logger = { path = "../../logger" } +common = { path = "../../common", default-features = false } +config = { path = "../../config", default-features = false } +logger = { path = "../../logger", default-features = false } metriken = { workspace = true } protocol-common = { path = "../../protocol/common" } storage-types = { path = "../../storage/types" } From 4de26f8309a99050e4af4429e757c0bce21d4a8c Mon Sep 17 00:00:00 2001 From: Brian Martin Date: Mon, 8 Apr 2024 16:43:34 -0700 Subject: [PATCH 2/5] add missing newlines --- src/common/Cargo.toml | 2 +- src/config/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/Cargo.toml b/src/common/Cargo.toml index cdba252d..33f25d9d 100644 --- a/src/common/Cargo.toml +++ b/src/common/Cargo.toml @@ -19,4 +19,4 @@ serde = { workspace = true, features = ["derive"] } [features] default = ["boringssl"] -boringssl = ["pelikan-net/boringssl"] \ No newline at end of file +boringssl = ["pelikan-net/boringssl"] diff --git a/src/config/Cargo.toml b/src/config/Cargo.toml index f8404daf..620c0065 100644 --- a/src/config/Cargo.toml +++ b/src/config/Cargo.toml @@ -18,4 +18,4 @@ toml = { workspace = true } [features] default = ["boringssl"] -boringssl = ["common/boringssl"] \ No newline at end of file +boringssl = ["common/boringssl"] From 6564d85170385faa1e9e47215b64dca86695e88e Mon Sep 17 00:00:00 2001 From: Brian Martin Date: Mon, 8 Apr 2024 17:07:01 -0700 Subject: [PATCH 3/5] address warning --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 867d5231..d58e1a68 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,7 +62,7 @@ nom = "7.1.3" openssl = "0.10.64" openssl-sys = "0.9.102" parking_lot = "0.12.1" -pelikan-net = { path = "./src/net", version = "0.2.0" } +pelikan-net = { path = "./src/net", version = "0.2.0", default-features = false } phf = "0.11.2" proc-macro2 = "1.0.69" quote = "1.0.33" From 361ad960535b6166d87243e170697931495f12ec Mon Sep 17 00:00:00 2001 From: Brian Martin Date: Mon, 8 Apr 2024 17:10:50 -0700 Subject: [PATCH 4/5] fix --- src/common/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/Cargo.toml b/src/common/Cargo.toml index 33f25d9d..476b1d81 100644 --- a/src/common/Cargo.toml +++ b/src/common/Cargo.toml @@ -10,7 +10,7 @@ repository = { workspace = true } license = { workspace = true } [dependencies] -boring = { workspace = true } +boring = { workspace = true, optional = true } clocksource = { workspace = true } metriken = { workspace = true } pelikan-net = { workspace = true, default-features = false } From ff80d182e5fb062999a228fe6774865c7a962dd5 Mon Sep 17 00:00:00 2001 From: Brian Martin Date: Mon, 8 Apr 2024 17:12:22 -0700 Subject: [PATCH 5/5] fix --- src/common/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/Cargo.toml b/src/common/Cargo.toml index 476b1d81..6e45ee5e 100644 --- a/src/common/Cargo.toml +++ b/src/common/Cargo.toml @@ -19,4 +19,4 @@ serde = { workspace = true, features = ["derive"] } [features] default = ["boringssl"] -boringssl = ["pelikan-net/boringssl"] +boringssl = ["dep:boring", "pelikan-net/boringssl"]