mirror of
https://github.com/MercuryWorkshop/epoxy-tls.git
synced 2025-05-12 22:10:01 -04:00
wisp_mux 1.1.0: abstract closecode, add hyper_tower feature to docs, fix stream not sending close code
This commit is contained in:
parent
429c4a30f4
commit
9ebb24b088
8 changed files with 207 additions and 22 deletions
|
@ -17,7 +17,9 @@ use tokio::net::{TcpListener, TcpStream, UdpSocket};
|
|||
use tokio_native_tls::{native_tls, TlsAcceptor};
|
||||
use tokio_util::codec::{BytesCodec, Framed};
|
||||
|
||||
use wisp_mux::{ws, ConnectPacket, MuxStream, ServerMux, StreamType, WispError, MuxEvent};
|
||||
use wisp_mux::{
|
||||
ws, CloseReason, ConnectPacket, MuxEvent, MuxStream, ServerMux, StreamType, WispError,
|
||||
};
|
||||
|
||||
type HttpBody = http_body_util::Full<hyper::body::Bytes>;
|
||||
|
||||
|
@ -192,12 +194,12 @@ async fn accept_ws(
|
|||
let close_ok = stream.get_close_handle();
|
||||
let _ = handle_mux(packet, stream)
|
||||
.or_else(|err| async move {
|
||||
let _ = close_err.close(0x03).await;
|
||||
let _ = close_err.close(CloseReason::Unexpected).await;
|
||||
Err(err)
|
||||
})
|
||||
.and_then(|should_send| async move {
|
||||
if should_send {
|
||||
close_ok.close(0x02).await
|
||||
close_ok.close(CloseReason::Voluntary).await
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
|
@ -222,7 +224,9 @@ async fn accept_wsproxy(
|
|||
match hyper::Uri::try_from(incoming_uri.clone()) {
|
||||
Ok(_) => (),
|
||||
Err(err) => {
|
||||
ws_stream.write_frame(Frame::close(CloseCode::Away.into(), b"invalid uri")).await?;
|
||||
ws_stream
|
||||
.write_frame(Frame::close(CloseCode::Away.into(), b"invalid uri"))
|
||||
.await?;
|
||||
return Err(Box::new(err));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue