mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
remove linux_headless/appimage/flatpak feature
This commit is contained in:
@@ -81,8 +81,7 @@ pub const SEC30: Duration = Duration::from_secs(30);
|
||||
pub const VIDEO_QUEUE_SIZE: usize = 120;
|
||||
const MAX_DECODE_FAIL_COUNTER: usize = 10; // Currently, failed decode cause refresh_video, so make it small
|
||||
|
||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||
#[cfg(target_os = "linux")]
|
||||
pub const LOGIN_MSG_DESKTOP_NOT_INITED: &str = "Desktop env is not inited";
|
||||
pub const LOGIN_MSG_DESKTOP_SESSION_NOT_READY: &str = "Desktop session not ready";
|
||||
pub const LOGIN_MSG_DESKTOP_XSESSION_FAILED: &str = "Desktop xsession failed";
|
||||
|
||||
@@ -774,8 +774,7 @@ pub fn main_get_error() -> String {
|
||||
}
|
||||
|
||||
pub fn main_show_option(_key: String) -> SyncReturn<bool> {
|
||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||
#[cfg(target_os = "linux")]
|
||||
if _key.eq(config::CONFIG_OPTION_ALLOW_LINUX_HEADLESS) {
|
||||
return SyncReturn(true);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
use super::{CursorData, ResultType};
|
||||
use desktop::Desktop;
|
||||
#[cfg(all(feature = "linux_headless"))]
|
||||
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||
use hbb_common::config::CONFIG_OPTION_ALLOW_LINUX_HEADLESS;
|
||||
pub use hbb_common::platform::linux::*;
|
||||
use hbb_common::{
|
||||
@@ -96,8 +94,6 @@ pub struct xcb_xfixes_get_cursor_image {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[cfg(feature = "linux_headless")]
|
||||
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||
pub fn is_headless_allowed() -> bool {
|
||||
Config::get_option(CONFIG_OPTION_ALLOW_LINUX_HEADLESS) == "Y"
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ fn check_desktop_manager() {
|
||||
}
|
||||
}
|
||||
|
||||
// --server process
|
||||
pub fn start_xdesktop() {
|
||||
debug_assert!(crate::is_sever());
|
||||
std::thread::spawn(|| {
|
||||
*DESKTOP_MANAGER.lock().unwrap() = Some(DesktopManager::new());
|
||||
|
||||
@@ -91,6 +91,7 @@ fn detect_headless() -> Option<&'static str> {
|
||||
}
|
||||
|
||||
pub fn try_start_desktop(_username: &str, _passsword: &str) -> String {
|
||||
debug_assert!(crate::is_sever());
|
||||
if _username.is_empty() {
|
||||
let username = get_username();
|
||||
if username.is_empty() {
|
||||
|
||||
@@ -20,8 +20,7 @@ pub mod delegate;
|
||||
#[cfg(target_os = "linux")]
|
||||
pub mod linux;
|
||||
|
||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||
#[cfg(target_os = "linux")]
|
||||
pub mod linux_desktop_manager;
|
||||
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
|
||||
@@ -15,8 +15,8 @@ use hbb_common::{
|
||||
config::{self, Config, CONNECT_TIMEOUT, READ_TIMEOUT, REG_INTERVAL, RENDEZVOUS_PORT},
|
||||
futures::future::join_all,
|
||||
log,
|
||||
proxy::Proxy,
|
||||
protobuf::Message as _,
|
||||
proxy::Proxy,
|
||||
rendezvous_proto::*,
|
||||
sleep,
|
||||
socket_client::{self, connect_tcp, is_ipv4},
|
||||
@@ -89,9 +89,10 @@ impl RendezvousMediator {
|
||||
});
|
||||
}
|
||||
// It is ok to run xdesktop manager when the headless function is not allowed.
|
||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||
crate::platform::linux_desktop_manager::start_xdesktop();
|
||||
#[cfg(target_os = "linux")]
|
||||
if crate::is_server() {
|
||||
crate::platform::linux_desktop_manager::start_xdesktop();
|
||||
}
|
||||
loop {
|
||||
let conn_start_time = Instant::now();
|
||||
*SOLVING_PK_MISMATCH.lock().await = "".to_owned();
|
||||
@@ -128,11 +129,6 @@ impl RendezvousMediator {
|
||||
}
|
||||
}
|
||||
}
|
||||
// It should be better to call stop_xdesktop.
|
||||
// But for server, it also is Ok without calling this method.
|
||||
// #[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||
// #[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||
// crate::platform::linux_desktop_manager::stop_xdesktop();
|
||||
}
|
||||
|
||||
fn get_host_prefix(host: &str) -> String {
|
||||
|
||||
@@ -560,8 +560,7 @@ async fn sync_and_watch_config_dir() {
|
||||
|
||||
let mut cfg0 = (Config::get(), Config2::get());
|
||||
let mut synced = false;
|
||||
let is_server = std::env::args().nth(1) == Some("--server".to_owned());
|
||||
let tries = if is_server { 30 } else { 3 };
|
||||
let tries = if crate::is_server() { 30 } else { 3 };
|
||||
log::debug!("#tries of ipc service connection: {}", tries);
|
||||
use hbb_common::sleep;
|
||||
for i in 1..=tries {
|
||||
|
||||
@@ -7,8 +7,7 @@ use crate::common::update_clipboard;
|
||||
use crate::keyboard::client::map_key_to_control_key;
|
||||
#[cfg(target_os = "linux")]
|
||||
use crate::platform::linux::is_x11;
|
||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||
#[cfg(target_os = "linux")]
|
||||
use crate::platform::linux_desktop_manager;
|
||||
#[cfg(any(target_os = "windows", target_os = "linux"))]
|
||||
use crate::platform::WallPaperRemover;
|
||||
@@ -24,8 +23,7 @@ use crate::{
|
||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
use crate::{common::DEVICE_NAME, flutter::connection_manager::start_channel};
|
||||
use cidr_utils::cidr::IpCidr;
|
||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||
#[cfg(target_os = "linux")]
|
||||
use hbb_common::platform::linux::run_cmds;
|
||||
#[cfg(target_os = "android")]
|
||||
use hbb_common::protobuf::EnumOrUnknown;
|
||||
@@ -224,8 +222,7 @@ pub struct Connection {
|
||||
options_in_login: Option<OptionMessage>,
|
||||
#[cfg(not(any(target_os = "ios")))]
|
||||
pressed_modifiers: HashSet<rdev::Key>,
|
||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||
#[cfg(target_os = "linux")]
|
||||
linux_headless_handle: LinuxHeadlessHandle,
|
||||
closed: bool,
|
||||
delay_response_instant: Instant,
|
||||
@@ -312,8 +309,7 @@ impl Connection {
|
||||
let (tx_cm_stream_ready, _rx_cm_stream_ready) = mpsc::channel(1);
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
let (_tx_desktop_ready, rx_desktop_ready) = mpsc::channel(1);
|
||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||
#[cfg(target_os = "linux")]
|
||||
let linux_headless_handle =
|
||||
LinuxHeadlessHandle::new(_rx_cm_stream_ready, _tx_desktop_ready);
|
||||
|
||||
@@ -376,8 +372,7 @@ impl Connection {
|
||||
options_in_login: None,
|
||||
#[cfg(not(any(target_os = "ios")))]
|
||||
pressed_modifiers: Default::default(),
|
||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||
#[cfg(target_os = "linux")]
|
||||
linux_headless_handle,
|
||||
closed: false,
|
||||
delay_response_instant: Instant::now(),
|
||||
@@ -1128,8 +1123,7 @@ impl Connection {
|
||||
if crate::platform::current_is_wayland() {
|
||||
platform_additions.insert("is_wayland".into(), json!(true));
|
||||
}
|
||||
#[cfg(feature = "linux_headless")]
|
||||
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||
#[cfg(target_os = "linux")]
|
||||
if crate::platform::is_headless_allowed() {
|
||||
if linux_desktop_manager::is_headless() {
|
||||
platform_additions.insert("headless".into(), json!(true));
|
||||
@@ -1670,14 +1664,9 @@ impl Connection {
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
self.try_start_cm_ipc();
|
||||
|
||||
#[cfg(any(
|
||||
feature = "flatpak",
|
||||
feature = "appimage",
|
||||
not(all(target_os = "linux", feature = "linux_headless"))
|
||||
))]
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
let err_msg = "".to_owned();
|
||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||
#[cfg(target_os = "linux")]
|
||||
let err_msg = self
|
||||
.linux_headless_handle
|
||||
.try_start_desktop(lr.os_login.as_ref());
|
||||
@@ -1714,8 +1703,7 @@ impl Connection {
|
||||
return false;
|
||||
} else if self.is_recent_session(false) {
|
||||
if err_msg.is_empty() {
|
||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||
#[cfg(target_os = "linux")]
|
||||
self.linux_headless_handle.wait_desktop_cm_ready().await;
|
||||
self.send_logon_response().await;
|
||||
self.try_start_cm(lr.my_id.clone(), lr.my_name.clone(), self.authorized);
|
||||
@@ -1751,8 +1739,7 @@ impl Connection {
|
||||
} else {
|
||||
self.update_failure(failure, true, 0);
|
||||
if err_msg.is_empty() {
|
||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||
#[cfg(target_os = "linux")]
|
||||
self.linux_headless_handle.wait_desktop_cm_ready().await;
|
||||
self.send_logon_response().await;
|
||||
self.try_start_cm(lr.my_id, lr.my_name, self.authorized);
|
||||
@@ -3226,8 +3213,7 @@ async fn start_ipc(
|
||||
let mut user = None;
|
||||
|
||||
// Cm run as user, wait until desktop session is ready.
|
||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||
#[cfg(target_os = "linux")]
|
||||
if crate::platform::is_headless_allowed() && linux_desktop_manager::is_headless() {
|
||||
let mut username = linux_desktop_manager::get_username();
|
||||
loop {
|
||||
@@ -3545,8 +3531,7 @@ impl Drop for Connection {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||
#[cfg(target_os = "linux")]
|
||||
struct LinuxHeadlessHandle {
|
||||
pub is_headless_allowed: bool,
|
||||
pub is_headless: bool,
|
||||
@@ -3555,11 +3540,10 @@ struct LinuxHeadlessHandle {
|
||||
pub tx_desktop_ready: mpsc::Sender<()>,
|
||||
}
|
||||
|
||||
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
||||
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
||||
#[cfg(target_os = "linux")]
|
||||
impl LinuxHeadlessHandle {
|
||||
pub fn new(rx_cm_stream_ready: mpsc::Receiver<()>, tx_desktop_ready: mpsc::Sender<()>) -> Self {
|
||||
let is_headless_allowed = crate::platform::is_headless_allowed();
|
||||
let is_headless_allowed = crate::is_server() && crate::platform::is_headless_allowed();
|
||||
let is_headless = is_headless_allowed && linux_desktop_manager::is_headless();
|
||||
Self {
|
||||
is_headless_allowed,
|
||||
|
||||
26
src/ui.rs
26
src/ui.rs
@@ -41,15 +41,23 @@ pub fn start(args: &mut [String]) {
|
||||
crate::platform::delegate::show_dock();
|
||||
#[cfg(all(target_os = "linux", feature = "inline"))]
|
||||
{
|
||||
#[cfg(feature = "appimage")]
|
||||
let prefix = std::env::var("APPDIR").unwrap_or("".to_string());
|
||||
#[cfg(not(feature = "appimage"))]
|
||||
let prefix = "".to_string();
|
||||
#[cfg(feature = "flatpak")]
|
||||
let dir = "/app";
|
||||
#[cfg(not(feature = "flatpak"))]
|
||||
let dir = "/usr";
|
||||
sciter::set_library(&(prefix + dir + "/lib/rustdesk/libsciter-gtk.so")).ok();
|
||||
let app_dir = std::env::var("APPDIR").unwrap_or("".to_string());
|
||||
let mut so_path = "/usr/lib/rustdesk/libsciter-gtk.so".to_owned();
|
||||
for (prefix, dir) in [
|
||||
("", "/usr"),
|
||||
("", "/app"),
|
||||
(&app_dir, "/usr"),
|
||||
(&app_dir, "/app"),
|
||||
]
|
||||
.iter()
|
||||
{
|
||||
let path = format!("{prefix}{dir}/lib/rustdesk/libsciter-gtk.so");
|
||||
if std::path::Path::new(&path).exists() {
|
||||
so_path = path;
|
||||
break;
|
||||
}
|
||||
}
|
||||
sciter::set_library(&so_path).ok();
|
||||
}
|
||||
#[cfg(windows)]
|
||||
// Check if there is a sciter.dll nearby.
|
||||
|
||||
@@ -913,8 +913,6 @@ pub fn is_root() -> bool {
|
||||
#[cfg(any(target_os = "android", target_os = "ios", feature = "flutter"))]
|
||||
#[inline]
|
||||
pub fn check_super_user_permission() -> bool {
|
||||
#[cfg(feature = "flatpak")]
|
||||
return true;
|
||||
#[cfg(any(windows, target_os = "linux", target_os = "macos"))]
|
||||
return crate::platform::check_super_user_permission().unwrap_or(false);
|
||||
#[cfg(not(any(windows, target_os = "linux", target_os = "macos")))]
|
||||
|
||||
Reference in New Issue
Block a user