From e48f36a227e3098e43071b4b95f9e3d74e3b004d Mon Sep 17 00:00:00 2001 From: rustdesk Date: Wed, 19 Jul 2023 21:46:15 +0800 Subject: [PATCH] prepare device_info upload, change sync interval from 30s to 15s, also enable android --- src/hbbs_http/sync.rs | 6 +++--- src/rendezvous_mediator.rs | 1 + src/server.rs | 1 - 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hbbs_http/sync.rs b/src/hbbs_http/sync.rs index 251436aa7..00fbc9933 100644 --- a/src/hbbs_http/sync.rs +++ b/src/hbbs_http/sync.rs @@ -9,7 +9,7 @@ use hbb_common::{ use serde::{Deserialize, Serialize}; use serde_json::{json, Value}; -const TIME_HEARTBEAT: Duration = Duration::from_secs(30); +const TIME_HEARTBEAT: Duration = Duration::from_secs(15); const TIME_CONN: Duration = Duration::from_secs(3); #[cfg(not(any(target_os = "ios")))] @@ -17,7 +17,7 @@ lazy_static::lazy_static! { static ref SENDER : Mutex>> = Mutex::new(start_hbbs_sync()); } -#[cfg(not(any(target_os = "android", target_os = "ios")))] +#[cfg(not(any(target_os = "ios")))] pub fn start() { let _sender = SENDER.lock().unwrap(); } @@ -52,7 +52,6 @@ async fn start_hbbs_sync_async() { tokio::select! { _ = interval.tick() => { let url = heartbeat_url(); - let modified_at = LocalConfig::get_option("strategy_timestamp").parse::().unwrap_or(0); if !url.is_empty() { let conns = Connection::alive_conns(); if conns.is_empty() && last_send.elapsed() < TIME_HEARTBEAT { @@ -65,6 +64,7 @@ async fn start_hbbs_sync_async() { if !conns.is_empty() { v["conns"] = json!(conns); } + let modified_at = LocalConfig::get_option("strategy_timestamp").parse::().unwrap_or(0); v["modified_at"] = json!(modified_at); if let Ok(s) = crate::post_request(url.clone(), v.to_string(), "").await { if let Ok(mut rsp) = serde_json::from_str::>(&s) { diff --git a/src/rendezvous_mediator.rs b/src/rendezvous_mediator.rs index 8b43d86a5..c0f02f2e3 100644 --- a/src/rendezvous_mediator.rs +++ b/src/rendezvous_mediator.rs @@ -52,6 +52,7 @@ impl RendezvousMediator { } pub async fn start_all() { + crate::hbbs_http::sync::start(); let mut nat_tested = false; check_zombie(); let server = new_server(); diff --git a/src/server.rs b/src/server.rs index 9f41b1ddc..a8634f81f 100644 --- a/src/server.rs +++ b/src/server.rs @@ -380,7 +380,6 @@ pub async fn start_server(is_server: bool) { } }); input_service::fix_key_down_timeout_loop(); - crate::hbbs_http::sync::start(); #[cfg(target_os = "linux")] if crate::platform::current_is_wayland() { allow_err!(input_service::setup_uinput(0, 1920, 0, 1080).await);