mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-09 05:11:29 +03:00
Fix some single device multiple ids scenarios on MacOS (#14196)
* fix(macos): sync config to root when root config is empty Signed-off-by: 21pages <sunboeasy@gmail.com> * fix(server): gate startup on initial config sync; document CheckIfResendPk limitation - wait up to 3s for initial root->local config sync before starting server services - continue startup when timeout is hit, while keeping sync/watch running in background - avoid blocking non-server process startup - clarify that CheckIfResendPk only re-registers PK for current ID and does not solve multi-ID when root uses a non-default mac-generated ID Signed-off-by: 21pages <sunboeasy@gmail.com> --------- Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
@@ -40,6 +40,7 @@ lazy_static::lazy_static! {
|
||||
}
|
||||
static SHOULD_EXIT: AtomicBool = AtomicBool::new(false);
|
||||
static MANUAL_RESTARTED: AtomicBool = AtomicBool::new(false);
|
||||
static SENT_REGISTER_PK: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct RendezvousMediator {
|
||||
@@ -689,6 +690,7 @@ impl RendezvousMediator {
|
||||
..Default::default()
|
||||
});
|
||||
socket.send(&msg_out).await?;
|
||||
SENT_REGISTER_PK.store(true, Ordering::SeqCst);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -904,3 +906,28 @@ async fn udp_nat_listen(
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// When config is not yet synced from root, register_pk may have already been sent with a new generated pk.
|
||||
// After config sync completes, the pk may change. This struct detects pk changes and triggers
|
||||
// a re-registration by setting key_confirmed to false.
|
||||
// NOTE:
|
||||
// This only corrects PK registration for the current ID. If root uses a non-default mac-generated ID,
|
||||
// this does not resolve the multi-ID issue by itself.
|
||||
pub struct CheckIfResendPk {
|
||||
pk: Option<Vec<u8>>,
|
||||
}
|
||||
impl CheckIfResendPk {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
pk: Config::get_cached_pk(),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl Drop for CheckIfResendPk {
|
||||
fn drop(&mut self) {
|
||||
if SENT_REGISTER_PK.load(Ordering::SeqCst) && Config::get_cached_pk() != self.pk {
|
||||
Config::set_key_confirmed(false);
|
||||
log::info!("Set key_confirmed to false due to pk changed, will resend register_pk");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user