From 32e7cdcb8ea05341ce6db9659c4c4a5a3bab38af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=A3rebe=20-=20Romain=20GERARD?= Date: Mon, 4 Dec 2023 08:35:29 +0100 Subject: [PATCH] cleanup --- src/udp.rs | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/udp.rs b/src/udp.rs index bdfa4bb..11043f0 100644 --- a/src/udp.rs +++ b/src/udp.rs @@ -23,15 +23,15 @@ use tokio::time::{timeout, Interval}; use tracing::{debug, error, info}; use url::Host; -pub struct IoInner { - pub has_data_to_read: Notify, - pub has_read_data: Notify, +struct IoInner { + has_data_to_read: Notify, + has_read_data: Notify, } -pub struct UdpServer { - pub listener: Arc, - pub peers: HashMap>, ahash::RandomState>, - pub keys_to_delete: Arc>>, - pub cnx_timeout: Option, +struct UdpServer { + listener: Arc, + peers: HashMap>, ahash::RandomState>, + keys_to_delete: Arc>>, + cnx_timeout: Option, } impl UdpServer { @@ -104,7 +104,7 @@ impl PinnedDrop for UdpStream { } impl UdpStream { - pub fn new( + fn new( recv_socket: Arc, send_socket: Arc, peer: SocketAddr, @@ -368,6 +368,7 @@ pub fn configure_tproxy(listener: &UdpSocket) -> anyhow::Result<()> { } #[cfg(target_os = "linux")] +#[inline] pub fn mk_send_socket_tproxy(listener: &Arc) -> anyhow::Result> { use nix::cmsg_space; use nix::sys::socket::{ControlMessageOwned, RecvMsg, SockaddrIn}; @@ -376,18 +377,17 @@ pub fn mk_send_socket_tproxy(listener: &Arc) -> anyhow::Result> = nix::sys::socket::recvmsg( + let msg: RecvMsg = nix::sys::socket::recvmsg( listener.as_raw_fd(), &mut io, - Some(&mut x), + Some(&mut cmsg_space), nix::sys::socket::MsgFlags::MSG_PEEK, - ); + )?; let mut remote_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), 0); - let msg = msg.unwrap(); for cmsg in msg.cmsgs() { match cmsg { ControlMessageOwned::Ipv4OrigDstAddr(ip) => { @@ -408,13 +408,13 @@ pub fn mk_send_socket_tproxy(listener: &Arc) -> anyhow::Result