mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
@@ -1,4 +1,8 @@
|
||||
use std::{collections::HashMap, sync::Mutex, time::Duration};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
sync::{Arc, Mutex},
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
#[cfg(not(any(target_os = "ios")))]
|
||||
use crate::Connection;
|
||||
@@ -16,6 +20,7 @@ const TIME_CONN: Duration = Duration::from_secs(3);
|
||||
#[cfg(not(any(target_os = "ios")))]
|
||||
lazy_static::lazy_static! {
|
||||
static ref SENDER : Mutex<broadcast::Sender<Vec<i32>>> = Mutex::new(start_hbbs_sync());
|
||||
static ref PRO: Arc<Mutex<bool>> = Default::default();
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "ios")))]
|
||||
@@ -54,6 +59,7 @@ async fn start_hbbs_sync_async() {
|
||||
_ = interval.tick() => {
|
||||
let url = heartbeat_url();
|
||||
if url.is_empty() {
|
||||
*PRO.lock().unwrap() = false;
|
||||
continue;
|
||||
}
|
||||
if !Config::get_option("stop-service").is_empty() {
|
||||
@@ -62,6 +68,7 @@ async fn start_hbbs_sync_async() {
|
||||
let conns = Connection::alive_conns();
|
||||
if info_uploaded.0 && url != info_uploaded.1 {
|
||||
info_uploaded.0 = false;
|
||||
*PRO.lock().unwrap() = false;
|
||||
}
|
||||
if !info_uploaded.0 && info_uploaded.2.map(|x| x.elapsed() >= UPLOAD_SYSINFO_TIMEOUT).unwrap_or(true){
|
||||
let mut v = crate::get_sysinfo();
|
||||
@@ -73,6 +80,7 @@ async fn start_hbbs_sync_async() {
|
||||
if x == "SYSINFO_UPDATED" {
|
||||
info_uploaded = (true, url.clone(), None);
|
||||
hbb_common::log::info!("sysinfo updated");
|
||||
*PRO.lock().unwrap() = true;
|
||||
} else if x == "ID_NOT_FOUND" {
|
||||
info_uploaded.2 = None; // next heartbeat will upload sysinfo again
|
||||
} else {
|
||||
@@ -148,3 +156,7 @@ fn handle_config_options(config_options: HashMap<String, String>) {
|
||||
.count();
|
||||
Config::set_options(options);
|
||||
}
|
||||
|
||||
pub fn is_pro() -> bool {
|
||||
PRO.lock().unwrap().clone()
|
||||
}
|
||||
|
||||
@@ -2393,10 +2393,9 @@ async fn start_ipc(
|
||||
stream = Some(s);
|
||||
} else {
|
||||
let mut args = vec!["--cm"];
|
||||
if password::hide_cm() {
|
||||
if crate::hbbs_http::sync::is_pro() && password::hide_cm() {
|
||||
args.push("--hide");
|
||||
};
|
||||
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
#[cfg(target_os = "linux")]
|
||||
let mut user = None;
|
||||
|
||||
Reference in New Issue
Block a user