Disable stdio for non unix

Former-commit-id: 9517420cf008ad68394c6f165c2854fa953027f8 [formerly 2f040f62537bfc2c720fac154d01da5025653d2f] [formerly 092cf2ee3cc7802316f45fd5d365d4eea26f4a70 [formerly 95539ed457c1a4370d476ae65feaf8c886bda618]]
Former-commit-id: 0287c62a86569d98886dfab52f069bf23baee92b [formerly 36e646d84a645a2f57715c80ae5c481c31c721b4]
Former-commit-id: 13fe8829cbd6c6af7712af0a13d52e4f21f3446c
Former-commit-id: 0b9a49925044d3d5b74d1e661cd0f179db93d8b8
Former-commit-id: fe0919c17783cde0d5d9af3ca5f63c7eb24044c5
Former-commit-id: 0dcce5ab0bc07b76095d097149b8d434578ded15 [formerly 5ab64e56d05f73f5f79dab98c621cc3c34407840]
Former-commit-id: ca56d5ac22971711babeb12cc1aac0889a464b1d
This commit is contained in:
Σrebe - Romain GERARD 2023-10-15 21:02:54 +02:00
parent 238275c45b
commit 1ca69673f5
3 changed files with 24 additions and 23 deletions

View file

@ -26,7 +26,6 @@ rustls-native-certs = { version = "0.6.3", features = [] }
tokio = { version = "1.32.0", features = ["full"] } tokio = { version = "1.32.0", features = ["full"] }
tokio-rustls = { version = "0.24.1", features = ["tls12", "dangerous_configuration", "early-data"] } tokio-rustls = { version = "0.24.1", features = ["tls12", "dangerous_configuration", "early-data"] }
tokio-stream = { version = "0.1.14", features = ["net"] } tokio-stream = { version = "0.1.14", features = ["net"] }
tokio-fd = "0.3.0"
futures-util = { version = "0.3.28" } futures-util = { version = "0.3.28" }
tracing = { version = "0.1.37", features = ["log"] } 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" base64 = "0.21.4"
serde = { version = "1.0.188", features = ["derive"] } serde = { version = "1.0.188", features = ["derive"] }
[target.'cfg(target_family = "unix")'.dependencies]
tokio-fd = "0.3.0"
[profile.release] [profile.release]

View file

@ -1,4 +1,5 @@
mod embedded_certificate; mod embedded_certificate;
#[cfg(target_family = "unix")]
mod stdio; mod stdio;
mod tcp; mod tcp;
mod tls; mod tls;
@ -502,20 +503,27 @@ async fn main() {
}); });
} }
L4Protocol::Stdio => { L4Protocol::Stdio => {
let server = stdio::run_server().await.unwrap_or_else(|err| { #[cfg(target_family = "unix")]
panic!("Cannot start STDIO server: {}", err); {
}); let server = stdio::run_server().await.unwrap_or_else(|err| {
tokio::spawn(async move { panic!("Cannot start STDIO server: {}", err);
if let Err(err) = run_tunnel( });
server_config, tokio::spawn(async move {
tunnel, if let Err(err) = run_tunnel(
stream::once(async move { Ok(server) }), server_config,
) tunnel,
.await stream::once(async move { Ok(server) }),
{ )
error!("{:?}", err); .await
} {
}); error!("{:?}", err);
}
});
}
#[cfg(not(target_family = "unix"))]
{
panic!("stdio is not implemented for non unix platform")
}
} }
} }
} }

View file

@ -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 tokio_fd::AsyncFd;
use tracing::info; use tracing::info;