From dda337a8a1781f7bc6c2803fc1371878b1c6bdba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20H=C3=A4ggblad?= Date: Mon, 24 Oct 2022 00:49:56 +0200 Subject: [PATCH] socks5: make closed_at_index an Option --- .../proxy-helpers/src/connection_controller.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/common/socks5/proxy-helpers/src/connection_controller.rs b/common/socks5/proxy-helpers/src/connection_controller.rs index a21131e82e..1a9b13cc29 100644 --- a/common/socks5/proxy-helpers/src/connection_controller.rs +++ b/common/socks5/proxy-helpers/src/connection_controller.rs @@ -38,7 +38,7 @@ pub enum ControllerCommand { struct ActiveConnection { is_closed: bool, - closed_at_index: u64, + closed_at_index: Option, connection_sender: Option, ordered_buffer: OrderedMessageBuffer, } @@ -53,7 +53,7 @@ impl ActiveConnection { } }; if is_closed { - self.closed_at_index = ordered_message.index; + self.closed_at_index = Some(ordered_message.index); } self.ordered_buffer.write(ordered_message); } @@ -103,7 +103,7 @@ impl Controller { is_closed: false, connection_sender: Some(connection_sender), ordered_buffer: OrderedMessageBuffer::new(), - closed_at_index: u64::MAX, + closed_at_index: None, }; if let Some(_active_conn) = self.active_connections.insert(conn_id, active_connection) { error!("Received a duplicate 'Connect'!") @@ -138,8 +138,10 @@ impl Controller { } if let Some(payload) = active_connection.read_from_buf() { - if payload.last_index > active_connection.closed_at_index { - active_connection.is_closed = true; + if let Some(closed_at_index) = active_connection.closed_at_index { + if payload.last_index > closed_at_index { + active_connection.is_closed = true; + } } if let Err(err) = active_connection .connection_sender