From 1bddb95affde7882fd6b5ae2e5bf5f798c20e9fc Mon Sep 17 00:00:00 2001 From: salmonik Date: Thu, 29 Oct 2026 22:14:58 +0100 Subject: initial connection timeout set to 10s --- src/bin/client/connection.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/bin') diff --git a/src/bin/client/connection.rs b/src/bin/client/connection.rs index 363a2a9..44cfea9 100644 --- a/src/bin/client/connection.rs +++ b/src/bin/client/connection.rs @@ -1,13 +1,13 @@ -use zagan_bet::client::database; -use zagan_bet::client::ui::first_contact_lines; use crate::tls::TlsConnector; +use parking_lot::Mutex; use rusqlite::Connection; use std::io::{Read, Write}; use std::net::TcpStream; use std::sync::mpsc; -use parking_lot::Mutex; use std::thread; use std::time::{Duration, Instant}; +use zagan_bet::client::database; +use zagan_bet::client::ui::first_contact_lines; static UNSAFE_MODE: Mutex = Mutex::new(false); @@ -35,7 +35,8 @@ pub fn connect( thread::spawn(move || { let outcome = (|| -> ConnectResult { let tcp = TcpStream::connect(&addr_str)?; - let connector = TlsConnector::new(&server_name, stored_fingerprint.clone(), unsafe_mode)?; + let connector = + TlsConnector::new(&server_name, stored_fingerprint.clone(), unsafe_mode)?; let tls_stream = connector.connect(tcp)?; let fp = connector.observed_fingerprint(); Ok((TlsStream { inner: tls_stream }, fp)) @@ -44,11 +45,11 @@ pub fn connect( }); // Channel carries (stream, observed fingerprint). - let (tls, observed) = match rx.recv_timeout(Duration::from_secs(3)) { + let (tls, observed) = match rx.recv_timeout(Duration::from_secs(10)) { Ok(Ok((tls, fp))) => (tls, fp), Ok(Err(e)) => return Err(Box::new(TrustError(format!("{e}")))), Err(mpsc::RecvTimeoutError::Timeout) => { - return Err("Connection timed out after 3 seconds".into()) + return Err("Connection timed out after 3 seconds".into()); } Err(_) => return Err("Connection attempt failed".into()), }; @@ -130,10 +131,7 @@ impl TlsStream { self.inner.read_available_line() } - pub fn set_read_timeout( - &self, - duration: Option, - ) -> std::io::Result<()> { + pub fn set_read_timeout(&self, duration: Option) -> std::io::Result<()> { self.inner.set_read_timeout(duration) } } -- cgit v1.2.3