mirror of
https://github.com/rustdesk/hbb_common.git
synced 2026-11-28 16:54:14 +00:00
feat: add opt-in WebSocket proxy support
Support WS and WSS over SOCKS5, HTTP, and HTTPS proxies, including custom ports. Use the configured proxy only when allow-websocket-proxy is enabled; explicit proxy configuration takes precedence. Propagate proxy failures without retrying a direct connection. Add regression coverage for proxy routing, authentication, TLS, custom ports, direct defaults, and failure handling. Signed-off-by: 21pages <sunboeasy@gmail.com> fix: flush WebSocket proxy tunnels before native TLS reads Flush buffered HTTP and HTTPS tunnel writes before NativeTls reads so WSS handshakes can complete on macOS. Apply the adapter only to NativeTls WebSocket connections through HTTP or HTTPS proxies. Extend the existing proxy round-trip test with HTTPS and SOCKS5 NativeTls cases. The websocket_proxy integration test passes in the rustdesk workspace. Signed-off-by: 21pages <sunboeasy@gmail.com> refactor: simplify WebSocket proxy configuration Select the configured proxy inside WsFramedStream::new based on the WebSocket proxy option and remove the explicit proxy argument. Update the socket client and drop the unused Stream::connect_websocket wrapper. Adapt integration tests to configured proxies and cover custom target ports and WebSocket close handling.
This commit is contained in:
1 parent
94ec710894
commit
3aade011c0
7 files changed
+627
-70
No files matched your search
+1
-15
@@ -1,4 +1,4 @@
|
||||
use crate::{bail, config, tcp, websocket, ResultType};
|
||||
use crate::{bail, tcp, websocket, ResultType};
|
||||
#[cfg(feature = "webrtc")]
|
||||
use crate::webrtc;
|
||||
use sodiumoxide::crypto::secretbox::Key;
|
||||
@@ -245,20 +245,6 @@ impl Stream {
|
||||
}
|
||||
}
|
||||
|
||||
/// establish connect from websocket
|
||||
#[inline]
|
||||
pub async fn connect_websocket(
|
||||
url: impl AsRef<str>,
|
||||
local_addr: Option<SocketAddr>,
|
||||
proxy_conf: Option<&config::Socks5Server>,
|
||||
timeout_ms: u64,
|
||||
) -> ResultType<Self> {
|
||||
let ws_stream =
|
||||
websocket::WsFramedStream::new(url, local_addr, proxy_conf, timeout_ms).await?;
|
||||
log::debug!("WebSocket connection established");
|
||||
Ok(Self::WebSocket(ws_stream))
|
||||
}
|
||||
|
||||
/// send message
|
||||
#[inline]
|
||||
pub async fn send(&mut self, msg: &impl protobuf::Message) -> ResultType<()> {
|
||||
|
||||
Reference in new issue
Block a user