Skip to content

Commit

Permalink
refactor: replace ftp tls impl as rustls (#3760)
Browse files Browse the repository at this point in the history
  • Loading branch information
oowl authored Dec 14, 2023
1 parent d82791c commit 3741397
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
15 changes: 2 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ services-dropbox = []
services-etcd = ["dep:etcd-client", "dep:bb8"]
services-foundationdb = ["dep:foundationdb"]
services-fs = ["tokio/fs"]
services-ftp = ["dep:suppaftp", "dep:bb8"]
services-ftp = ["dep:suppaftp", "dep:bb8", "dep:async-tls" ]
services-gcs = [
"dep:reqsign",
"reqsign?/services-google",
Expand Down Expand Up @@ -295,14 +295,15 @@ sha2 = { version = "0.10", optional = true }
sled = { version = "0.34.7", optional = true }
suppaftp = { version = "5.2", default-features = false, features = [
"async-secure",
"rustls",
"async-rustls",
"async-native-tls",
], optional = true }
tikv-client = { version = "0.3.0", optional = true, default-features = false }
tokio = "1.27"
tokio-postgres = { version = "0.7.8", optional = true }
tracing = { version = "0.1", optional = true }
uuid = { version = "1", features = ["serde", "v4"] }
async-tls = { version = "0.12.0", optional = true }

[dev-dependencies]
criterion = { version = "0.5", features = ["async", "async_tokio"] }
Expand Down
12 changes: 7 additions & 5 deletions core/src/services/ftp/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use std::fmt::Formatter;
use std::str;
use std::str::FromStr;

use async_tls::TlsConnector;
use async_trait::async_trait;
use bb8::PooledConnection;
use bb8::RunError;
Expand All @@ -29,14 +30,15 @@ use futures::AsyncReadExt;
use http::Uri;
use log::debug;
use serde::Deserialize;
use suppaftp::async_native_tls::TlsConnector;
use suppaftp::list::File;

use suppaftp::types::FileType;
use suppaftp::types::Response;
use suppaftp::AsyncNativeTlsConnector;
use suppaftp::AsyncNativeTlsFtpStream;
use suppaftp::AsyncRustlsConnector;
use suppaftp::AsyncRustlsFtpStream;
use suppaftp::FtpError;
use suppaftp::ImplAsyncFtpStream;

use suppaftp::Status;
use tokio::sync::OnceCell;

Expand Down Expand Up @@ -214,7 +216,7 @@ pub struct Manager {

#[async_trait]
impl bb8::ManageConnection for Manager {
type Connection = AsyncNativeTlsFtpStream;
type Connection = AsyncRustlsFtpStream;
type Error = FtpError;

async fn connect(&self) -> std::result::Result<Self::Connection, Self::Error> {
Expand All @@ -223,7 +225,7 @@ impl bb8::ManageConnection for Manager {
let mut ftp_stream = if self.enable_secure {
stream
.into_secure(
AsyncNativeTlsConnector::from(TlsConnector::new()),
AsyncRustlsConnector::from(TlsConnector::default()),
&self.endpoint,
)
.await?
Expand Down

0 comments on commit 3741397

Please sign in to comment.