From 6f8030f8ef01082e267e7e33177cab3234c15938 Mon Sep 17 00:00:00 2001 From: Egbert Bouman Date: Fri, 26 Jan 2024 10:04:38 +0100 Subject: [PATCH] Fixed exit socket stats --- src/routing/exit.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/routing/exit.rs b/src/routing/exit.rs index dca524b..9acec31 100644 --- a/src/routing/exit.rs +++ b/src/routing/exit.rs @@ -74,7 +74,6 @@ impl ExitSocket { pub fn encrypt_outgoing_cell(&mut self, packet: Vec) -> Result, String> { let encrypted_cell = payload::encrypt_cell(&packet, Direction::Backward, &mut self.keys)?; - self.bytes_up += encrypted_cell.len() as u32; Ok(encrypted_cell) } @@ -84,7 +83,7 @@ impl ExitSocket { max_relay_early: u8, ) -> Result, String> { let decrypted_cell = payload::decrypt_cell(packet, Direction::Forward, &self.keys)?; - self.bytes_down += packet.len() as u32; + self.bytes_up += packet.len() as u32; self.last_activity = util::get_time(); payload::check_cell_flags(&decrypted_cell, max_relay_early)?; Ok(decrypted_cell) @@ -137,6 +136,7 @@ impl ExitSocket { return Ok(()); } Some(exit) => { + exit.bytes_down += size as u32; let dest = Address::SocketAddress(SocketAddr::from((Ipv4Addr::from(0), 0))); let origin = Address::SocketAddress(socket_addr); let pkt = &buf[..size].to_vec(); @@ -149,7 +149,6 @@ impl ExitSocket { continue; }; - exit.bytes_up += encrypted_cell.len() as u32; (exit.peer.clone(), encrypted_cell) } };