Files
termscp/src/utils/parser/ports.rs
T
Christian Visintin 974b6d6917 feat(gcs): add Google Cloud Storage support (#443)
* feat(gcs): add Google Cloud Storage support

Closes #436

* fix: honor configured protocol and finalization errors

* ci: remove TruffleHog checks
2026-08-30 18:58:17 +02:00

26 lines
810 B
Rust

//! ## Parser Port Helpers
//!
//! Shared helpers for resolving default protocol ports and parsing explicit
//! port captures from remote connection strings.
use crate::filetransfer::FileTransferProtocol;
pub(super) fn default_port_for_protocol(protocol: FileTransferProtocol) -> u16 {
match protocol {
FileTransferProtocol::Ftp(_) => 21,
FileTransferProtocol::Scp | FileTransferProtocol::Sftp => 22,
FileTransferProtocol::GoogleCloudStorage => 22,
_ => 22,
}
}
pub(super) fn parse_port(port: Option<regex::Match<'_>>, default: u16) -> Result<u16, String> {
match port {
Some(port) => port
.as_str()
.parse::<u16>()
.map_err(|err| format!("Bad port \"{}\": {err}", port.as_str())),
None => Ok(default),
}
}