From b2e94da4579d60ff4630a58251a6438b40623722 Mon Sep 17 00:00:00 2001 From: ardocrat Date: Wed, 9 Aug 2023 02:28:20 +0300 Subject: [PATCH] config: fix external connection availability check --- src/wallet/connections/external.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/wallet/connections/external.rs b/src/wallet/connections/external.rs index f36b6aa..9108223 100644 --- a/src/wallet/connections/external.rs +++ b/src/wallet/connections/external.rs @@ -58,14 +58,17 @@ impl ExternalConnection { let conn = self.clone(); std::thread::spawn(move || { let url = url::Url::parse(conn.url.as_str()).unwrap(); - let addr = url.socket_addrs(|| None).unwrap(); - match std::net::TcpStream::connect_timeout(&addr[0], Self::AVAILABILITY_CHECK_DELAY) { - Ok(_) => { - ConnectionsConfig::update_ext_conn_availability(conn.id, true); - } - Err(_) => { - ConnectionsConfig::update_ext_conn_availability(conn.id, false); + if let Ok(addr) = url.socket_addrs(|| None) { + match std::net::TcpStream::connect_timeout(&addr[0], Self::AVAILABILITY_CHECK_DELAY) { + Ok(_) => { + ConnectionsConfig::update_ext_conn_availability(conn.id, true); + } + Err(_) => { + ConnectionsConfig::update_ext_conn_availability(conn.id, false); + } } + } else { + ConnectionsConfig::update_ext_conn_availability(conn.id, false); } }); }