Skip to content

Commit 41857f5

Browse files
committed
fix: connect
1 parent 0100625 commit 41857f5

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/ssh/commons.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub fn connect(opts: &SshOpts) -> RemoteResult<Session> {
2424
// Resolve host
2525
debug!("Connecting to '{}'", ssh_config.address);
2626
// setup tcp stream
27-
let socket_addresses: Vec<SocketAddr> = match ssh_config.resolved_host.to_socket_addrs() {
27+
let socket_addresses: Vec<SocketAddr> = match ssh_config.address.to_socket_addrs() {
2828
Ok(s) => s.collect(),
2929
Err(err) => {
3030
return Err(RemoteError::new_ex(
@@ -398,7 +398,11 @@ mod test {
398398
let opts = SshOpts::new("sftp")
399399
.config_file(config_file.path(), ParseRule::ALLOW_UNKNOWN_FIELDS)
400400
.password("password");
401-
let session = connect(&opts).ok().unwrap();
401+
402+
if let Err(err) = connect(&opts) {
403+
panic!("Could not connect to server: {}", err);
404+
}
405+
let session = connect(&opts).unwrap();
402406
assert!(session.authenticated());
403407
}
404408

@@ -410,7 +414,7 @@ mod test {
410414
let opts = SshOpts::new("sftp")
411415
.config_file(config_file.path(), ParseRule::ALLOW_UNKNOWN_FIELDS)
412416
.key_storage(Box::new(ssh_mock::MockSshKeyStorage::default()));
413-
let session = connect(&opts).ok().unwrap();
417+
let session = connect(&opts).unwrap();
414418
assert!(session.authenticated());
415419
}
416420

@@ -422,7 +426,7 @@ mod test {
422426
.port(10022)
423427
.username("sftp")
424428
.password("password");
425-
let mut session = connect(&opts).ok().unwrap();
429+
let mut session = connect(&opts).unwrap();
426430
assert!(session.authenticated());
427431
// run commands
428432
assert!(perform_shell_cmd(&mut session, "pwd").is_ok());
@@ -436,7 +440,7 @@ mod test {
436440
.port(10022)
437441
.username("sftp")
438442
.password("password");
439-
let mut session = connect(&opts).ok().unwrap();
443+
let mut session = connect(&opts).unwrap();
440444
assert!(session.authenticated());
441445
// run commands
442446
assert_eq!(

0 commit comments

Comments
 (0)