From 964c2ed2b5f1f082a7dd18b5d16d5be3357e6a93 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Sat, 17 Feb 2024 16:50:03 +0800 Subject: [PATCH] smaller timeout for android and self-hosting --- src/client.rs | 2 +- src/common.rs | 7 +++++++ src/rendezvous_mediator.rs | 8 ++++++-- src/ui.rs | 2 +- src/ui_interface.rs | 9 +-------- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/client.rs b/src/client.rs index 28c262ed0..45eac5abd 100644 --- a/src/client.rs +++ b/src/client.rs @@ -1531,7 +1531,7 @@ impl LoginConfigHandler { } else if q == "custom" { let config = self.load_config(); let allow_more = - !crate::ui_interface::using_public_server() || self.direct == Some(true); + !crate::using_public_server() || self.direct == Some(true); let quality = if config.custom_image_quality.is_empty() { 50 } else { diff --git a/src/common.rs b/src/common.rs index 09ebb6ba2..fde8ecfa5 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1328,3 +1328,10 @@ pub fn create_symmetric_key_msg(their_pk_b: [u8; 32]) -> (Bytes, Bytes, secretbo let sealed_key = box_::seal(&key.0, &nonce, &their_pk_b, &out_sk_b); (Vec::from(our_pk_b.0).into(), sealed_key.into(), key) } + +#[inline] +pub fn using_public_server() -> bool { + option_env!("RENDEZVOUS_SERVER").unwrap_or("").is_empty() + && crate::get_custom_rendezvous_server(get_option("custom-rendezvous-server")).is_empty() +} + diff --git a/src/rendezvous_mediator.rs b/src/rendezvous_mediator.rs index 233f31e57..7fc6d8927 100644 --- a/src/rendezvous_mediator.rs +++ b/src/rendezvous_mediator.rs @@ -222,8 +222,12 @@ impl RendezvousMediator { last_timer = now; let expired = last_register_resp.map(|x| x.elapsed().as_millis() as i64 >= REG_INTERVAL).unwrap_or(true); let timeout = last_register_sent.map(|x| x.elapsed().as_millis() as i64 >= reg_timeout).unwrap_or(false); - if timeout && reg_timeout < MAX_REG_TIMEOUT { - reg_timeout += MIN_REG_TIMEOUT; + // temporarily disable exponential backoff for android before we add wakeup trigger to force connect in android + #[cfg(not(any(target_os = "android", target_os = "ios")))] + if crate::using_public_server() { // only turn on this for public server, may help DDNS self-hosting user. + if timeout && reg_timeout < MAX_REG_TIMEOUT { + reg_timeout += MIN_REG_TIMEOUT; + } } if timeout || (last_register_sent.is_none() && expired) { if timeout { diff --git a/src/ui.rs b/src/ui.rs index 8c4f4b3d9..c6916e6c8 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -259,7 +259,7 @@ impl UI { } fn using_public_server(&self) -> bool { - using_public_server() + crate::using_public_server() } fn get_options(&self) -> Value { diff --git a/src/ui_interface.rs b/src/ui_interface.rs index 86c5037bb..dbcf525db 100644 --- a/src/ui_interface.rs +++ b/src/ui_interface.rs @@ -248,12 +248,6 @@ pub fn set_peer_option(id: String, name: String, value: String) { c.store(&id); } -#[inline] -pub fn using_public_server() -> bool { - option_env!("RENDEZVOUS_SERVER").unwrap_or("").is_empty() - && crate::get_custom_rendezvous_server(get_option("custom-rendezvous-server")).is_empty() -} - #[inline] pub fn get_options() -> String { let options = { @@ -1114,11 +1108,10 @@ async fn check_connect_status_(reconnect: bool, rx: mpsc::UnboundedReceiver { - let now = time::Instant::now(); if last_timer.elapsed() < TIMER_OUT { continue; } - last_timer = now; + last_timer = time::Instant::now(); c.send(&ipc::Data::OnlineStatus(None)).await.ok(); c.send(&ipc::Data::Options(None)).await.ok();