mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
Added Scp file transfer to ui
This commit is contained in:
@@ -26,10 +26,11 @@
|
|||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use crate::fs::{FsFile, FsEntry};
|
use crate::fs::{FsEntry, FsFile};
|
||||||
|
|
||||||
// Transfers
|
// Transfers
|
||||||
pub mod ftp_transfer;
|
pub mod ftp_transfer;
|
||||||
|
pub mod scp_transfer;
|
||||||
pub mod sftp_transfer;
|
pub mod sftp_transfer;
|
||||||
|
|
||||||
/// ## FileTransferProtocol
|
/// ## FileTransferProtocol
|
||||||
@@ -39,6 +40,7 @@ pub mod sftp_transfer;
|
|||||||
#[derive(std::cmp::PartialEq, std::fmt::Debug, std::clone::Clone)]
|
#[derive(std::cmp::PartialEq, std::fmt::Debug, std::clone::Clone)]
|
||||||
pub enum FileTransferProtocol {
|
pub enum FileTransferProtocol {
|
||||||
Sftp,
|
Sftp,
|
||||||
|
Scp,
|
||||||
Ftp(bool), // Bool is for secure (true => ftps)
|
Ftp(bool), // Bool is for secure (true => ftps)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -230,10 +230,11 @@ impl AuthActivity {
|
|||||||
if self.selected_field == InputField::Protocol {
|
if self.selected_field == InputField::Protocol {
|
||||||
self.protocol = match self.protocol {
|
self.protocol = match self.protocol {
|
||||||
FileTransferProtocol::Sftp => FileTransferProtocol::Ftp(true), // End of list (wrap)
|
FileTransferProtocol::Sftp => FileTransferProtocol::Ftp(true), // End of list (wrap)
|
||||||
|
FileTransferProtocol::Scp => FileTransferProtocol::Sftp,
|
||||||
FileTransferProtocol::Ftp(ftps) => match ftps {
|
FileTransferProtocol::Ftp(ftps) => match ftps {
|
||||||
|
false => FileTransferProtocol::Scp,
|
||||||
true => FileTransferProtocol::Ftp(false),
|
true => FileTransferProtocol::Ftp(false),
|
||||||
false => FileTransferProtocol::Sftp,
|
},
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -241,11 +242,12 @@ impl AuthActivity {
|
|||||||
// If current field is Protocol handle event... ( move element right )
|
// If current field is Protocol handle event... ( move element right )
|
||||||
if self.selected_field == InputField::Protocol {
|
if self.selected_field == InputField::Protocol {
|
||||||
self.protocol = match self.protocol {
|
self.protocol = match self.protocol {
|
||||||
FileTransferProtocol::Sftp => FileTransferProtocol::Ftp(false),
|
FileTransferProtocol::Sftp => FileTransferProtocol::Scp,
|
||||||
|
FileTransferProtocol::Scp => FileTransferProtocol::Ftp(false),
|
||||||
FileTransferProtocol::Ftp(ftps) => match ftps {
|
FileTransferProtocol::Ftp(ftps) => match ftps {
|
||||||
false => FileTransferProtocol::Ftp(true),
|
false => FileTransferProtocol::Ftp(true),
|
||||||
true => FileTransferProtocol::Sftp, // End of list (wrap)
|
true => FileTransferProtocol::Sftp, // End of list (wrap)
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -306,14 +308,19 @@ impl AuthActivity {
|
|||||||
///
|
///
|
||||||
/// Draw protocol select
|
/// Draw protocol select
|
||||||
fn draw_protocol_select(&self) -> Tabs {
|
fn draw_protocol_select(&self) -> Tabs {
|
||||||
let protocols: Vec<Spans> =
|
let protocols: Vec<Spans> = vec![
|
||||||
vec![Spans::from("SFTP"), Spans::from("FTP"), Spans::from("FTPS")];
|
Spans::from("SFTP"),
|
||||||
|
Spans::from("SCP"),
|
||||||
|
Spans::from("FTP"),
|
||||||
|
Spans::from("FTPS"),
|
||||||
|
];
|
||||||
let index: usize = match self.protocol {
|
let index: usize = match self.protocol {
|
||||||
FileTransferProtocol::Sftp => 0,
|
FileTransferProtocol::Sftp => 0,
|
||||||
|
FileTransferProtocol::Scp => 1,
|
||||||
FileTransferProtocol::Ftp(ftps) => match ftps {
|
FileTransferProtocol::Ftp(ftps) => match ftps {
|
||||||
false => 1,
|
false => 2,
|
||||||
true => 2,
|
true => 3,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
Tabs::new(protocols)
|
Tabs::new(protocols)
|
||||||
.block(Block::default().borders(Borders::ALL).title("Protocol"))
|
.block(Block::default().borders(Borders::ALL).title("Protocol"))
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ use crate::filetransfer::FileTransferProtocol;
|
|||||||
|
|
||||||
// File transfer
|
// File transfer
|
||||||
use crate::filetransfer::ftp_transfer::FtpFileTransfer;
|
use crate::filetransfer::ftp_transfer::FtpFileTransfer;
|
||||||
|
use crate::filetransfer::scp_transfer::ScpFileTransfer;
|
||||||
use crate::filetransfer::sftp_transfer::SftpFileTransfer;
|
use crate::filetransfer::sftp_transfer::SftpFileTransfer;
|
||||||
use crate::filetransfer::FileTransfer;
|
use crate::filetransfer::FileTransfer;
|
||||||
use crate::fs::FsEntry;
|
use crate::fs::FsEntry;
|
||||||
@@ -238,9 +239,8 @@ impl FileTransferActivity {
|
|||||||
context: None,
|
context: None,
|
||||||
client: match protocol {
|
client: match protocol {
|
||||||
FileTransferProtocol::Sftp => Box::new(SftpFileTransfer::new()),
|
FileTransferProtocol::Sftp => Box::new(SftpFileTransfer::new()),
|
||||||
FileTransferProtocol::Ftp(ftps) => {
|
FileTransferProtocol::Ftp(ftps) => Box::new(FtpFileTransfer::new(ftps)),
|
||||||
Box::new(FtpFileTransfer::new(ftps))
|
FileTransferProtocol::Scp => Box::new(ScpFileTransfer::new()),
|
||||||
}
|
|
||||||
},
|
},
|
||||||
params: params,
|
params: params,
|
||||||
local: FileExplorer::new(),
|
local: FileExplorer::new(),
|
||||||
|
|||||||
Reference in New Issue
Block a user