mirror of
https://github.com/rustdesk/hbb_common.git
synced 2025-07-01 15:36:53 +00:00
[clean] test passed.
- clean unused.
This commit is contained in:
parent
880365cab0
commit
3ef70f0e4d
@ -60,6 +60,7 @@ pub use flexi_logger;
|
|||||||
pub mod websocket;
|
pub mod websocket;
|
||||||
use sodiumoxide::crypto::secretbox::Key;
|
use sodiumoxide::crypto::secretbox::Key;
|
||||||
|
|
||||||
|
// support Websocket and tcp.
|
||||||
pub enum Stream {
|
pub enum Stream {
|
||||||
WebSocket(websocket::WsFramedStream),
|
WebSocket(websocket::WsFramedStream),
|
||||||
Tcp(tcp::FramedStream),
|
Tcp(tcp::FramedStream),
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
use crate::tcp::Encrypt;
|
use crate::tcp::Encrypt;
|
||||||
use crate::{
|
use crate::{
|
||||||
config::Socks5Server,
|
config::Socks5Server, protobuf::Message, sodiumoxide::crypto::secretbox::Key, ResultType,
|
||||||
protobuf::Message,
|
|
||||||
sodiumoxide::crypto::secretbox::{self, Key, Nonce},
|
|
||||||
ResultType,
|
|
||||||
};
|
};
|
||||||
use bytes::{BufMut, Bytes, BytesMut};
|
use bytes::{Bytes, BytesMut};
|
||||||
use futures::{SinkExt, StreamExt};
|
use futures::{SinkExt, StreamExt};
|
||||||
use std::{
|
use std::{
|
||||||
io::{Error, ErrorKind},
|
io::{Error, ErrorKind},
|
||||||
@ -24,7 +21,6 @@ pub struct WsFramedStream {
|
|||||||
addr: SocketAddr,
|
addr: SocketAddr,
|
||||||
encrypt: Option<Encrypt>,
|
encrypt: Option<Encrypt>,
|
||||||
send_timeout: u64,
|
send_timeout: u64,
|
||||||
// read_buf: BytesMut,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WsFramedStream {
|
impl WsFramedStream {
|
||||||
@ -36,40 +32,7 @@ impl WsFramedStream {
|
|||||||
) -> ResultType<Self> {
|
) -> ResultType<Self> {
|
||||||
let url_str = url.as_ref();
|
let url_str = url.as_ref();
|
||||||
|
|
||||||
// if let Some(proxy_conf) = proxy_conf {
|
// to-do: websocket proxy.
|
||||||
// // use proxy connect
|
|
||||||
// let url_obj = url::Url::parse(url_str)?;
|
|
||||||
// let host = url_obj
|
|
||||||
// .host_str()
|
|
||||||
// .ok_or_else(|| Error::new(ErrorKind::Other, "Invalid URL: no host"))?;
|
|
||||||
|
|
||||||
// let port = url_obj
|
|
||||||
// .port()
|
|
||||||
// .unwrap_or(if url_obj.scheme() == "wss" { 443 } else { 80 });
|
|
||||||
|
|
||||||
// let socket =
|
|
||||||
// tokio_socks::tcp::Socks5Stream::connect(proxy_conf.proxy.as_str(), (host, port))
|
|
||||||
// .await?;
|
|
||||||
|
|
||||||
// let tcp_stream = socket.into_inner();
|
|
||||||
// let maybe_tls_stream = MaybeTlsStream::Plain(tcp_stream);
|
|
||||||
// let ws_stream =
|
|
||||||
// WebSocketStream::from_raw_socket(maybe_tls_stream, Role::Client, None).await;
|
|
||||||
|
|
||||||
// let addr = match ws_stream.get_ref() {
|
|
||||||
// MaybeTlsStream::Plain(tcp) => tcp.peer_addr()?,
|
|
||||||
// _ => return Err(Error::new(ErrorKind::Other, "Unsupported stream type").into()),
|
|
||||||
// };
|
|
||||||
|
|
||||||
// let ws = Self {
|
|
||||||
// stream: ws_stream,
|
|
||||||
// addr,
|
|
||||||
// encrypt: None,
|
|
||||||
// send_timeout: ms_timeout,
|
|
||||||
// };
|
|
||||||
|
|
||||||
// Ok(ws)
|
|
||||||
// } else {
|
|
||||||
log::info!("{:?}", url_str);
|
log::info!("{:?}", url_str);
|
||||||
|
|
||||||
let request = url_str
|
let request = url_str
|
||||||
@ -92,7 +55,6 @@ impl WsFramedStream {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Ok(ws)
|
Ok(ws)
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_raw(&mut self) {
|
pub fn set_raw(&mut self) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user