port forward, wait until TestDelay is replied (#7282)
* Revert "fix rdp not work, caused by test_delay_timer (#7274)"
This reverts commit 7fca0ba588
.
* port forward, wait until TestDelay is replied
Signed-off-by: 21pages <pages21@163.com>
---------
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
parent
30802820b0
commit
49d396538c
@ -423,14 +423,8 @@ impl Connection {
|
|||||||
if !conn.block_input {
|
if !conn.block_input {
|
||||||
conn.send_permission(Permission::BlockInput, false).await;
|
conn.send_permission(Permission::BlockInput, false).await;
|
||||||
}
|
}
|
||||||
// Note: The start parameter of interval_at needs to add TEST_DELAY_TIMEOUT, otherwise windows rdp will be affected.
|
let mut test_delay_timer =
|
||||||
// This is because controlling's TestDelay messsage comes late and injects to rdp data flow.
|
crate::rustdesk_interval(time::interval_at(Instant::now(), TEST_DELAY_TIMEOUT));
|
||||||
// Todo: Controlling side sends a notification message to controlled side before entering port forward loop, https://github.com/rustdesk/rustdesk/blob/50d080d098b22f53e46744fbdd286f2d81d64a4d/src/port_forward.rs#L187
|
|
||||||
//, and controller side waits for this notification before entering port forward loop.
|
|
||||||
let mut test_delay_timer = crate::rustdesk_interval(time::interval_at(
|
|
||||||
Instant::now() + TEST_DELAY_TIMEOUT,
|
|
||||||
TEST_DELAY_TIMEOUT,
|
|
||||||
));
|
|
||||||
let mut last_recv_time = Instant::now();
|
let mut last_recv_time = Instant::now();
|
||||||
|
|
||||||
conn.stream.set_send_timeout(
|
conn.stream.set_send_timeout(
|
||||||
@ -594,7 +588,11 @@ impl Connection {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if conn.port_forward_socket.is_some() && conn.authorized {
|
if conn.port_forward_socket.is_some() && conn.authorized {
|
||||||
break;
|
log::info!("Port forward, last_test_delay is none: {}", conn.last_test_delay.is_none());
|
||||||
|
// Avoid TestDelay reply injection into rdp data stream
|
||||||
|
if conn.last_test_delay.is_none() {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -701,18 +699,18 @@ impl Connection {
|
|||||||
conn.on_close("Timeout", true).await;
|
conn.on_close("Timeout", true).await;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
let mut qos = video_service::VIDEO_QOS.lock().unwrap();
|
// The control end will jump out of the loop after receiving LoginResponse and will not reply to the TestDelay
|
||||||
if conn.last_test_delay.is_none() {
|
if conn.last_test_delay.is_none() && !(conn.port_forward_socket.is_some() && conn.authorized) {
|
||||||
conn.last_test_delay = Some(Instant::now());
|
conn.last_test_delay = Some(Instant::now());
|
||||||
let mut msg_out = Message::new();
|
let mut msg_out = Message::new();
|
||||||
msg_out.set_test_delay(TestDelay{
|
msg_out.set_test_delay(TestDelay{
|
||||||
last_delay: conn.network_delay,
|
last_delay: conn.network_delay,
|
||||||
target_bitrate: qos.bitrate(),
|
target_bitrate: video_service::VIDEO_QOS.lock().unwrap().bitrate(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
conn.inner.send(msg_out.into());
|
conn.send(msg_out.into()).await;
|
||||||
}
|
}
|
||||||
qos.user_delay_response_elapsed(conn.inner.id(), conn.delay_response_instant.elapsed().as_millis());
|
video_service::VIDEO_QOS.lock().unwrap().user_delay_response_elapsed(conn.inner.id(), conn.delay_response_instant.elapsed().as_millis());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1835,6 +1833,9 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if self.authorized {
|
} else if self.authorized {
|
||||||
|
if self.port_forward_socket.is_some() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
match msg.union {
|
match msg.union {
|
||||||
#[allow(unused_mut)]
|
#[allow(unused_mut)]
|
||||||
Some(message::Union::MouseEvent(mut me)) => {
|
Some(message::Union::MouseEvent(mut me)) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user