mirror of
https://github.com/rustdesk/hbb_common.git
synced 2026-10-20 23:47:20 +00:00
fix: return local address for direct WebSocket connections
This commit is contained in:
1 parent
0ccaaf2cf6
commit
423fb71085
2 files changed
+7
-4
No files matched your search
@@ -243,19 +243,22 @@ async fn direct_round_trip(wss: bool) {
|
||||
let url = format!("{}://{addr}/ws/id", if wss { "wss" } else { "ws" });
|
||||
upsert_tls_cache(&url, TlsType::Rustls, true);
|
||||
let server = tokio::spawn(async move {
|
||||
let (stream, _) = listener.accept().await.unwrap();
|
||||
let (stream, client_addr) = listener.accept().await.unwrap();
|
||||
let mut stream = DynTcpStream(Box::new(stream));
|
||||
if wss {
|
||||
stream = DynTcpStream(Box::new(tls_acceptor().accept(stream).await.unwrap()));
|
||||
}
|
||||
echo(stream, "/ws/id", &addr.to_string()).await;
|
||||
client_addr
|
||||
});
|
||||
let stream = socket_client::connect_tcp(url, TIMEOUT).await.unwrap();
|
||||
let local_addr = stream.local_addr();
|
||||
exchange(stream).await;
|
||||
timeout(Duration::from_millis(TIMEOUT), server)
|
||||
let client_addr = timeout(Duration::from_millis(TIMEOUT), server)
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
assert_eq!(local_addr, client_addr);
|
||||
}
|
||||
|
||||
async fn tcp_proxy_round_trip() {
|
||||
|
||||
Reference in new issue
Block a user