From d9a4c0388177c92eb18762cecedb7e00755ebebc Mon Sep 17 00:00:00 2001 From: bobzilladev Date: Mon, 9 Jan 2023 11:05:08 -0500 Subject: [PATCH] rust/tokio do not include unixstream at all on windows --- ngrok/src/tunnel_ext.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ngrok/src/tunnel_ext.rs b/ngrok/src/tunnel_ext.rs index 9f3687f..2cbed10 100644 --- a/ngrok/src/tunnel_ext.rs +++ b/ngrok/src/tunnel_ext.rs @@ -1,3 +1,5 @@ +#[cfg(not(target_os = "windows"))] +use std::path::Path; #[cfg(feature = "hyper")] use std::{ convert::Infallible, @@ -6,7 +8,6 @@ use std::{ use std::{ io, net::SocketAddr, - path::Path, }; use async_trait::async_trait; @@ -19,6 +20,8 @@ use hyper::{ Response, StatusCode, }; +#[cfg(not(target_os = "windows"))] +use tokio::net::UnixStream; use tokio::{ io::{ AsyncRead, @@ -29,7 +32,6 @@ use tokio::{ net::{ TcpStream, ToSocketAddrs, - UnixStream, }, task::JoinHandle, }; @@ -69,6 +71,7 @@ pub trait TunnelExt: Tunnel { } /// Forward incoming tunnel connections to the provided Unix socket path. + #[cfg(not(target_os = "windows"))] #[instrument(level = "debug", skip_all, fields(path))] async fn forward_unix(&mut self, addr: String) -> Result<(), io::Error> { forward_unix_conns(self, addr, |_, _| {}).await @@ -95,6 +98,7 @@ where Ok(()) } +#[cfg(not(target_os = "windows"))] async fn forward_unix_conns( this: &mut T, addr: String, @@ -193,6 +197,7 @@ where Ok(true) } +#[cfg(not(target_os = "windows"))] #[instrument(level = "debug", skip_all, fields(remote_addr, local_addr))] async fn handle_one_unix(this: &mut T, addr: &Path, on_error: F) -> Result where