An open-source remote desktop application designed for self-hosting, as an alternative to TeamViewer.
Rust androidanydeskdartflatpakflutterflutter-appsioslinuxmacosp2prdpremote-controlremote-desktoprustrust-langteamviewervncwaylandwindows
patch: make linux build ok
ClSlaid30e85c8654f4
diff --git a/libs/clipboard/src/platform/fuse.rs b/libs/clipboard/src/platform/fuse.rsindex 9294ac1db..6c5bbcdd2 100644--- a/libs/clipboard/src/platform/fuse.rs+++ b/libs/clipboard/src/platform/fuse.rs@@ -40,7 +40,6 @@ use utf16string::WStr;use crate::{send_data, ClipboardFile, CliprdrError};-#[cfg(target_os = "linux")]use super::LDAP_EPOCH_DELTA;/// fuse server ready retry max timesdiff --git a/libs/clipboard/src/platform/mod.rs b/libs/clipboard/src/platform/mod.rsindex 1d9a96644..9f76fa8bb 100644--- a/libs/clipboard/src/platform/mod.rs+++ b/libs/clipboard/src/platform/mod.rs@@ -21,7 +21,7 @@ pub mod fuse;#[cfg(feature = "unix-file-copy-paste")]#[cfg(any(target_os = "linux", target_os = "macos"))]pub mod unix;-#[cfg(target_os = "linux")]+#[cfg(any(target_os = "linux", target_os = "macos"))]pub fn create_cliprdr_context(_enable_files: bool,_enable_others: bool,@@ -52,11 +52,11 @@ pub fn create_cliprdr_context(log::warn!("umount {:?} may fail: {:?}", mnt_path, e);}- let linux_ctx = unix::ClipboardContext::new(timeout, mnt_path.parse().unwrap())?;+ let unix_ctx = unix::ClipboardContext::new(timeout, mnt_path.parse().unwrap())?;log::debug!("start cliprdr FUSE");- linux_ctx.run().expect("failed to start cliprdr FUSE");+ unix_ctx.run().expect("failed to start cliprdr FUSE");- Ok(Box::new(linux_ctx) as Box<_>)+ Ok(Box::new(unix_ctx) as Box<_>)}#[cfg(not(feature = "unix-file-copy-paste"))]return Ok(Box::new(DummyCliprdrContext {}) as Box<_>);@@ -83,5 +83,4 @@ impl CliprdrServiceContext for DummyCliprdrContext {#[cfg(feature = "unix-file-copy-paste")]// begin of epoch used by microsoft// 1601-01-01 00:00:00 + LDAP_EPOCH_DELTA*(100 ns) = 1970-01-01 00:00:00-#[cfg(target_os = "linux")]const LDAP_EPOCH_DELTA: u64 = 116444772610000000;diff --git a/libs/clipboard/src/platform/unix/mod.rs b/libs/clipboard/src/platform/unix/mod.rsindex b74c583c8..39b851e10 100644--- a/libs/clipboard/src/platform/unix/mod.rs+++ b/libs/clipboard/src/platform/unix/mod.rs@@ -19,14 +19,17 @@ use crate::{};use self::local_file::LocalFile;+#[cfg(target_os = "linux")]use self::url::{encode_path_to_uri, parse_plain_uri_list};use super::fuse::FuseServer;-#[cfg(not(feature = "wayland"))]+#[cfg(target_os = "linux")]pub mod x11;pub mod local_file;++#[cfg(target_os = "linux")]pub mod url;// not actual format id, just a placeholder@@ -66,6 +69,7 @@ trait SysClipboard: Send + Sync {fn get_file_list(&self) -> Vec<PathBuf>;}+#[cfg(target_os = "linux")]fn get_sys_clipboard(ignore_path: &PathBuf) -> Result<Box<dyn SysClipboard>, CliprdrError> {#[cfg(feature = "wayland")]{@@ -79,6 +83,11 @@ fn get_sys_clipboard(ignore_path: &PathBuf) -> Result<Box<dyn SysClipboard>, Cli}}+#[cfg(target_os = "macos")]+fn get_sys_clipboard(ignore_path: &PathBuf) -> Result<Box<dyn SysClipboard>, CliprdrError> {+ unimplemented!()+}+#[derive(Debug)]enum FileContentsRequest {Size {diff --git a/src/client/io_loop.rs b/src/client/io_loop.rsindex 2d46097ed..377da85e3 100644--- a/src/client/io_loop.rs+++ b/src/client/io_loop.rs@@ -7,14 +7,14 @@ use std::{},};-#[cfg(any(target_os = "windows", target_os = "linux"))]+#[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]use clipboard::ContextSend;use crossbeam_queue::ArrayQueue;#[cfg(not(any(target_os = "android", target_os = "ios")))]use hbb_common::sleep;#[cfg(not(target_os = "ios"))]use hbb_common::tokio::sync::mpsc::error::TryRecvError;-#[cfg(any(target_os = "windows", target_os = "linux"))]+#[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]use hbb_common::tokio::sync::Mutex as TokioMutex;use hbb_common::{allow_err,@@ -66,7 +66,7 @@ pub struct Remote<T: InvokeUiSession> {last_update_jobs_status: (Instant, HashMap<i32, u64>),is_connected: bool,first_frame: bool,- #[cfg(any(target_os = "windows", target_os = "linux"))]+ #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]client_conn_id: i32, // used for file clipboarddata_count: Arc<AtomicUsize>,frame_count_map: Arc<RwLock<HashMap<usize, usize>>>,@@ -101,7 +101,7 @@ impl<T: InvokeUiSession> Remote<T> {last_update_jobs_status: (Instant::now(), Default::default()),is_connected: false,first_frame: false,- #[cfg(any(target_os = "windows", target_os = "linux"))]+ #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]client_conn_id: 0,data_count: Arc::new(AtomicUsize::new(0)),frame_count_map,@@ -146,14 +146,14 @@ impl<T: InvokeUiSession> Remote<T> {}// just build for now- #[cfg(not(any(target_os = "windows", target_os = "linux")))]+ #[cfg(not(any(target_os = "windows", target_os = "linux", target_os = "macos")))]let (_tx_holder, mut rx_clip_client) = mpsc::unbounded_channel::<i32>();- #[cfg(any(target_os = "windows", target_os = "linux"))]+ #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]let (_tx_holder, rx) = mpsc::unbounded_channel();- #[cfg(any(target_os = "windows", target_os = "linux"))]+ #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]let mut rx_clip_client_lock = Arc::new(TokioMutex::new(rx));- #[cfg(any(target_os = "windows", target_os = "linux"))]+ #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]{let is_conn_not_default = self.handler.is_file_transfer()|| self.handler.is_port_forward()@@ -164,7 +164,7 @@ impl<T: InvokeUiSession> Remote<T> {clipboard::get_rx_cliprdr_client(&self.handler.id);};}- #[cfg(any(target_os = "windows", target_os = "linux"))]+ #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]let mut rx_clip_client = rx_clip_client_lock.lock().await;let mut status_timer = time::interval(Duration::new(1, 0));@@ -210,7 +210,7 @@ impl<T: InvokeUiSession> Remote<T> {}}_msg = rx_clip_client.recv() => {- #[cfg(any(target_os="windows", target_os="linux"))]+ #[cfg(any(target_os="windows", target_os="linux", target_os = "macos"))]self.handle_local_clipboard_msg(&mut peer, _msg).await;}_ = self.timer.tick() => {@@ -278,7 +278,7 @@ impl<T: InvokeUiSession> Remote<T> {Client::try_stop_clipboard(&self.handler.id);}- #[cfg(any(target_os = "windows", target_os = "linux"))]+ #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]if _set_disconnected_ok {let conn_id = self.client_conn_id;log::debug!("try empty cliprdr for conn_id {}", conn_id);@@ -289,7 +289,7 @@ impl<T: InvokeUiSession> Remote<T> {}}- #[cfg(any(target_os = "windows", target_os = "linux"))]+ #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]async fn handle_local_clipboard_msg(&self,peer: &mut crate::client::FramedStream,@@ -1143,7 +1143,7 @@ impl<T: InvokeUiSession> Remote<T> {}}}- #[cfg(any(target_os = "windows", target_os = "linux"))]+ #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]Some(message::Union::Cliprdr(clip)) => {self.handle_cliprdr_msg(clip);}@@ -1718,7 +1718,7 @@ impl<T: InvokeUiSession> Remote<T> {}}- #[cfg(any(target_os = "windows", target_os = "linux"))]+ #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]fn handle_cliprdr_msg(&self, clip: hbb_common::message_proto::Cliprdr) {log::debug!("handling cliprdr msg from server peer");#[cfg(feature = "flutter")]diff --git a/src/lib.rs b/src/lib.rsindex 631766a2d..8aa520579 100644--- a/src/lib.rs+++ b/src/lib.rs@@ -58,7 +58,7 @@ mod ui_session_interface;mod hbbs_http;-#[cfg(any(target_os = "windows", target_os = "linux"))]+#[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]pub mod clipboard_file;#[cfg(windows)]diff --git a/src/server/connection.rs b/src/server/connection.rsindex 9601f3ca9..4bbfd6211 100644--- a/src/server/connection.rs+++ b/src/server/connection.rs@@ -1,5 +1,5 @@use super::{input_service::*, *};-#[cfg(any(target_os = "windows", target_os = "linux"))]+#[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]use crate::clipboard_file::*;#[cfg(not(any(target_os = "android", target_os = "ios")))]use crate::common::update_clipboard;@@ -192,7 +192,7 @@ pub struct Connection {// by peerdisable_audio: bool,// by peer- #[cfg(any(target_os = "windows", target_os = "linux"))]+ #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]enable_file_transfer: bool,// by peeraudio_sender: Option<MediaSender>,@@ -330,7 +330,7 @@ impl Connection {show_remote_cursor: false,ip: "".to_owned(),disable_audio: false,- #[cfg(any(target_os = "windows", target_os = "linux"))]+ #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]enable_file_transfer: false,disable_clipboard: false,disable_keyboard: false,@@ -1032,7 +1032,7 @@ impl Connection {pi.hostname = DEVICE_NAME.lock().unwrap().clone();pi.platform = "Android".into();}- #[cfg(any(target_os = "linux", target_os = "windows"))]+ #[cfg(any(target_os = "linux", target_os = "windows", target_os = "macos"))]let mut platform_additions = serde_json::Map::new();#[cfg(target_os = "linux")]{@@ -1247,7 +1247,7 @@ impl Connection {self.audio && !self.disable_audio}- #[cfg(any(target_os = "windows", target_os = "linux"))]+ #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]fn file_transfer_enabled(&self) -> bool {self.file && self.enable_file_transfer}@@ -1817,7 +1817,7 @@ impl Connection {}Some(message::Union::Cliprdr(_clip)) =>{- #[cfg(any(target_os = "windows", target_os = "linux"))]+ #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]if let Some(clip) = msg_2_clip(_clip) {log::debug!("got clipfile from client peer");self.send_to_cm(ipc::Data::ClipboardFile(clip))@@ -2401,7 +2401,7 @@ impl Connection {}}}- #[cfg(any(target_os = "windows", target_os = "linux"))]+ #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]if let Ok(q) = o.enable_file_transfer.enum_value() {if q != BoolOption::NotSet {self.enable_file_transfer = q == BoolOption::Yes;diff --git a/src/ui_cm_interface.rs b/src/ui_cm_interface.rsindex 83c43d24b..a20997dc9 100644--- a/src/ui_cm_interface.rs+++ b/src/ui_cm_interface.rs@@ -1,6 +1,6 @@#[cfg(any(target_os = "android", target_os = "ios", feature = "flutter"))]use std::iter::FromIterator;-#[cfg(any(target_os = "windows", target_os = "linux"))]+#[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]use std::sync::Arc;use std::{collections::HashMap,@@ -15,11 +15,11 @@ use std::{use crate::ipc::Connection;#[cfg(not(any(target_os = "ios")))]use crate::ipc::{self, Data};-#[cfg(any(target_os = "windows", target_os = "linux"))]+#[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]use clipboard::ContextSend;#[cfg(not(any(target_os = "android", target_os = "ios")))]use hbb_common::tokio::sync::mpsc::unbounded_channel;-#[cfg(any(target_os = "windows", target_os = "linux"))]+#[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]use hbb_common::tokio::sync::Mutex as TokioMutex;use hbb_common::{allow_err,@@ -70,9 +70,9 @@ struct IpcTaskRunner<T: InvokeUiCM> {close: bool,running: bool,conn_id: i32,- #[cfg(any(target_os = "windows", target_os = "linux"))]+ #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]file_transfer_enabled: bool,- #[cfg(any(target_os = "windows", target_os = "linux"))]+ #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]file_transfer_enabled_peer: bool,}@@ -165,7 +165,7 @@ impl<T: InvokeUiCM> ConnectionManager<T> {}#[inline]- #[cfg(any(target_os = "windows", target_os = "linux"))]+ #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]fn is_authorized(&self, id: i32) -> bool {CLIENTS.read()@@ -186,7 +186,7 @@ impl<T: InvokeUiCM> ConnectionManager<T> {.map(|c| c.disconnected = true);}- #[cfg(any(target_os = "windows", target_os = "linux"))]+ #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]{let _ = ContextSend::proc(|context| -> ResultType<()> {context.empty_clipboard(id)?;@@ -330,14 +330,14 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> {// for tmp use, without real conn idlet mut write_jobs: Vec<fs::TransferJob> = Vec::new();- #[cfg(any(target_os = "windows", target_os = "linux"))]+ #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]let is_authorized = self.cm.is_authorized(self.conn_id);- #[cfg(any(target_os = "windows", target_os = "linux"))]+ #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]let rx_clip1;let mut rx_clip;let _tx_clip;- #[cfg(any(target_os = "windows", target_os = "linux"))]+ #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]if self.conn_id > 0 && is_authorized {log::debug!("Clipboard is enabled from client peer: type 1");rx_clip1 = clipboard::get_rx_cliprdr_server(self.conn_id);@@ -349,12 +349,12 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> {rx_clip1 = Arc::new(TokioMutex::new(rx_clip2));rx_clip = rx_clip1.lock().await;}- #[cfg(not(any(target_os = "windows", target_os = "linux")))]+ #[cfg(not(any(target_os = "windows", target_os = "linux", target_os = "macos")))]{(_tx_clip, rx_clip) = unbounded_channel::<i32>();}- #[cfg(any(target_os = "windows", target_os = "linux"))]+ #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]{if ContextSend::is_enabled() {log::debug!("Clipboard is enabled");@@ -382,7 +382,7 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> {log::debug!("conn_id: {}", id);self.cm.add_connection(id, is_file_transfer, port_forward, peer_id, name, authorized, keyboard, clipboard, audio, file, restart, recording, from_switch,self.tx.clone());self.conn_id = id;- #[cfg(any(target_os = "linux", target_os = "windows"))]+ #[cfg(any(target_os = "linux", target_os = "windows", target_os = "macos"))]{self.file_transfer_enabled = _file_transfer_enabled;}@@ -425,7 +425,7 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> {}#[cfg(not(any(target_os = "android", target_os = "ios")))]Data::ClipboardFile(_clip) => {- #[cfg(any(target_os = "windows", target_os="linux"))]+ #[cfg(any(target_os = "windows", target_os="linux", target_os = "macos"))]{let is_stopping_allowed = _clip.is_stopping_allowed_from_peer();let is_clipboard_enabled = ContextSend::is_enabled();@@ -504,7 +504,7 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> {},clip_file = rx_clip.recv() => match clip_file {Some(_clip) => {- #[cfg(any(target_os = "windows", target_os ="linux"))]+ #[cfg(any(target_os = "windows", target_os ="linux", target_os = "macos"))]{let is_stopping_allowed = _clip.is_stopping_allowed();let is_clipboard_enabled = ContextSend::is_enabled();@@ -543,9 +543,9 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> {close: true,running: true,conn_id: 0,- #[cfg(any(target_os = "windows", target_os = "linux"))]+ #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]file_transfer_enabled: false,- #[cfg(any(target_os = "windows", target_os = "linux"))]+ #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]file_transfer_enabled_peer: false,};diff --git a/src/ui_interface.rs b/src/ui_interface.rsindex 5379b4a55..7cabdf790 100644--- a/src/ui_interface.rs+++ b/src/ui_interface.rs@@ -1007,7 +1007,7 @@ async fn check_connect_status_(reconnect: bool, rx: mpsc::UnboundedReceiver<ipc:let mut mouse_time = 0;#[cfg(not(feature = "flutter"))]let mut id = "".to_owned();- #[cfg(any(target_os = "windows", target_os = "linux"))]+ #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]#[allow(unused_mut, dead_code)]let mut enable_file_transfer = "".to_owned();@@ -1032,7 +1032,7 @@ async fn check_connect_status_(reconnect: bool, rx: mpsc::UnboundedReceiver<ipc:*OPTION_SYNCED.lock().unwrap() = true;#[cfg(any(- target_os="windows",+ target_os = "windows",all(any(target_os="linux", target_os = "macos"),feature = "unix-file-copy-paste"