diff --git a/rosenpass/src/app_server.rs b/rosenpass/src/app_server.rs index 5b0b998..4eee622 100644 --- a/rosenpass/src/app_server.rs +++ b/rosenpass/src/app_server.rs @@ -218,7 +218,7 @@ pub struct SocketBoundEndpoint { /// Just the address addr: SocketAddr, /// identifier - bytes: (usize,[u8;SocketBoundEndpoint::BUFFER_SIZE]) + bytes: (usize, [u8; SocketBoundEndpoint::BUFFER_SIZE]), } impl std::fmt::Display for SocketBoundEndpoint { @@ -237,7 +237,7 @@ impl SocketBoundEndpoint { + SocketBoundEndpoint::IPV6_SIZE + SocketBoundEndpoint::PORT_SIZE + SocketBoundEndpoint::SCOPE_ID_SIZE; - + pub fn new(socket: SocketPtr, addr: SocketAddr) -> Self { let bytes = Self::to_bytes(&socket, &addr); Self { @@ -247,7 +247,10 @@ impl SocketBoundEndpoint { } } - fn to_bytes(socket: &SocketPtr, addr: &SocketAddr) -> (usize, [u8; SocketBoundEndpoint::BUFFER_SIZE]) { + fn to_bytes( + socket: &SocketPtr, + addr: &SocketAddr, + ) -> (usize, [u8; SocketBoundEndpoint::BUFFER_SIZE]) { let mut buf = [0u8; SocketBoundEndpoint::BUFFER_SIZE]; let addr = match addr { SocketAddr::V4(addr) => { @@ -258,8 +261,7 @@ impl SocketBoundEndpoint { SocketAddr::V6(addr) => addr.clone(), }; let mut len: usize = 0; - buf[len..len + SocketBoundEndpoint::SOCKET_SIZE] - .copy_from_slice(&socket.0.to_be_bytes()); + buf[len..len + SocketBoundEndpoint::SOCKET_SIZE].copy_from_slice(&socket.0.to_be_bytes()); len += SocketBoundEndpoint::SOCKET_SIZE; buf[len..len + SocketBoundEndpoint::IPV6_SIZE].copy_from_slice(&addr.ip().octets()); len += SocketBoundEndpoint::IPV6_SIZE; @@ -724,8 +726,7 @@ impl AppServer { ) -> Result { match endpoint { Endpoint::SocketBoundAddress(socket) => { - self.crypt - .handle_msg_under_load(&rx, &mut *tx, socket) + self.crypt.handle_msg_under_load(&rx, &mut *tx, socket) } Endpoint::Discovery(_) => { anyhow::bail!("Host-path discovery is not supported under load") diff --git a/rosenpass/src/protocol.rs b/rosenpass/src/protocol.rs index 2c93166..98d4ada 100644 --- a/rosenpass/src/protocol.rs +++ b/rosenpass/src/protocol.rs @@ -932,7 +932,7 @@ impl CryptoServer { let mut rx_cookie = [0u8; COOKIE_SIZE]; let mut rx_mac = [0u8; MAC_SIZE]; let mut rx_sid = [0u8; 4]; - let msg_type : Result = rx_buf[0].try_into(); + let msg_type: Result = rx_buf[0].try_into(); for cookie_secret in self.active_or_retired_cookie_secrets() { if let Some(cookie_secret) = cookie_secret { @@ -963,7 +963,11 @@ impl CryptoServer { //If valid cookie is found, process message if constant_time::memcmp(&rx_cookie, &expected) { - log::debug!("Rx {:?} from {} under load, valid cookie", msg_type, host_identification); + log::debug!( + "Rx {:?} from {} under load, valid cookie", + msg_type, + host_identification + ); let result = self.handle_msg(rx_buf, tx_buf)?; return Ok(result); } @@ -977,7 +981,11 @@ impl CryptoServer { bail!("No active cookie value found"); } - log::debug!("Rx {:?} from {} under load, tx cookie reply message", msg_type, host_identification); + log::debug!( + "Rx {:?} from {} under load, tx cookie reply message", + msg_type, + host_identification + ); let cookie_value = active_cookie_value.unwrap(); let cookie_key = hash_domains::cookie_key()? diff --git a/rosenpass/tests/integration_test.rs b/rosenpass/tests/integration_test.rs index fd6893e..dfbc253 100644 --- a/rosenpass/tests/integration_test.rs +++ b/rosenpass/tests/integration_test.rs @@ -1,4 +1,10 @@ -use std::{fs::{self, write}, net::UdpSocket, path::PathBuf, process::Stdio, time::Duration}; +use std::{ + fs::{self, write}, + net::UdpSocket, + path::PathBuf, + process::Stdio, + time::Duration, +}; use clap::Parser; use rosenpass::{app_server::AppServerTestBuilder, cli::CliArgs}; @@ -137,9 +143,15 @@ fn check_exchange_under_dos() { let mut log_builder = env_logger::Builder::from_default_env(); // sets log level filter from environment (or defaults) log_builder.filter_level(log::LevelFilter::Debug); log_builder.format_timestamp_nanos(); - log_builder.format(|buf, record| { + log_builder.format(|buf, record| { let ts_format = buf.timestamp_nanos().to_string(); - writeln!(buf, "\x1b[1m{:?}\x1b[0m {}: {}", std::thread::current().id(), &ts_format[18..], record.args()) + writeln!( + buf, + "\x1b[1m{:?}\x1b[0m {}: {}", + std::thread::current().id(), + &ts_format[18..], + record.args() + ) }); let _ = log_builder.try_init();