Skip to content

Commit

Permalink
Use the enum from fastwebsockets for the close code instead of a magi…
Browse files Browse the repository at this point in the history
…c number
  • Loading branch information
r-vdp committed Jul 13, 2024
1 parent 61fe891 commit bbbf649
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/tunnel/transport/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::tunnel::{tunnel_to_jwt_token, RemoteAddr, JWT_HEADER_PREFIX};
use crate::WsClientConfig;
use anyhow::{anyhow, Context};
use bytes::{Bytes, BytesMut};
use fastwebsockets::{Frame, OpCode, Payload, WebSocketRead, WebSocketWrite};
use fastwebsockets::{CloseCode, Frame, OpCode, Payload, WebSocketRead, WebSocketWrite};
use http_body_util::Empty;
use hyper::header::{AUTHORIZATION, SEC_WEBSOCKET_PROTOCOL, SEC_WEBSOCKET_VERSION, UPGRADE};
use hyper::header::{CONNECTION, HOST, SEC_WEBSOCKET_KEY};
Expand Down Expand Up @@ -186,7 +186,11 @@ impl TunnelWrite for WebsocketTunnelWrite {
}

async fn close(&mut self) -> Result<(), io::Error> {
if let Err(err) = self.inner.write_frame(Frame::close(1000, &[])).await {
if let Err(err) = self
.inner
.write_frame(Frame::close(CloseCode::Normal.into(), &[]))
.await
{
return Err(io::Error::new(ErrorKind::BrokenPipe, err));
}

Expand Down

0 comments on commit bbbf649

Please sign in to comment.