mirror of
https://github.com/veeso/termscp.git
synced 2026-04-14 22:21:35 -07:00
@@ -52,16 +52,21 @@ pub struct UserInterfaceConfig {
|
||||
pub check_for_updates: Option<bool>, // @! Since 0.3.3
|
||||
pub prompt_on_file_replace: Option<bool>, // @! Since 0.7.0; Default True
|
||||
pub group_dirs: Option<String>,
|
||||
pub file_fmt: Option<String>, // Refers to local host (for backward compatibility)
|
||||
pub remote_file_fmt: Option<String>, // @! Since 0.5.0
|
||||
pub notifications: Option<bool>, // @! Since 0.7.0; Default true
|
||||
/// file fmt. Refers to local host (for backward compatibility)
|
||||
pub file_fmt: Option<String>,
|
||||
pub remote_file_fmt: Option<String>, // @! Since 0.5.0
|
||||
pub notifications: Option<bool>, // @! Since 0.7.0; Default true
|
||||
pub notification_threshold: Option<u64>, // @! Since 0.7.0; Default 512MB
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug, Default)]
|
||||
/// Contains configuratio related to remote hosts
|
||||
pub struct RemoteConfig {
|
||||
pub ssh_keys: HashMap<String, PathBuf>, // Association between host name and path to private key
|
||||
/// Ssh configuration path. If NONE, won't be read
|
||||
pub ssh_config: Option<String>,
|
||||
/// Association between host name and path to private key
|
||||
/// NOTE: this parameter must stay as last: <https://github.com/alexcrichton/toml-rs/issues/142>
|
||||
pub ssh_keys: HashMap<String, PathBuf>,
|
||||
}
|
||||
|
||||
impl Default for UserInterfaceConfig {
|
||||
@@ -99,7 +104,10 @@ mod tests {
|
||||
String::from("192.168.1.31"),
|
||||
PathBuf::from("/tmp/private.key"),
|
||||
);
|
||||
let remote: RemoteConfig = RemoteConfig { ssh_keys: keys };
|
||||
let remote: RemoteConfig = RemoteConfig {
|
||||
ssh_keys: keys,
|
||||
ssh_config: Some(String::from("~/.ssh/config")),
|
||||
};
|
||||
let ui: UserInterfaceConfig = UserInterfaceConfig {
|
||||
default_protocol: String::from("SFTP"),
|
||||
text_editor: PathBuf::from("nano"),
|
||||
@@ -130,6 +138,10 @@ mod tests {
|
||||
.unwrap(),
|
||||
PathBuf::from("/tmp/private.key")
|
||||
);
|
||||
assert_eq!(
|
||||
cfg.remote.ssh_config.as_deref().unwrap(),
|
||||
String::from("~/.ssh/config")
|
||||
);
|
||||
assert_eq!(cfg.user_interface.default_protocol, String::from("SFTP"));
|
||||
assert_eq!(cfg.user_interface.text_editor, PathBuf::from("nano"));
|
||||
assert_eq!(cfg.user_interface.show_hidden_files, true);
|
||||
|
||||
@@ -197,6 +197,11 @@ mod tests {
|
||||
assert_eq!(cfg.user_interface.notifications.unwrap(), false);
|
||||
assert_eq!(cfg.user_interface.notification_threshold.unwrap(), 1024);
|
||||
assert_eq!(cfg.user_interface.group_dirs, Some(String::from("last")));
|
||||
// Remote
|
||||
assert_eq!(
|
||||
cfg.remote.ssh_config.as_deref(),
|
||||
Some("/home/omar/.ssh/config")
|
||||
);
|
||||
assert_eq!(
|
||||
cfg.user_interface.file_fmt,
|
||||
Some(String::from("{NAME} {PEX}"))
|
||||
@@ -244,6 +249,7 @@ mod tests {
|
||||
assert!(cfg.user_interface.remote_file_fmt.is_none());
|
||||
assert!(cfg.user_interface.notifications.is_none());
|
||||
assert!(cfg.user_interface.notification_threshold.is_none());
|
||||
assert!(cfg.remote.ssh_config.is_none());
|
||||
// Verify keys
|
||||
assert_eq!(
|
||||
*cfg.remote
|
||||
@@ -322,6 +328,9 @@ mod tests {
|
||||
notifications = false
|
||||
notification_threshold = 1024
|
||||
|
||||
[remote]
|
||||
ssh_config = "/home/omar/.ssh/config"
|
||||
|
||||
[remote.ssh_keys]
|
||||
"192.168.1.31" = "/home/omar/.ssh/raspberry.key"
|
||||
"192.168.1.32" = "/home/omar/.ssh/beaglebone.key"
|
||||
|
||||
Reference in New Issue
Block a user