mirror of
https://github.com/rustdesk/hbb_common.git
synced 2025-07-03 00:17:17 +00:00
[test] fix bug: twice enc. add ping pong log.
This commit is contained in:
parent
4ff800a8be
commit
0d6948c97b
@ -72,7 +72,18 @@ impl WsFramedStream {
|
|||||||
} else {
|
} else {
|
||||||
log::info!("{:?}", url_str);
|
log::info!("{:?}", url_str);
|
||||||
|
|
||||||
let (stream, _) = connect_async(url_str.into_client_request().unwrap()).await?;
|
let mut request = url_str
|
||||||
|
.into_client_request()
|
||||||
|
.map_err(|e| Error::new(ErrorKind::Other, e))?;
|
||||||
|
|
||||||
|
// 添加必要协议头
|
||||||
|
// request.headers_mut().insert(
|
||||||
|
// "Sec-WebSocket-Protocol",
|
||||||
|
// tungstenite::http::HeaderValue::from_static("rustdesk"),
|
||||||
|
// );
|
||||||
|
|
||||||
|
let (stream, _) =
|
||||||
|
timeout(Duration::from_millis(ms_timeout), connect_async(request)).await??;
|
||||||
|
|
||||||
let addr = match stream.get_ref() {
|
let addr = match stream.get_ref() {
|
||||||
MaybeTlsStream::Plain(tcp) => tcp.peer_addr()?,
|
MaybeTlsStream::Plain(tcp) => tcp.peer_addr()?,
|
||||||
@ -141,10 +152,6 @@ impl WsFramedStream {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub async fn send_raw(&mut self, msg: Vec<u8>) -> ResultType<()> {
|
pub async fn send_raw(&mut self, msg: Vec<u8>) -> ResultType<()> {
|
||||||
let mut msg = msg;
|
|
||||||
if let Some(key) = self.encrypt.as_mut() {
|
|
||||||
msg = key.enc(&msg);
|
|
||||||
}
|
|
||||||
self.send_bytes(bytes::Bytes::from(msg)).await
|
self.send_bytes(bytes::Bytes::from(msg)).await
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,6 +196,10 @@ impl WsFramedStream {
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Ok(WsMessage::Pong(_)) => {
|
||||||
|
log::debug!("Received pong");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
Ok(WsMessage::Close(_)) => return None,
|
Ok(WsMessage::Close(_)) => return None,
|
||||||
Ok(_) => continue,
|
Ok(_) => continue,
|
||||||
Err(e) => return Some(Err(Error::new(ErrorKind::Other, e))),
|
Err(e) => return Some(Err(Error::new(ErrorKind::Other, e))),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user