mirror of
https://github.com/rosenpass/rosenpass.git
synced 2026-03-01 06:53:10 -08:00
Cargo fmt
This commit is contained in:
@@ -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 {
|
||||
@@ -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<crate::protocol::HandleMsgResult> {
|
||||
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")
|
||||
|
||||
@@ -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()?
|
||||
|
||||
@@ -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};
|
||||
@@ -139,7 +145,13 @@ fn check_exchange_under_dos() {
|
||||
log_builder.format_timestamp_nanos();
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user