From 83bf067d187624ceb04c4765bf3148cb19f0767a Mon Sep 17 00:00:00 2001 From: fufesou <13586388+fufesou@users.noreply.github.com> Date: Mon, 12 Aug 2024 21:53:41 +0800 Subject: [PATCH] fix: not plug virtual dislay, non win, installed (#9034) Signed-off-by: fufesou --- src/client/io_loop.rs | 45 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/client/io_loop.rs b/src/client/io_loop.rs index 537de56ad..15c6c24b5 100644 --- a/src/client/io_loop.rs +++ b/src/client/io_loop.rs @@ -73,6 +73,22 @@ pub struct Remote { fps_control: FpsControl, decode_fps: Arc>>, chroma: Arc>>, + peer_info: ParsedPeerInfo, +} + +#[derive(Default)] +struct ParsedPeerInfo { + platform: String, + is_installed: bool, + idd_impl: String, +} + +impl ParsedPeerInfo { + fn is_support_virtual_display(&self) -> bool { + self.is_installed + && self.platform == "Windows" + && (self.idd_impl == "rustdesk_idd" || self.idd_impl == "amyuni_idd") + } } impl Remote { @@ -112,6 +128,7 @@ impl Remote { fps_control: Default::default(), decode_fps, chroma, + peer_info: Default::default(), } } @@ -938,6 +955,9 @@ impl Remote { } async fn send_toggle_virtual_display_msg(&self, peer: &mut Stream) { + if !self.peer_info.is_support_virtual_display() { + return; + } let lc = self.handler.lc.read().unwrap(); let displays = lc.get_option("virtual-display"); for d in displays.split(',') { @@ -961,6 +981,11 @@ impl Remote { && lc.get_toggle_option("privacy-mode") { let impl_key = lc.get_option("privacy-mode-impl-key"); + if impl_key == crate::privacy_mode::PRIVACY_MODE_IMPL_WIN_VIRTUAL_DISPLAY + && !self.peer_info.is_support_virtual_display() + { + return; + } let mut misc = Misc::new(); misc.set_toggle_privacy_mode(TogglePrivacyMode { impl_key, @@ -1146,6 +1171,7 @@ impl Remote { Some(login_response::Union::PeerInfo(pi)) => { let peer_version = pi.version.clone(); let peer_platform = pi.platform.clone(); + self.set_peer_info(&pi); self.handler.handle_peer_info(pi); self.check_clipboard_file_context(); if !(self.handler.is_file_transfer() || self.handler.is_port_forward()) { @@ -1636,6 +1662,25 @@ impl Remote { true } + fn set_peer_info(&mut self, pi: &PeerInfo) { + self.peer_info.platform = pi.platform.clone(); + if let Ok(platform_additions) = + serde_json::from_str::>(&pi.platform_additions) + { + self.peer_info.is_installed = platform_additions + .get("is_installed") + .map(|v| v.as_bool()) + .flatten() + .unwrap_or(false); + self.peer_info.idd_impl = platform_additions + .get("idd_impl") + .map(|v| v.as_str()) + .flatten() + .unwrap_or_default() + .to_string(); + } + } + async fn handle_back_notification(&mut self, notification: BackNotification) -> bool { match notification.union { Some(back_notification::Union::BlockInputState(state)) => {