Merge pull request #143 from YinMo19/main

[enhance] add from method
This commit is contained in:
RustDesk 2025-04-27 17:58:50 +08:00 committed by GitHub
commit 3afaf64944
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,6 +1,7 @@
use crate::{config, tcp, websocket, ResultType};
use sodiumoxide::crypto::secretbox::Key;
use std::net::SocketAddr;
use tokio::net::TcpStream;
// support Websocket and tcp.
pub enum Stream {
@ -107,4 +108,9 @@ impl Stream {
Self::Tcp(tcp) => tcp.local_addr(),
}
}
#[inline]
pub fn from(stream: TcpStream, stream_addr: SocketAddr) -> Self {
Self::Tcp(tcp::FramedStream::from(stream, stream_addr))
}
}