diff --git a/Cargo.toml b/Cargo.toml index 1b5735b..e7ad84c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,6 @@ rustls-native-certs = { version = "0.6.3", features = [] } tokio = { version = "1.32.0", features = ["full"] } tokio-rustls = { version = "0.24.1", features = ["tls12", "dangerous_configuration", "early-data"] } tokio-stream = { version = "0.1.14", features = ["net"] } -tokio-fd = "0.3.0" futures-util = { version = "0.3.28" } tracing = { version = "0.1.37", features = ["log"] } @@ -34,6 +33,8 @@ tracing-subscriber = { version = "0.3.17", features = ["env-filter", "fmt", "loc base64 = "0.21.4" serde = { version = "1.0.188", features = ["derive"] } +[target.'cfg(target_family = "unix")'.dependencies] +tokio-fd = "0.3.0" [profile.release] diff --git a/src/main.rs b/src/main.rs index 17c5050..939fb1c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ mod embedded_certificate; +#[cfg(target_family = "unix")] mod stdio; mod tcp; mod tls; @@ -502,20 +503,27 @@ async fn main() { }); } L4Protocol::Stdio => { - let server = stdio::run_server().await.unwrap_or_else(|err| { - panic!("Cannot start STDIO server: {}", err); - }); - tokio::spawn(async move { - if let Err(err) = run_tunnel( - server_config, - tunnel, - stream::once(async move { Ok(server) }), - ) - .await - { - error!("{:?}", err); - } - }); + #[cfg(target_family = "unix")] + { + let server = stdio::run_server().await.unwrap_or_else(|err| { + panic!("Cannot start STDIO server: {}", err); + }); + tokio::spawn(async move { + if let Err(err) = run_tunnel( + server_config, + tunnel, + stream::once(async move { Ok(server) }), + ) + .await + { + error!("{:?}", err); + } + }); + } + #[cfg(not(target_family = "unix"))] + { + panic!("stdio is not implemented for non unix platform") + } } } } diff --git a/src/stdio.rs b/src/stdio.rs index 7403ea0..26cfed9 100644 --- a/src/stdio.rs +++ b/src/stdio.rs @@ -1,11 +1,3 @@ -#![allow(unused_imports)] - -use libc::STDIN_FILENO; -use std::os::fd::{AsRawFd, FromRawFd}; -use std::pin::Pin; -use std::task::{Context, Poll}; -use tokio::fs::File; -use tokio::io::{stdout, AsyncRead, ReadBuf, Stdout}; use tokio_fd::AsyncFd; use tracing::info;