diff options
| author | salmonik <salmonik@tuta.io> | 2026-10-28 22:36:07 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-10-28 22:36:07 +0100 |
| commit | 25f9abeb4c69024f8d9dceb472ba33c03e00daa0 (patch) | |
| tree | a02a78f04b5afa2e3fbebffb524f1568df8f00d8 /src/bin/client/connection.rs | |
| parent | v0.2.4: fix command UX, completion wrapping and auth prompt cancellation (diff) | |
| download | zagan-bet-25f9abeb4c69024f8d9dceb472ba33c03e00daa0.tar.gz zagan-bet-25f9abeb4c69024f8d9dceb472ba33c03e00daa0.zip | |
v0.2.5: fix terminal width, ping timing and output formatting
Diffstat (limited to '')
| -rw-r--r-- | src/bin/client/connection.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/bin/client/connection.rs b/src/bin/client/connection.rs index e54b646..93a7829 100644 --- a/src/bin/client/connection.rs +++ b/src/bin/client/connection.rs | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | use zagan_bet::client::database; | 1 | use zagan_bet::client::database; |
| 2 | use zagan_bet::client::ui::first_contact_lines; | ||
| 2 | use crate::tls::TlsConnector; | 3 | use crate::tls::TlsConnector; |
| 3 | use rusqlite::Connection; | 4 | use rusqlite::Connection; |
| 4 | use std::io::{Read, Write}; | 5 | use std::io::{Read, Write}; |
| @@ -57,10 +58,9 @@ pub fn connect( | |||
| 57 | if let Some(fp) = observed { | 58 | if let Some(fp) = observed { |
| 58 | if database::get_fingerprint(conn, addr).is_none() { | 59 | if database::get_fingerprint(conn, addr).is_none() { |
| 59 | database::save_fingerprint(conn, addr, &fp)?; | 60 | database::save_fingerprint(conn, addr, &fp)?; |
| 60 | println!( | 61 | for line in first_contact_lines(addr, &fp) { |
| 61 | "First contact with {addr}: trusting fingerprint {fp}\n\ | 62 | println!("{}", line); |
| 62 | Future connections must present the same certificate key." | 63 | } |
| 63 | ); | ||
| 64 | } | 64 | } |
| 65 | } | 65 | } |
| 66 | } | 66 | } |
| @@ -72,7 +72,11 @@ pub fn connect( | |||
| 72 | let mut response = String::new(); | 72 | let mut response = String::new(); |
| 73 | tls.read_line(&mut response)?; | 73 | tls.read_line(&mut response)?; |
| 74 | let elapsed = start.elapsed(); | 74 | let elapsed = start.elapsed(); |
| 75 | println!("\n\rConnected to {} with ping delay: {:?} (TLS)", addr, elapsed); | 75 | println!( |
| 76 | "\n\rConnected to {} with ping delay: {:.1}ms (TLS)", | ||
| 77 | addr, | ||
| 78 | elapsed.as_secs_f64() * 1000.0 | ||
| 79 | ); | ||
| 76 | 80 | ||
| 77 | if let Some((username, password)) = database::get_credentials(conn, addr) { | 81 | if let Some((username, password)) = database::get_credentials(conn, addr) { |
| 78 | let auth_msg = format!("AUTH {} {}", username, password); | 82 | let auth_msg = format!("AUTH {} {}", username, password); |
