MCPcopy Create free account
hub / github.com/BitVM/BitVM / insecure_connect

Function insecure_connect

bridge/src/client/data_store/ftp/lib.rs:290–330  ·  view source on GitHub ↗
(credentials: &FtpCredentials)

Source from the content-addressed store, hash-verified

288}
289
290async fn insecure_connect(credentials: &FtpCredentials) -> Result<AsyncFtpStream, String> {
291 let result =
292 AsyncFtpStream::connect(format!("{}:{}", &credentials.host, &credentials.port)).await;
293 if result.is_err() {
294 return Err(format!(
295 "Unable to connect to FTP server at {}:{} (error: {})",
296 &credentials.host,
297 &credentials.port,
298 result.err().unwrap()
299 ));
300 }
301
302 let mut ftp_stream = result.unwrap();
303
304 let result = ftp_stream
305 .login(&credentials.username, &credentials.password)
306 .await;
307 if result.is_err() {
308 return Err(format!(
309 "Invalid login credentials (error: {})",
310 result.err().unwrap()
311 ));
312 }
313
314 let result = ftp_stream.cwd(&credentials.base_path).await;
315 if result.is_err() {
316 return Err(format!(
317 "Invalid base path: {} (error: {})",
318 &credentials.base_path,
319 result.err().unwrap()
320 ));
321 }
322
323 // let result = ftp_stream.pwd().await;
324 // println!("PWD: {:?}", result);
325
326 // Use passive mode
327 ftp_stream.set_mode(suppaftp::Mode::ExtendedPassive);
328
329 Ok(ftp_stream)
330}
331
332async fn secure_connect(credentials: &FtpCredentials) -> Result<AsyncNativeTlsFtpStream, String> {
333 let result =

Callers 4

test_connectionFunction · 0.85
list_objectsFunction · 0.85
get_objectFunction · 0.85
upload_fileFunction · 0.85

Calls 1

connectFunction · 0.85

Tested by 1

test_connectionFunction · 0.68