mirror of
https://github.com/rustdesk/hbb_common.git
synced 2025-07-03 08:25:27 +00:00
[test] websocket should be determined in runtime.
This commit is contained in:
parent
b1dd3bb9c8
commit
4ff800a8be
@ -116,11 +116,7 @@ pub async fn connect_tcp_local<
|
||||
) -> ResultType<Stream> {
|
||||
let target_str = target.to_string();
|
||||
|
||||
// if target_str.starts_with("ws://") || target_str.starts_with("wss://") {
|
||||
// Ok(Stream::WebSocket(
|
||||
// websocket::WsFramedStream::new(target_str, local, None, ms_timeout).await?,
|
||||
// ))
|
||||
if true {
|
||||
if target_str.starts_with("ws://") || target_str.starts_with("wss://") {
|
||||
Ok(Stream::WebSocket(
|
||||
websocket::WsFramedStream::new(target_str, local, None, ms_timeout).await?,
|
||||
))
|
||||
|
@ -15,6 +15,7 @@ use tokio::{net::TcpStream, time::timeout};
|
||||
use tokio_tungstenite::{
|
||||
connect_async, tungstenite::protocol::Message as WsMessage, MaybeTlsStream, WebSocketStream,
|
||||
};
|
||||
use tungstenite::client::IntoClientRequest;
|
||||
use tungstenite::protocol::Role;
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -70,15 +71,11 @@ impl WsFramedStream {
|
||||
})
|
||||
} else {
|
||||
log::info!("{:?}", url_str);
|
||||
let ws_url = format!("ws://{}", url_str);
|
||||
let (stream, _) = connect_async(ws_url).await?;
|
||||
|
||||
let (stream, _) = connect_async(url_str.into_client_request().unwrap()).await?;
|
||||
|
||||
let addr = match stream.get_ref() {
|
||||
MaybeTlsStream::Plain(tcp) => tcp.peer_addr()?,
|
||||
#[cfg(feature = "native-tls")]
|
||||
MaybeTlsStream::NativeTls(tls) => tls.get_ref().peer_addr()?,
|
||||
#[cfg(feature = "rustls")]
|
||||
MaybeTlsStream::Rustls(tls) => tls.get_ref().0.peer_addr()?,
|
||||
_ => return Err(Error::new(ErrorKind::Other, "Unsupported stream type").into()),
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user