[enhance] add websocket NOT a config feature.

This commit is contained in:
YinMo19
2025-04-18 02:53:39 +08:00
parent d00dd60e4c
commit 58103659e7
2 changed files with 116 additions and 7 deletions

View File

@@ -2,7 +2,7 @@ use crate::{
config::{Config, NetworkType},
tcp::FramedStream,
udp::FramedSocket,
websocket, ResultType,
websocket, ResultType, Stream,
};
use anyhow::Context;
use std::net::SocketAddr;
@@ -113,11 +113,11 @@ pub async fn connect_tcp_local<
target: T,
local: Option<SocketAddr>,
ms_timeout: u64,
) -> ResultType<crate::Stream> {
) -> ResultType<Stream> {
#[cfg(feature = "websocket")]
{
let url = format!("ws://{}", target);
websocket::WsFramedStream::new(url, local, None, ms_timeout).await
Ok(Stream::WebSocket(websocket::WsFramedStream::new(url, local, None, ms_timeout).await?))
}
#[cfg(not(feature = "websocket"))]
{