summaryrefslogtreecommitdiffstats
path: root/src/unix.rs
diff options
context:
space:
mode:
authorToby Vincent <tobyv13@gmail.com>2023-03-19 22:35:35 -0500
committerToby Vincent <tobyv13@gmail.com>2023-03-19 22:35:35 -0500
commit465590929dad316bc07602fddaa09a6e36dcb66f (patch)
tree54803be44f2efdcabbda0c38e9765fda2366bb10 /src/unix.rs
parent6b0ca0d87fa180262ff651d287a3d09e92480178 (diff)
refactor: remove ssh2 dependency and parse known_hosts manually
Diffstat (limited to 'src/unix.rs')
-rw-r--r--src/unix.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/unix.rs b/src/unix.rs
new file mode 100644
index 0000000..5414125
--- /dev/null
+++ b/src/unix.rs
@@ -0,0 +1,19 @@
+use crate::{Session, SessionSource};
+
+pub struct HostFile;
+
+impl SessionSource for HostFile {
+ type Error = &'static str;
+
+ type Iter = Vec<Session>;
+
+ fn sessions(&self) -> Result<Self::Iter, Self::Error> {
+ let sessions = hostfile::parse_hostfile()?
+ .into_iter()
+ .flat_map(|h| h.names.into_iter())
+ .map(Into::into)
+ .collect();
+
+ Ok(sessions)
+ }
+}