update fastwebsockets, revert custom asyncread impl

This commit is contained in:
Toshit Chawda 2024-07-10 21:59:17 -07:00
parent 1916a8e7c8
commit 5571a63f40
No known key found for this signature in database
GPG key ID: 91480ED99E2B3D9D
13 changed files with 646 additions and 703 deletions

View file

@ -10,7 +10,7 @@ clap = { version = "4.4.18", features = ["derive", "help", "usage", "color", "wr
clio = { version = "0.3.5", features = ["clap-parse"] }
console-subscriber = { version = "0.2.0", optional = true }
dashmap = "5.5.3"
fastwebsockets = { version = "0.7.1", features = ["upgrade", "simdutf8", "unstable-split"] }
fastwebsockets = { version = "0.8.0", features = ["upgrade", "simdutf8", "unstable-split"] }
futures-util = { version = "0.3.30", features = ["sink"] }
http-body-util = "0.1.0"
hyper = { version = "1.1.0", features = ["server", "http1"] }

View file

@ -17,7 +17,7 @@ use hyper_util::rt::TokioIo;
#[cfg(unix)]
use tokio::net::{UnixListener, UnixStream};
use tokio::{
io::{copy, AsyncBufReadExt, AsyncWriteExt},
io::{copy, copy_bidirectional, AsyncBufReadExt, AsyncWriteExt},
net::{lookup_host, TcpListener, TcpStream, UdpSocket},
select,
};
@ -34,7 +34,7 @@ use wisp_mux::{
udp::UdpProtocolExtensionBuilder,
ProtocolExtensionBuilder,
},
CloseReason, ConnectPacket, MuxStream, MuxStreamAsyncRW, ServerMux, StreamType, WispError,
CloseReason, ConnectPacket, MuxStream, IoStream, ServerMux, StreamType, WispError,
};
type HttpBody = http_body_util::Full<hyper::body::Bytes>;
@ -269,6 +269,8 @@ async fn accept_http(
}
}
// re-enable once MuxStreamAsyncRW is fixed
/*
async fn copy_buf(mux: MuxStreamAsyncRW, tcp: TcpStream) -> std::io::Result<()> {
let (muxrx, muxtx) = mux.into_split();
let mut muxrx = muxrx.compat();
@ -300,6 +302,7 @@ async fn copy_buf(mux: MuxStreamAsyncRW, tcp: TcpStream) -> std::io::Result<()>
x = slow_fut => x.map(|_| ()),
}
}
*/
async fn handle_mux(
packet: ConnectPacket,
@ -311,9 +314,9 @@ async fn handle_mux(
);
match packet.stream_type {
StreamType::Tcp => {
let tcp_stream = TcpStream::connect(uri).await?;
let mux = stream.into_io().into_asyncrw();
copy_buf(mux, tcp_stream).await?;
let mut tcp_stream = TcpStream::connect(uri).await?;
let mut mux = stream.into_io().into_asyncrw().compat();
copy_bidirectional(&mut mux, &mut tcp_stream).await?;
}
StreamType::Udp => {
let uri = lookup_host(uri)