mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-14 07:51:29 +03:00
fix dup msg for relay request
This commit is contained in:
@@ -36,6 +36,7 @@ type Message = RendezvousMessage;
|
|||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
static ref SOLVING_PK_MISMATCH: Mutex<String> = Default::default();
|
static ref SOLVING_PK_MISMATCH: Mutex<String> = Default::default();
|
||||||
static ref LAST_MSG: Mutex<(SocketAddr, Instant)> = Mutex::new((SocketAddr::new([0; 4].into(), 0), Instant::now()));
|
static ref LAST_MSG: Mutex<(SocketAddr, Instant)> = Mutex::new((SocketAddr::new([0; 4].into(), 0), Instant::now()));
|
||||||
|
static ref LAST_RELAY_MSG: Mutex<(SocketAddr, Instant)> = Mutex::new((SocketAddr::new([0; 4].into(), 0), Instant::now()));
|
||||||
}
|
}
|
||||||
static SHOULD_EXIT: AtomicBool = AtomicBool::new(false);
|
static SHOULD_EXIT: AtomicBool = AtomicBool::new(false);
|
||||||
static MANUAL_RESTARTED: AtomicBool = AtomicBool::new(false);
|
static MANUAL_RESTARTED: AtomicBool = AtomicBool::new(false);
|
||||||
@@ -396,6 +397,14 @@ impl RendezvousMediator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_request_relay(&self, rr: RequestRelay, server: ServerPtr) -> ResultType<()> {
|
async fn handle_request_relay(&self, rr: RequestRelay, server: ServerPtr) -> ResultType<()> {
|
||||||
|
let addr = AddrMangle::decode(&rr.socket_addr);
|
||||||
|
let last = *LAST_RELAY_MSG.lock().await;
|
||||||
|
*LAST_RELAY_MSG.lock().await = (addr, Instant::now());
|
||||||
|
// skip duplicate relay request messages
|
||||||
|
if last.0 == addr && last.1.elapsed().as_millis() < 100 {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
self.create_relay(
|
self.create_relay(
|
||||||
rr.socket_addr.into(),
|
rr.socket_addr.into(),
|
||||||
rr.relay_server,
|
rr.relay_server,
|
||||||
|
|||||||
Reference in New Issue
Block a user