mirror of
https://github.com/rustdesk/hbb_common.git
synced 2025-07-04 00:45:32 +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> {
|
) -> ResultType<Stream> {
|
||||||
let target_str = target.to_string();
|
let target_str = target.to_string();
|
||||||
|
|
||||||
// if target_str.starts_with("ws://") || target_str.starts_with("wss://") {
|
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 {
|
|
||||||
Ok(Stream::WebSocket(
|
Ok(Stream::WebSocket(
|
||||||
websocket::WsFramedStream::new(target_str, local, None, ms_timeout).await?,
|
websocket::WsFramedStream::new(target_str, local, None, ms_timeout).await?,
|
||||||
))
|
))
|
||||||
|
@ -15,6 +15,7 @@ use tokio::{net::TcpStream, time::timeout};
|
|||||||
use tokio_tungstenite::{
|
use tokio_tungstenite::{
|
||||||
connect_async, tungstenite::protocol::Message as WsMessage, MaybeTlsStream, WebSocketStream,
|
connect_async, tungstenite::protocol::Message as WsMessage, MaybeTlsStream, WebSocketStream,
|
||||||
};
|
};
|
||||||
|
use tungstenite::client::IntoClientRequest;
|
||||||
use tungstenite::protocol::Role;
|
use tungstenite::protocol::Role;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@ -70,15 +71,11 @@ impl WsFramedStream {
|
|||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
log::info!("{:?}", url_str);
|
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() {
|
let addr = match stream.get_ref() {
|
||||||
MaybeTlsStream::Plain(tcp) => tcp.peer_addr()?,
|
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()),
|
_ => return Err(Error::new(ErrorKind::Other, "Unsupported stream type").into()),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user