From 56543696b79aecdcee713eabb6da3fd433ac5423 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=A3rebe=20-=20Romain=20GERARD?= Date: Fri, 12 Jan 2024 17:54:56 +0100 Subject: [PATCH] fix imports for non unix target --- src/main.rs | 7 ++++++- src/tunnel/server.rs | 7 +++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 14e6dda..68b2661 100644 --- a/src/main.rs +++ b/src/main.rs @@ -823,6 +823,7 @@ async fn main() { } }); } + #[cfg(unix)] LocalProtocol::Unix { path } => { let path = path.clone(); tokio::spawn(async move { @@ -852,6 +853,10 @@ async fn main() { } }); } + #[cfg(not(unix))] + LocalProtocol::Unix { path } => { + panic!("Unix socket is not available for non Unix platform") + } LocalProtocol::Stdio | LocalProtocol::TProxyTcp | LocalProtocol::TProxyUdp { .. } @@ -938,7 +943,7 @@ async fn main() { }); } #[cfg(not(unix))] - LocalProtocol::Unix => { + LocalProtocol::Unix { .. } => { panic!("Unix socket is not available for non Unix platform") } diff --git a/src/tunnel/server.rs b/src/tunnel/server.rs index d3bca27..ddd5e1e 100644 --- a/src/tunnel/server.rs +++ b/src/tunnel/server.rs @@ -11,7 +11,7 @@ use std::sync::Arc; use std::time::Duration; use super::{tunnel_to_jwt_token, JwtTunnelConfig, RemoteAddr, JWT_DECODE, JWT_HEADER_PREFIX}; -use crate::{socks5, tcp, tls, udp, unix_socket, LocalProtocol, TlsServerConfig, WsServerConfig}; +use crate::{socks5, tcp, tls, udp, LocalProtocol, TlsServerConfig, WsServerConfig}; use hyper::body::Incoming; use hyper::header::{COOKIE, SEC_WEBSOCKET_PROTOCOL}; use hyper::http::HeaderValue; @@ -26,7 +26,7 @@ use crate::socks5::Socks5Stream; use crate::tunnel::tls_reloader::TlsReloader; use crate::udp::UdpStream; use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt}; -use tokio::net::{TcpListener, TcpStream, UnixStream}; +use tokio::net::{TcpListener, TcpStream}; use tokio::select; use tokio::sync::{mpsc, oneshot}; use tokio_rustls::TlsAcceptor; @@ -135,6 +135,9 @@ async fn run_tunnel( } #[cfg(unix)] LocalProtocol::ReverseUnix { ref path } => { + use crate::unix_socket; + use tokio::net::UnixStream; + #[allow(clippy::type_complexity)] static SERVERS: Lazy, u16), mpsc::Receiver>>> = Lazy::new(|| Mutex::new(HashMap::with_capacity(0)));