diff options
| author | salmonik <salmonik@tuta.io> | 2026-08-24 18:39:12 +0200 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-08-24 18:39:12 +0200 |
| commit | a2041a3d337afdc236d3c323957c0d581d32234a (patch) | |
| tree | 0fdf8caa473da0a04154289a107d4e43fc8549ff /src/bin/client/database.rs | |
| parent | v0.2.0: lock game mode (ESC/Q to exit), bump version (diff) | |
| download | zagan-bet-a2041a3d337afdc236d3c323957c0d581d32234a.tar.gz zagan-bet-a2041a3d337afdc236d3c323957c0d581d32234a.zip | |
Add hosts command, info shows current host+fingerprint, disconnect-before-connect, default port 11525
Diffstat (limited to '')
| -rw-r--r-- | src/bin/client/database.rs | 12 |
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. | ||
| 109 | pub 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 | } | ||
