Disable stdio for non unix

Former-commit-id: 96afad71a8f9fa35fb3d9c5e66c1997bc807363f [formerly 75eb089125357ac5c54e8cb1e8249af13ba1ceaf] [formerly 53827390930ab1794a71f6a3080e62c836df8e45 [formerly cf75be1f0fc6425e300a32134ab53b71021d779e]]
Former-commit-id: dfd2da943781a191e9f99e027530ffb9e406655b [formerly ce8958e3821b869b9e8a27de35e63d9c0150b78b]
Former-commit-id: 6818ee061a09649169fce78ee769cd456588a412
Former-commit-id: 43352854d166a7059a4681c1997adcc0afcbd16c
Former-commit-id: c0ecf0ed363485181eae37d7f0fc6130f218f6b5
Former-commit-id: 8305f65a95302b0e7aceae2ded794272dc27e5fd [formerly 793cec8465da46bebafa53975bc4bbf753091db8]
Former-commit-id: 300e8aa99d90a98a8697052e7efa3042ce773d39
This commit is contained in:
Σrebe - Romain GERARD 2023-10-15 21:09:11 +02:00
parent 1ca69673f5
commit ef112495ae
4 changed files with 13 additions and 27 deletions

View file

@ -26,7 +26,7 @@ use tokio::net::TcpStream;
use tokio_rustls::rustls::server::DnsName;
use tokio_rustls::rustls::{Certificate, PrivateKey, ServerName};
use tracing::{debug, error, field, instrument, Instrument, Span};
use tracing::{debug, error, instrument, Instrument, Span};
use tracing_subscriber::EnvFilter;
use url::{Host, Url};
@ -572,7 +572,7 @@ async fn main() {
tokio::signal::ctrl_c().await.unwrap();
}
#[instrument(name="tunnel", level="info", skip_all, fields(id=field::Empty, remote=field::Empty))]
#[instrument(name="tunnel", level="info", skip_all, fields(id=tracing::field::Empty, remote=tracing::field::Empty))]
async fn run_tunnel<T, R, W>(
server_config: Arc<WsClientConfig>,
tunnel: LocalToRemote,

View file

@ -2,7 +2,6 @@ use anyhow::{anyhow, Context};
use std::{io, vec};
use std::net::{SocketAddr, SocketAddrV4, SocketAddrV6};
use std::os::fd::AsRawFd;
use std::time::Duration;
use tokio::net::{TcpListener, TcpSocket, TcpStream};
use tokio::time::timeout;
@ -21,6 +20,7 @@ fn configure_socket(socket: &mut TcpSocket, so_mark: &Option<i32>) -> Result<(),
#[cfg(target_os = "linux")]
if let Some(so_mark) = so_mark {
use std::os::fd::AsRawFd;
unsafe {
let optval: libc::c_int = *so_mark;
let ret = libc::setsockopt(

View file

@ -1,8 +1,5 @@
#![allow(unused_imports)]
use std::collections::HashSet;
use std::future::Future;
use std::net::Ipv4Addr;
use std::ops::{Deref, Not};
use std::pin::Pin;
use std::sync::Arc;
@ -10,12 +7,11 @@ use std::time::Duration;
use crate::{tcp, tls, L4Protocol, LocalToRemote, WsClientConfig, WsServerConfig};
use anyhow::Context;
use fastwebsockets::upgrade::UpgradeFut;
use fastwebsockets::{
Frame, OpCode, Payload, WebSocket, WebSocketError, WebSocketRead, WebSocketWrite,
};
use futures_util::{pin_mut, StreamExt};
use hyper::header::{AUTHORIZATION, SEC_WEBSOCKET_VERSION, UPGRADE, X_FRAME_OPTIONS};
use futures_util::{pin_mut};
use hyper::header::{AUTHORIZATION, SEC_WEBSOCKET_VERSION, UPGRADE};
use hyper::header::{CONNECTION, HOST, SEC_WEBSOCKET_KEY};
use hyper::server::conn::Http;
use hyper::service::service_fn;
@ -23,21 +19,16 @@ use hyper::upgrade::Upgraded;
use hyper::{http, Body, Request, Response, StatusCode};
use jsonwebtoken::{Algorithm, DecodingKey, EncodingKey, Header, TokenData, Validation};
use once_cell::sync::Lazy;
use tokio::io::{
AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, Interest, ReadHalf, WriteHalf,
};
use tokio::net::{TcpListener, TcpStream, UdpSocket};
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, ReadHalf, WriteHalf};
use tokio::net::{TcpListener, UdpSocket};
use tokio::select;
use tokio::sync::oneshot;
use tokio::time::error::Elapsed;
use tokio::time::timeout;
use crate::udp::{MyUdpSocket, UdpStream};
use crate::udp::MyUdpSocket;
use serde::{Deserialize, Serialize};
use tokio_rustls::TlsAcceptor;
use tracing::log::debug;
use tracing::{error, field, info, instrument, trace, warn, Instrument, Span};
use url::quirks::host;
use tracing::{error, info, instrument, trace, warn, Instrument, Span};
use url::Host;
use uuid::Uuid;
@ -318,7 +309,7 @@ async fn server_upgrade(
Ok(response)
}
#[instrument(name="tunnel", level="info", skip_all, fields(id=field::Empty, remote=field::Empty, peer=field::Empty, forwarded_for=field::Empty))]
#[instrument(name="tunnel", level="info", skip_all, fields(id=tracing::field::Empty, remote=tracing::field::Empty, peer=tracing::field::Empty, forwarded_for=tracing::field::Empty))]
pub async fn run_server(server_config: Arc<WsServerConfig>) -> anyhow::Result<()> {
info!(
"Starting wstunnel server listening on {}",

View file

@ -1,21 +1,16 @@
#![allow(unused_imports)]
use anyhow::Context;
use futures_util::future::join;
use futures_util::{stream, FutureExt, Stream};
use hyper::server;
use libc::poll;
use futures_util::{stream, Stream};
use pin_project::{pin_project, pinned_drop};
use std::collections::hash_map::Entry;
use std::collections::HashMap;
use std::future::Future;
use std::io;
use std::io::{Error, ErrorKind, IoSlice};
use std::io::{Error, ErrorKind};
use std::net::SocketAddr;
use std::pin::{pin, Pin};
use std::sync::{Arc, RwLock, Weak};
use std::task::Poll;
use std::time::{Duration, Instant};
use std::time::Duration;
use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt, DuplexStream, ReadBuf};
use tokio::net::UdpSocket;
use tokio::time::Sleep;