Skip to content

Commit e19cac9

Browse files
authored
fix(sb_fs): make s3 fs proxy capability to unsafe feature (#448)
1 parent 728006d commit e19cac9

File tree

3 files changed

+41
-20
lines changed

3 files changed

+41
-20
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/sb_fs/Cargo.toml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ either.workspace = true
4141
tracing.workspace = true
4242
rkyv = { workspace = true, features = ["validation"] }
4343

44-
rustls = "0.21"
45-
hyper-proxy = { version = "0.9", default-features = false, features = ["rustls"] }
46-
hyper-rustls = "0.24"
47-
headers = "0.3"
44+
rustls = { version = "0.21", optional = true }
45+
hyper-proxy = { version = "0.9", optional = true, default-features = false, features = ["rustls"] }
46+
hyper-rustls = { version = "0.24", optional = true }
47+
headers = { version = "0.3", optional = true }
4848
normalize-path = "0.2"
4949
memmap2 = "0.9"
5050
aws-sdk-s3 = "1.2"
@@ -63,4 +63,12 @@ serial_test.workspace = true
6363

6464
dotenvy = "0.15"
6565
aws-smithy-runtime = { version = "1.7", features = ["test-util"] }
66-
aws-smithy-runtime-api = { version = "1.7", features = ["test-util"] }
66+
aws-smithy-runtime-api = { version = "1.7", features = ["test-util"] }
67+
68+
[features]
69+
unsafe-proxy = [
70+
"dep:rustls",
71+
"dep:hyper-proxy",
72+
"dep:hyper-rustls",
73+
"dep:headers"
74+
]

crates/sb_fs/fs/s3_fs.rs

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use std::{
1717
time::{Duration, SystemTime, UNIX_EPOCH},
1818
};
1919

20+
use super::TryNormalizePath;
2021
use anyhow::{anyhow, Context};
2122
use aws_config::{retry::RetryConfig, AppName, BehaviorVersion, Region};
2223
use aws_credential_types::{credential_fn::provide_credentials_fn, Credentials};
@@ -44,12 +45,9 @@ use futures::{
4445
stream::FuturesUnordered,
4546
AsyncWriteExt, FutureExt, StreamExt, TryFutureExt,
4647
};
47-
use headers::Authorization;
48-
use hyper_proxy::{Intercept, Proxy, ProxyConnector};
49-
use hyper_rustls::{HttpsConnector, HttpsConnectorBuilder};
50-
use hyper_v014::{client::HttpConnector, Uri};
48+
5149
use memmap2::{MmapOptions, MmapRaw};
52-
use once_cell::sync::{Lazy, OnceCell};
50+
use once_cell::sync::OnceCell;
5351
use serde::{Deserialize, Serialize};
5452
use tempfile::tempfile;
5553
use tokio::{
@@ -58,9 +56,6 @@ use tokio::{
5856
task::JoinError,
5957
};
6058
use tracing::{debug, error, info_span, instrument, trace, trace_span, warn, Instrument};
61-
use url::Url;
62-
63-
use super::TryNormalizePath;
6459

6560
const MIN_PART_SIZE: usize = 1024 * 1024 * 5;
6661

@@ -240,9 +235,17 @@ impl S3FsConfig {
240235
CLIENT.with(|it| {
241236
it.borrow_mut()
242237
.get_or_init(|| {
243-
if let Some(proxy_connector) = resolve_proxy_connector() {
244-
HyperClientBuilder::new().build(proxy_connector)
245-
} else {
238+
#[cfg(feature = "unsafe-proxy")]
239+
{
240+
if let Some(proxy_connector) = resolve_proxy_connector() {
241+
HyperClientBuilder::new().build(proxy_connector)
242+
} else {
243+
HyperClientBuilder::new().build_https()
244+
}
245+
}
246+
247+
#[cfg(not(feature = "unsafe-proxy"))]
248+
{
246249
HyperClientBuilder::new().build_https()
247250
}
248251
})
@@ -251,7 +254,17 @@ impl S3FsConfig {
251254
}
252255
}
253256

254-
fn resolve_proxy_connector() -> Option<ProxyConnector<HttpsConnector<HttpConnector>>> {
257+
#[cfg(feature = "unsafe-proxy")]
258+
fn resolve_proxy_connector() -> Option<
259+
hyper_proxy::ProxyConnector<hyper_rustls::HttpsConnector<hyper_v014::client::HttpConnector>>,
260+
> {
261+
use headers::Authorization;
262+
use hyper_proxy::{Intercept, Proxy, ProxyConnector};
263+
use hyper_rustls::{HttpsConnector, HttpsConnectorBuilder};
264+
use hyper_v014::{client::HttpConnector, Uri};
265+
use once_cell::sync::Lazy;
266+
use url::Url;
267+
255268
let proxy_url: Url = std::env::var("HTTPS_PROXY").ok()?.parse().ok()?;
256269
let proxy_uri: Uri = std::env::var("HTTPS_PROXY").ok()?.parse().ok()?;
257270
let mut proxy = Proxy::new(Intercept::All, proxy_uri);

0 commit comments

Comments
 (0)