From 01146574f2471a567a542fc3da43eaea33f0b9d8 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Fri, 23 May 2025 22:15:31 +0800 Subject: [PATCH] prepare no-register-device --- libs/hbb_common | 2 +- src/core_main.rs | 4 +++- src/hbbs_http/sync.rs | 3 ++- src/rendezvous_mediator.rs | 1 + 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libs/hbb_common b/libs/hbb_common index 53709d8f8..fa160b286 160000 --- a/libs/hbb_common +++ b/libs/hbb_common @@ -1 +1 @@ -Subproject commit 53709d8f8dd09a1491f4d8866e9643804caa380b +Subproject commit fa160b286449d4feee26c03dfa721d9997b4748b diff --git a/src/core_main.rs b/src/core_main.rs index 4ce4be7b5..eab989181 100644 --- a/src/core_main.rs +++ b/src/core_main.rs @@ -454,7 +454,9 @@ pub fn core_main() -> Option> { } return None; } else if args[0] == "--assign" { - if crate::platform::is_installed() && is_root() { + if config::Config::no_register_device() { + println!("Cannot assign an unregistrable device!"); + } else if crate::platform::is_installed() && is_root() { let max = args.len() - 1; let pos = args.iter().position(|x| x == "--token").unwrap_or(max); if pos < max { diff --git a/src/hbbs_http/sync.rs b/src/hbbs_http/sync.rs index b82464b24..a94ff7aa2 100644 --- a/src/hbbs_http/sync.rs +++ b/src/hbbs_http/sync.rs @@ -127,7 +127,8 @@ async fn start_hbbs_sync_async() { // Though the username comparison is only necessary on Windows, // we still keep the comparison on other platforms for consistency. let need_upload = (!info_uploaded.uploaded || info_uploaded.username.as_ref() != Some(&sys_username)) && - info_uploaded.last_uploaded.map(|x| x.elapsed() >= UPLOAD_SYSINFO_TIMEOUT).unwrap_or(true); + info_uploaded.last_uploaded.map(|x| x.elapsed() >= UPLOAD_SYSINFO_TIMEOUT).unwrap_or(true) + && !Config::no_register_device(); if need_upload { v["version"] = json!(crate::VERSION); v["id"] = json!(id); diff --git a/src/rendezvous_mediator.rs b/src/rendezvous_mediator.rs index aa31ec323..99e6c3b8f 100644 --- a/src/rendezvous_mediator.rs +++ b/src/rendezvous_mediator.rs @@ -568,6 +568,7 @@ impl RendezvousMediator { id, uuid: uuid.into(), pk: pk.into(), + no_register_device: Config::no_register_device(), ..Default::default() }); socket.send(&msg_out).await?;