diff options
| author | salmonik <salmonik@tuta.io> | 2026-10-28 22:38:54 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-10-28 22:38:54 +0100 |
| commit | ef2e13df274aaf0f2e50c03c63db33d65d9a0275 (patch) | |
| tree | 991fa12e70ec11e84e8f6c6e7bc0a60b0a150759 /src/bin/client/connection.rs | |
| parent | v0.2.5: fix terminal width, ping timing and output formatting (diff) | |
| download | zagan-bet-ef2e13df274aaf0f2e50c03c63db33d65d9a0275.tar.gz zagan-bet-ef2e13df274aaf0f2e50c03c63db33d65d9a0275.zip | |
v0.2.6: preserve buffered lines and add request read timeouts
Diffstat (limited to 'src/bin/client/connection.rs')
| -rw-r--r-- | src/bin/client/connection.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/bin/client/connection.rs b/src/bin/client/connection.rs index 93a7829..49695dd 100644 --- a/src/bin/client/connection.rs +++ b/src/bin/client/connection.rs | |||
| @@ -66,6 +66,7 @@ pub fn connect( | |||
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | let mut tls = tls; | 68 | let mut tls = tls; |
| 69 | tls.set_read_timeout(Some(Duration::from_secs(10)))?; | ||
| 69 | 70 | ||
| 70 | let start = Instant::now(); | 71 | let start = Instant::now(); |
| 71 | tls.write_line("PING")?; | 72 | tls.write_line("PING")?; |
| @@ -124,6 +125,13 @@ impl TlsStream { | |||
| 124 | self.inner.write_line(msg) | 125 | self.inner.write_line(msg) |
| 125 | } | 126 | } |
| 126 | 127 | ||
| 128 | pub fn set_read_timeout( | ||
| 129 | &self, | ||
| 130 | duration: Option<std::time::Duration>, | ||
| 131 | ) -> std::io::Result<()> { | ||
| 132 | self.inner.set_read_timeout(duration) | ||
| 133 | } | ||
| 134 | |||
| 127 | pub fn try_clone(&self) -> std::io::Result<TlsStream> { | 135 | pub fn try_clone(&self) -> std::io::Result<TlsStream> { |
| 128 | Ok(TlsStream { | 136 | Ok(TlsStream { |
| 129 | inner: self.inner.try_clone()?, | 137 | inner: self.inner.try_clone()?, |
