summaryrefslogtreecommitdiffstats
path: root/src/bin/client/database.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/client/database.rs')
-rw-r--r--src/bin/client/database.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/bin/client/database.rs b/src/bin/client/database.rs
index 55051fb..e1fa42d 100644
--- a/src/bin/client/database.rs
+++ b/src/bin/client/database.rs
@@ -104,3 +104,15 @@ pub fn forget_host(conn: &Connection, host: &str) -> Result<(), rusqlite::Error>
104 conn.execute("DELETE FROM credentials WHERE host = ?1", [host])?; 104 conn.execute("DELETE FROM credentials WHERE host = ?1", [host])?;
105 Ok(()) 105 Ok(())
106} 106}
107
108/// List all remembered hosts with their fingerprints.
109pub fn get_all_hosts(conn: &Connection) -> Vec<(String, Option<String>)> {
110 let mut stmt = conn
111 .prepare("SELECT host, fingerprint FROM hosts ORDER BY last_used DESC")
112 .unwrap();
113 let rows = stmt.query_map([], |row| {
114 Ok((row.get(0)?, row.get(1)?))
115 })
116 .unwrap();
117 rows.filter_map(|r| r.ok()).collect()
118}