Skip to content

Commit

Permalink
Fixed exit socket stats
Browse files Browse the repository at this point in the history
  • Loading branch information
egbertbouman committed Jan 26, 2024
1 parent 4c7aacd commit 6f8030f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/routing/exit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ impl ExitSocket {

pub fn encrypt_outgoing_cell(&mut self, packet: Vec<u8>) -> Result<Vec<u8>, String> {
let encrypted_cell = payload::encrypt_cell(&packet, Direction::Backward, &mut self.keys)?;
self.bytes_up += encrypted_cell.len() as u32;
Ok(encrypted_cell)
}

Expand All @@ -84,7 +83,7 @@ impl ExitSocket {
max_relay_early: u8,
) -> Result<Vec<u8>, 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)
Expand Down Expand Up @@ -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();
Expand All @@ -149,7 +149,6 @@ impl ExitSocket {
continue;
};

exit.bytes_up += encrypted_cell.len() as u32;
(exit.peer.clone(), encrypted_cell)
}
};
Expand Down

0 comments on commit 6f8030f

Please sign in to comment.