Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: replace ftp tls impl as rustls #3760

Merged
merged 3 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }
Xuanwo marked this conversation as resolved.
Show resolved Hide resolved

[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
Loading