diff options
| author | salmonik <salmonik@tuta.io> | 2026-10-29 22:16:15 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-10-29 22:16:15 +0100 |
| commit | bc0de9955c375cf27d52c9934403964205afc182 (patch) | |
| tree | 42799fb426fb0ec164f44c92a63525003c582f35 /src/bin/client/tls.rs | |
| parent | initial connection timeout set to 10s (diff) | |
| download | zagan-bet-bc0de9955c375cf27d52c9934403964205afc182.tar.gz zagan-bet-bc0de9955c375cf27d52c9934403964205afc182.zip | |
formatting
Diffstat (limited to 'src/bin/client/tls.rs')
| -rw-r--r-- | src/bin/client/tls.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/bin/client/tls.rs b/src/bin/client/tls.rs index b46f52b..e14ed98 100644 --- a/src/bin/client/tls.rs +++ b/src/bin/client/tls.rs | |||
| @@ -17,10 +17,10 @@ use std::net::TcpStream; | |||
| 17 | use std::sync::Arc; | 17 | use std::sync::Arc; |
| 18 | 18 | ||
| 19 | use parking_lot::Mutex; | 19 | use parking_lot::Mutex; |
| 20 | use rustls::client::{HandshakeSignatureValid, ServerCertVerified, ServerCertVerifier}; | ||
| 21 | use rustls::DigitallySignedStruct; | 20 | use rustls::DigitallySignedStruct; |
| 21 | use rustls::client::{HandshakeSignatureValid, ServerCertVerified, ServerCertVerifier}; | ||
| 22 | use zagan_bet::protocol::LineBuffer; | 22 | use zagan_bet::protocol::LineBuffer; |
| 23 | use zagan_bet::tofu::{decide, spki_fingerprint, TrustDecision}; | 23 | use zagan_bet::tofu::{TrustDecision, decide, spki_fingerprint}; |
| 24 | 24 | ||
| 25 | pub struct TlsConnector { | 25 | pub struct TlsConnector { |
| 26 | config: Arc<rustls::ClientConfig>, | 26 | config: Arc<rustls::ClientConfig>, |
| @@ -53,7 +53,10 @@ impl TlsConnector { | |||
| 53 | }) | 53 | }) |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | pub fn connect(&self, stream: TcpStream) -> Result<TlsStream, Box<dyn std::error::Error + Send + Sync>> { | 56 | pub fn connect( |
| 57 | &self, | ||
| 58 | stream: TcpStream, | ||
| 59 | ) -> Result<TlsStream, Box<dyn std::error::Error + Send + Sync>> { | ||
| 57 | let mut conn = | 60 | let mut conn = |
| 58 | rustls::ClientConnection::new(Arc::clone(&self.config), self.server_name.clone())?; | 61 | rustls::ClientConnection::new(Arc::clone(&self.config), self.server_name.clone())?; |
| 59 | let mut sock = stream; | 62 | let mut sock = stream; |
| @@ -200,10 +203,7 @@ impl TlsStream { | |||
| 200 | } | 203 | } |
| 201 | 204 | ||
| 202 | /// Apply a read timeout to the underlying TCP socket. | 205 | /// Apply a read timeout to the underlying TCP socket. |
| 203 | pub fn set_read_timeout( | 206 | pub fn set_read_timeout(&self, duration: Option<std::time::Duration>) -> std::io::Result<()> { |
| 204 | &self, | ||
| 205 | duration: Option<std::time::Duration>, | ||
| 206 | ) -> std::io::Result<()> { | ||
| 207 | let mut s = self.session.lock(); | 207 | let mut s = self.session.lock(); |
| 208 | s.read_timeout = duration; | 208 | s.read_timeout = duration; |
| 209 | s.sock.set_read_timeout(duration) | 209 | s.sock.set_read_timeout(duration) |
| @@ -235,8 +235,7 @@ impl TlsStream { | |||
| 235 | Err(error) | 235 | Err(error) |
| 236 | if matches!( | 236 | if matches!( |
| 237 | error.kind(), | 237 | error.kind(), |
| 238 | std::io::ErrorKind::WouldBlock | 238 | std::io::ErrorKind::WouldBlock | std::io::ErrorKind::TimedOut |
| 239 | | std::io::ErrorKind::TimedOut | ||
| 240 | ) => | 239 | ) => |
| 241 | { | 240 | { |
| 242 | return Ok(()); | 241 | return Ok(()); |
