mirror of
https://github.com/veeso/termscp.git
synced 2025-12-06 17:15:35 -08:00
SSH configuration path is not ~/.ssh/config by default (#145)
SSH configuration path is not `~/.ssh/config` by default
This commit is contained in:
committed by
veeso
parent
251b125cbb
commit
1c75c7d386
@@ -33,6 +33,8 @@ Released on ??
|
|||||||
|
|
||||||
> 🦥 The lazy update
|
> 🦥 The lazy update
|
||||||
|
|
||||||
|
- **Default ssh config path**:
|
||||||
|
- SSH configuration path is now `~/.ssh/config` by default
|
||||||
- **Bugfix**:
|
- **Bugfix**:
|
||||||
- Fixed [Issue 126](https://github.com/veeso/termscp/issues/126)
|
- Fixed [Issue 126](https://github.com/veeso/termscp/issues/126)
|
||||||
- Fixed [Issue 141](https://github.com/veeso/termscp/issues/141)
|
- Fixed [Issue 141](https://github.com/veeso/termscp/issues/141)
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ pub struct UserInterfaceConfig {
|
|||||||
pub notification_threshold: Option<u64>, // @! Since 0.7.0; Default 512MB
|
pub notification_threshold: Option<u64>, // @! Since 0.7.0; Default 512MB
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Debug, Default)]
|
#[derive(Deserialize, Serialize, Debug)]
|
||||||
/// Contains configuratio related to remote hosts
|
/// Contains configuratio related to remote hosts
|
||||||
pub struct RemoteConfig {
|
pub struct RemoteConfig {
|
||||||
/// Ssh configuration path. If NONE, won't be read
|
/// Ssh configuration path. If NONE, won't be read
|
||||||
@@ -46,6 +46,19 @@ pub struct RemoteConfig {
|
|||||||
pub ssh_keys: HashMap<String, PathBuf>,
|
pub ssh_keys: HashMap<String, PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for RemoteConfig {
|
||||||
|
fn default() -> Self {
|
||||||
|
let home_dir = dirs::home_dir().unwrap_or_else(|| PathBuf::from("/root"));
|
||||||
|
let mut ssh_config_path = "~/.ssh/config".to_string();
|
||||||
|
ssh_config_path = ssh_config_path.replacen('~', &home_dir.to_string_lossy(), 1);
|
||||||
|
|
||||||
|
Self {
|
||||||
|
ssh_config: Some(ssh_config_path),
|
||||||
|
ssh_keys: HashMap::default(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Default for UserInterfaceConfig {
|
impl Default for UserInterfaceConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
UserInterfaceConfig {
|
UserInterfaceConfig {
|
||||||
|
|||||||
@@ -651,7 +651,11 @@ mod tests {
|
|||||||
let mut client: ConfigClient = ConfigClient::new(cfg_path.as_path(), key_path.as_path())
|
let mut client: ConfigClient = ConfigClient::new(cfg_path.as_path(), key_path.as_path())
|
||||||
.ok()
|
.ok()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(client.get_ssh_config(), None); // Null ?
|
|
||||||
|
let home_dir = dirs::home_dir().unwrap_or_else(|| PathBuf::from("/root"));
|
||||||
|
let mut ssh_config_path = "~/.ssh/config".to_string();
|
||||||
|
ssh_config_path = ssh_config_path.replacen('~', &home_dir.to_string_lossy(), 1);
|
||||||
|
assert_eq!(client.get_ssh_config(), Some(ssh_config_path.as_str())); // Null ?
|
||||||
client.set_ssh_config(Some(String::from("/tmp/ssh_config")));
|
client.set_ssh_config(Some(String::from("/tmp/ssh_config")));
|
||||||
assert_eq!(client.get_ssh_config(), Some("/tmp/ssh_config"));
|
assert_eq!(client.get_ssh_config(), Some("/tmp/ssh_config"));
|
||||||
client.set_ssh_config(None);
|
client.set_ssh_config(None);
|
||||||
|
|||||||
Reference in New Issue
Block a user