diff --git a/clash_lib/src/proxy/transport/ws/websocket.rs b/clash_lib/src/proxy/transport/ws/websocket.rs index 87b087533..55a0152c8 100644 --- a/clash_lib/src/proxy/transport/ws/websocket.rs +++ b/clash_lib/src/proxy/transport/ws/websocket.rs @@ -1,6 +1,6 @@ use std::{fmt::Debug, pin::Pin, task::Poll}; -use bytes::BytesMut; +use bytes::{Bytes, BytesMut}; use futures::{ready, Sink, Stream}; use tokio::io::{AsyncRead, AsyncWrite}; use tokio_tungstenite::{tungstenite::Message, WebSocketStream}; @@ -81,7 +81,7 @@ impl AsyncWrite for WebsocketConn { buf: &[u8], ) -> std::task::Poll> { ready!(Pin::new(&mut self.inner).poll_ready(cx)).map_err(map_io_error)?; - let message = Message::Binary(buf.into()); + let message = Message::Binary(Bytes::copy_from_slice(buf)); Pin::new(&mut self.inner) .start_send(message) .map_err(map_io_error)?;