Skip to content

Commit 763ee33

Browse files
committed
fix: ssh2-config 0.5
1 parent c4cb5d3 commit 763ee33

File tree

4 files changed

+64
-44
lines changed

4 files changed

+64
-44
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Changelog
22

33
- [Changelog](#changelog)
4+
- [0.6.1](#061)
45
- [0.6.0](#060)
56
- [0.5.0](#050)
67
- [0.4.1](#041)
@@ -18,6 +19,12 @@
1819

1920
---
2021

22+
## 0.6.1
23+
24+
Released on 27/03/2025
25+
26+
- bump `ssh2-config` to `0.5.4`
27+
2128
## 0.6.0
2229

2330
Released on 15/03/2025

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ license = "MIT"
1010
name = "remotefs-ssh"
1111
readme = "README.md"
1212
repository = "https://github.com/remotefs-rs/remotefs-rs-ssh"
13-
version = "0.6.0"
13+
version = "0.6.1"
1414
rust-version = "1.85.0"
1515

1616
[dependencies]
1717
chrono = "^0.4"
1818
lazy-regex = "3"
1919
log = "^0.4"
2020
remotefs = "^0.3"
21-
ssh2-config = "^0.4"
21+
ssh2-config = "^0.5"
2222
ssh2 = "^0.9"
2323

2424
[dev-dependencies]

src/ssh/commons.rs

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -144,46 +144,47 @@ fn set_algo_prefs(session: &mut Session, opts: &SshOpts, config: &Config) -> Rem
144144
trace!("compression: {}", compress);
145145
session.set_compress(compress);
146146
}
147-
if let Some(algos) = params.kex_algorithms.as_deref() {
148-
let algos = algos.join(",");
149-
trace!("Configuring KEX algorithms: {}", algos);
150-
if let Err(err) = session.method_pref(SshMethodType::Kex, algos.as_str()) {
151-
error!("Could not set KEX algorithms: {}", err);
152-
return Err(RemoteError::new_ex(RemoteErrorType::ProtocolError, err));
153-
}
147+
148+
// kex
149+
let algos = params.kex_algorithms.algorithms().join(",");
150+
trace!("Configuring KEX algorithms: {}", algos);
151+
if let Err(err) = session.method_pref(SshMethodType::Kex, algos.as_str()) {
152+
error!("Could not set KEX algorithms: {}", err);
153+
return Err(RemoteError::new_ex(RemoteErrorType::ProtocolError, err));
154154
}
155-
if let Some(algos) = params.host_key_algorithms.as_deref() {
156-
let algos = algos.join(",");
157-
trace!("Configuring HostKey algorithms: {}", algos);
158-
if let Err(err) = session.method_pref(SshMethodType::HostKey, algos.as_str()) {
159-
error!("Could not set host key algorithms: {}", err);
160-
return Err(RemoteError::new_ex(RemoteErrorType::ProtocolError, err));
161-
}
155+
156+
// HostKey
157+
let algos = params.host_key_algorithms.algorithms().join(",");
158+
trace!("Configuring HostKey algorithms: {}", algos);
159+
if let Err(err) = session.method_pref(SshMethodType::HostKey, algos.as_str()) {
160+
error!("Could not set host key algorithms: {}", err);
161+
return Err(RemoteError::new_ex(RemoteErrorType::ProtocolError, err));
162162
}
163-
if let Some(algos) = params.ciphers.as_deref() {
164-
let algos = algos.join(",");
165-
trace!("Configuring Crypt algorithms: {}", algos);
166-
if let Err(err) = session.method_pref(SshMethodType::CryptCs, algos.as_str()) {
167-
error!("Could not set crypt algorithms (client-server): {}", err);
168-
return Err(RemoteError::new_ex(RemoteErrorType::ProtocolError, err));
169-
}
170-
if let Err(err) = session.method_pref(SshMethodType::CryptSc, algos.as_str()) {
171-
error!("Could not set crypt algorithms (server-client): {}", err);
172-
return Err(RemoteError::new_ex(RemoteErrorType::ProtocolError, err));
173-
}
163+
164+
// ciphers
165+
let algos = params.ciphers.algorithms().join(",");
166+
trace!("Configuring Crypt algorithms: {}", algos);
167+
if let Err(err) = session.method_pref(SshMethodType::CryptCs, algos.as_str()) {
168+
error!("Could not set crypt algorithms (client-server): {}", err);
169+
return Err(RemoteError::new_ex(RemoteErrorType::ProtocolError, err));
174170
}
175-
if let Some(algos) = params.mac.as_deref() {
176-
let algos = algos.join(",");
177-
trace!("Configuring MAC algorithms: {}", algos);
178-
if let Err(err) = session.method_pref(SshMethodType::MacCs, algos.as_str()) {
179-
error!("Could not set MAC algorithms (client-server): {}", err);
180-
return Err(RemoteError::new_ex(RemoteErrorType::ProtocolError, err));
181-
}
182-
if let Err(err) = session.method_pref(SshMethodType::MacSc, algos.as_str()) {
183-
error!("Could not set MAC algorithms (server-client): {}", err);
184-
return Err(RemoteError::new_ex(RemoteErrorType::ProtocolError, err));
185-
}
171+
if let Err(err) = session.method_pref(SshMethodType::CryptSc, algos.as_str()) {
172+
error!("Could not set crypt algorithms (server-client): {}", err);
173+
return Err(RemoteError::new_ex(RemoteErrorType::ProtocolError, err));
186174
}
175+
176+
// MAC
177+
let algos = params.mac.algorithms().join(",");
178+
trace!("Configuring MAC algorithms: {}", algos);
179+
if let Err(err) = session.method_pref(SshMethodType::MacCs, algos.as_str()) {
180+
error!("Could not set MAC algorithms (client-server): {}", err);
181+
return Err(RemoteError::new_ex(RemoteErrorType::ProtocolError, err));
182+
}
183+
if let Err(err) = session.method_pref(SshMethodType::MacSc, algos.as_str()) {
184+
error!("Could not set MAC algorithms (server-client): {}", err);
185+
return Err(RemoteError::new_ex(RemoteErrorType::ProtocolError, err));
186+
}
187+
187188
// -- configure algos from opts
188189
for method in opts.methods.iter() {
189190
let algos = method.prefs();

src/ssh/config.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::path::Path;
88
use std::time::Duration;
99

1010
use remotefs::{RemoteError, RemoteErrorType, RemoteResult};
11-
use ssh2_config::{HostParams, ParseRule, SshConfig};
11+
use ssh2_config::{DefaultAlgorithms, HostParams, ParseRule, SshConfig};
1212

1313
use super::SshOpts;
1414

@@ -117,7 +117,7 @@ impl TryFrom<&SshOpts> for Config {
117117
let params = Self::parse(p, opts.host.as_str(), opts.parse_rules)?;
118118
Ok(Self::from_params(params, opts))
119119
} else {
120-
let params = HostParams::default();
120+
let params = HostParams::new(&DefaultAlgorithms::default());
121121
Ok(Self::from_params(params, opts))
122122
}
123123
}
@@ -140,7 +140,10 @@ mod test {
140140
assert_eq!(config.address.as_str(), "192.168.1.1:22");
141141
assert_eq!(config.host.as_str(), "192.168.1.1");
142142
assert!(config.username.is_empty());
143-
assert_eq!(config.params, HostParams::default());
143+
assert_eq!(
144+
config.params,
145+
HostParams::new(&DefaultAlgorithms::default())
146+
);
144147
}
145148

146149
#[test]
@@ -155,7 +158,10 @@ mod test {
155158
assert_eq!(config.host.as_str(), "192.168.1.1");
156159
assert_eq!(config.address.as_str(), "192.168.1.1:2222");
157160
assert_eq!(config.username.as_str(), "omar");
158-
assert_eq!(config.params, HostParams::default());
161+
assert_eq!(
162+
config.params,
163+
HostParams::new(&DefaultAlgorithms::default())
164+
);
159165
}
160166

161167
#[test]
@@ -169,7 +175,10 @@ mod test {
169175
assert_eq!(config.resolved_host.as_str(), "127.0.0.1");
170176
assert_eq!(config.address.as_str(), "127.0.0.1:22");
171177
assert_eq!(config.username.as_str(), "sftp");
172-
assert_ne!(config.params, HostParams::default());
178+
assert_ne!(
179+
config.params,
180+
HostParams::new(&DefaultAlgorithms::default())
181+
);
173182
}
174183

175184
#[test]
@@ -187,6 +196,9 @@ mod test {
187196
assert_eq!(config.resolved_host.as_str(), "127.0.0.1");
188197
assert_eq!(config.address.as_str(), "127.0.0.1:22");
189198
assert_eq!(config.username.as_str(), "omar");
190-
assert_ne!(config.params, HostParams::default());
199+
assert_ne!(
200+
config.params,
201+
HostParams::new(&DefaultAlgorithms::default())
202+
);
191203
}
192204
}

0 commit comments

Comments
 (0)