Added scp:// syntax to protocol
@@ -74,6 +74,12 @@ pub fn parse_remote_opt(
// Set port to default (22)
port = 22;
}
+ "scp" => {
+ // Set protocol to scp
+ protocol = FileTransferProtocol::Scp;
+ // Set port to default (22)
+ port = 22;
+ }
"ftp" => {
// Set protocol to fpt
protocol = FileTransferProtocol::Ftp(false);
@@ -234,6 +240,15 @@ mod tests {
assert_eq!(result.1, 21); // Fallback to ftp default
assert_eq!(result.2, FileTransferProtocol::Ftp(false));
assert!(result.3.is_none()); // Doesn't fall back
+ // Protocol
+ let result: (String, u16, FileTransferProtocol, Option<String>) =
+ parse_remote_opt(&String::from("scp://172.26.104.1"))
+ .ok()
+ .unwrap();
+ assert_eq!(result.0, String::from("172.26.104.1"));
+ assert_eq!(result.1, 22); // Fallback to scp default
+ assert_eq!(result.2, FileTransferProtocol::Scp);
+ assert!(result.3.is_none()); // Doesn't fall back
// Protocol + user
let result: (String, u16, FileTransferProtocol, Option<String>) =
parse_remote_opt(&String::from("ftps://anon@172.26.104.1"))
