fix(#365): correctly downcast websocket cnx when not using tls
This commit is contained in:
parent
57a142c9ca
commit
c39d84fdc2
2 changed files with 8 additions and 3 deletions
|
@ -47,7 +47,13 @@ pub(super) async fn ws_server_upgrade(
|
||||||
tokio::spawn(
|
tokio::spawn(
|
||||||
async move {
|
async move {
|
||||||
let (ws_rx, ws_tx) = match fut.await {
|
let (ws_rx, ws_tx) = match fut.await {
|
||||||
Ok(ws) => mk_websocket_tunnel(ws, Role::Server, mask_frame)?,
|
Ok(ws) => match mk_websocket_tunnel(ws, Role::Server, mask_frame) {
|
||||||
|
Ok(ws) => ws,
|
||||||
|
Err(err) => {
|
||||||
|
error!("Error during http upgrade request: {:?}", err);
|
||||||
|
return Err(err);
|
||||||
|
}
|
||||||
|
},
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!("Error during http upgrade request: {:?}", err);
|
error!("Error during http upgrade request: {:?}", err);
|
||||||
return Err(anyhow::Error::from(err));
|
return Err(anyhow::Error::from(err));
|
||||||
|
|
|
@ -319,8 +319,7 @@ pub fn mk_websocket_tunnel(
|
||||||
WebSocket::after_handshake(transport, role)
|
WebSocket::after_handshake(transport, role)
|
||||||
}
|
}
|
||||||
Err(upgraded) => {
|
Err(upgraded) => {
|
||||||
let stream = upgraded
|
let stream = hyper_util::server::conn::auto::upgrade::downcast::<TokioIo<TcpStream>>(upgraded)
|
||||||
.downcast::<TokioIo<TcpStream>>()
|
|
||||||
.map_err(|_| anyhow!("cannot downcast websocket server stream"))?;
|
.map_err(|_| anyhow!("cannot downcast websocket server stream"))?;
|
||||||
let transport = TransportStream::from_tcp(stream.io.into_inner(), stream.read_buf);
|
let transport = TransportStream::from_tcp(stream.io.into_inner(), stream.read_buf);
|
||||||
WebSocket::after_handshake(transport, role)
|
WebSocket::after_handshake(transport, role)
|
||||||
|
|
Loading…
Reference in a new issue