mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
Merge branch 'rustdesk:master' into master
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use crate::client::{
|
||||
Client, CodecFormat, FileManager, MediaData, MediaSender, QualityStatus, MILLI1, SEC30,
|
||||
Client, CodecFormat, MediaData, MediaSender, QualityStatus, MILLI1, SEC30,
|
||||
SERVER_CLIPBOARD_ENABLED, SERVER_FILE_TRANSFER_ENABLED, SERVER_KEYBOARD_ENABLED,
|
||||
};
|
||||
use crate::common;
|
||||
@@ -15,7 +15,7 @@ use crate::{client::Data, client::Interface};
|
||||
use hbb_common::config::{PeerConfig, TransferSerde};
|
||||
use hbb_common::fs::{
|
||||
can_enable_overwrite_detection, get_job, get_string, new_send_confirm, DigestCheckResult,
|
||||
RemoveJobMeta, TransferJobMeta,
|
||||
RemoveJobMeta,
|
||||
};
|
||||
use hbb_common::message_proto::permission_info::Permission;
|
||||
use hbb_common::protobuf::Message as _;
|
||||
@@ -23,6 +23,7 @@ use hbb_common::rendezvous_proto::ConnType;
|
||||
use hbb_common::tokio::{
|
||||
self,
|
||||
sync::mpsc,
|
||||
sync::Mutex as TokioMutex,
|
||||
time::{self, Duration, Instant, Interval},
|
||||
};
|
||||
use hbb_common::{
|
||||
@@ -113,15 +114,23 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
// just build for now
|
||||
#[cfg(not(windows))]
|
||||
let (_tx_holder, mut rx_clip_client) = mpsc::unbounded_channel::<i32>();
|
||||
|
||||
#[cfg(windows)]
|
||||
let (client_conn_id, rx_clip_client1) =
|
||||
clipboard::get_rx_cliprdr_client(&self.handler.id);
|
||||
let (_tx_holder, rx) = mpsc::unbounded_channel();
|
||||
#[cfg(windows)]
|
||||
let mut rx_clip_client = rx_clip_client1.lock().await;
|
||||
let mut rx_clip_client_lock = Arc::new(TokioMutex::new(rx));
|
||||
#[cfg(windows)]
|
||||
{
|
||||
self.client_conn_id = client_conn_id;
|
||||
let is_conn_not_default = self.handler.is_file_transfer()
|
||||
|| self.handler.is_port_forward()
|
||||
|| self.handler.is_rdp();
|
||||
if !is_conn_not_default {
|
||||
(self.client_conn_id, rx_clip_client_lock) =
|
||||
clipboard::get_rx_cliprdr_client(&self.handler.id);
|
||||
};
|
||||
}
|
||||
#[cfg(windows)]
|
||||
let mut rx_clip_client = rx_clip_client_lock.lock().await;
|
||||
|
||||
let mut status_timer = time::interval(Duration::new(1, 0));
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
future::Future,
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
@@ -27,6 +26,9 @@ pub type NotifyMessageBox = fn(String, String, String, String) -> dyn Future<Out
|
||||
pub const CLIPBOARD_NAME: &'static str = "clipboard";
|
||||
pub const CLIPBOARD_INTERVAL: u64 = 333;
|
||||
|
||||
// the executable name of the portable version
|
||||
pub const PORTABLE_APPNAME_RUNTIME_ENV_KEY: &str = "RUSTDESK_APPNAME";
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
pub static ref CONTENT: Arc<Mutex<String>> = Default::default();
|
||||
pub static ref SOFTWARE_UPDATE_URL: Arc<Mutex<String>> = Default::default();
|
||||
|
||||
@@ -85,11 +85,6 @@ pub fn core_main() -> Option<Vec<String>> {
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
#[cfg(windows)]
|
||||
#[cfg(not(debug_assertions))]
|
||||
if !crate::platform::is_installed() && args.is_empty() {
|
||||
crate::platform::elevate_or_run_as_system(is_setup, _is_elevate, _is_run_as_system);
|
||||
}
|
||||
if args.is_empty() {
|
||||
std::thread::spawn(move || crate::start_server(false));
|
||||
} else {
|
||||
|
||||
@@ -418,6 +418,7 @@ pub fn session_start_(id: &str, event_stream: StreamSink<EventToUI>) -> ResultTy
|
||||
pub mod connection_manager {
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[cfg(any(target_os = "android"))]
|
||||
use hbb_common::log;
|
||||
#[cfg(any(target_os = "android"))]
|
||||
use scrap::android::call_main_service_set_by_name;
|
||||
|
||||
@@ -7,13 +7,14 @@ use std::{
|
||||
use flutter_rust_bridge::{StreamSink, SyncReturn, ZeroCopyBuffer};
|
||||
use serde_json::json;
|
||||
|
||||
use hbb_common::ResultType;
|
||||
use hbb_common::{
|
||||
config::{self, LocalConfig, PeerConfig, ONLINE},
|
||||
fs, log,
|
||||
};
|
||||
use hbb_common::{message_proto::Hash, ResultType};
|
||||
|
||||
use crate::flutter::{self, SESSIONS};
|
||||
#[cfg(target_os = "android")]
|
||||
use crate::start_server;
|
||||
use crate::ui_interface::{self, *};
|
||||
use crate::{
|
||||
@@ -362,7 +363,7 @@ pub fn session_create_dir(id: String, act_id: i32, path: String, is_remote: bool
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_read_local_dir_sync(id: String, path: String, show_hidden: bool) -> String {
|
||||
pub fn session_read_local_dir_sync(_id: String, path: String, show_hidden: bool) -> String {
|
||||
if let Ok(fd) = fs::read_dir(&fs::get_path(&path), show_hidden) {
|
||||
return make_fd_to_json(fd.id, path, &fd.entries);
|
||||
}
|
||||
|
||||
@@ -34,5 +34,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("uac_warning", "Temporarily denied access due to elevation request, please wait for the remote user to accept the UAC dialog. To avoid this problem, it is recommended to install the software on the remote device or run it with administrator privileges."),
|
||||
("elevated_foreground_window_warning", "Temporarily unable to use the mouse and keyboard, because the current window of the remote desktop requires higher privilege to operate, you can request the remote user to minimize the current window. To avoid this problem, it is recommended to install the software on the remote device or run it with administrator privileges."),
|
||||
("JumpLink", "View"),
|
||||
("Stop service", "Stop Service"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use super::{CursorData, ResultType};
|
||||
use crate::common::PORTABLE_APPNAME_RUNTIME_ENV_KEY;
|
||||
use crate::ipc;
|
||||
use crate::license::*;
|
||||
use hbb_common::{
|
||||
@@ -21,7 +22,10 @@ use winapi::{
|
||||
errhandlingapi::GetLastError,
|
||||
handleapi::CloseHandle,
|
||||
minwinbase::STILL_ACTIVE,
|
||||
processthreadsapi::{GetCurrentProcess, GetExitCodeProcess, OpenProcess, OpenProcessToken},
|
||||
processthreadsapi::{
|
||||
GetCurrentProcess, GetCurrentProcessId, GetExitCodeProcess, OpenProcess,
|
||||
OpenProcessToken,
|
||||
},
|
||||
securitybaseapi::GetTokenInformation,
|
||||
shellapi::ShellExecuteA,
|
||||
winbase::*,
|
||||
@@ -878,23 +882,35 @@ fn get_install_info_with_subkey(subkey: String) -> (String, String, String, Stri
|
||||
(subkey, path, start_menu, exe)
|
||||
}
|
||||
|
||||
pub fn copy_exe_cmd(src_exe: &str, _exe: &str, _path: &str) -> String {
|
||||
pub fn copy_exe_cmd(src_exe: &str, _exe: &str, path: &str) -> String {
|
||||
#[cfg(feature = "flutter")]
|
||||
return format!(
|
||||
let main_exe = format!(
|
||||
"XCOPY \"{}\" \"{}\" /Y /E /H /C /I /K /R /Z",
|
||||
PathBuf::from(src_exe)
|
||||
.parent()
|
||||
.unwrap()
|
||||
.to_string_lossy()
|
||||
.to_string(),
|
||||
_path
|
||||
path
|
||||
);
|
||||
#[cfg(not(feature = "flutter"))]
|
||||
return format!(
|
||||
let main_exe = format!(
|
||||
"copy /Y \"{src_exe}\" \"{exe}\"",
|
||||
src_exe = src_exe,
|
||||
exe = _exe
|
||||
);
|
||||
|
||||
return format!(
|
||||
"
|
||||
{main_exe}
|
||||
copy /Y \"{ORIGIN_PROCESS_EXE}\" \"{path}\\{broker_exe}\"
|
||||
\"{src_exe}\" --extract \"{path}\"
|
||||
",
|
||||
main_exe = main_exe,
|
||||
path = path,
|
||||
ORIGIN_PROCESS_EXE = crate::ui::win_privacy::ORIGIN_PROCESS_EXE,
|
||||
broker_exe = crate::ui::win_privacy::INJECTED_PROCESS_EXE,
|
||||
);
|
||||
}
|
||||
|
||||
pub fn update_me() -> ResultType<()> {
|
||||
@@ -905,18 +921,16 @@ pub fn update_me() -> ResultType<()> {
|
||||
chcp 65001
|
||||
sc stop {app_name}
|
||||
taskkill /F /IM {broker_exe}
|
||||
taskkill /F /IM {app_name}.exe
|
||||
taskkill /F /IM {app_name}.exe /FI \"PID ne {cur_pid}\"
|
||||
{copy_exe}
|
||||
\"{src_exe}\" --extract \"{path}\"
|
||||
sc start {app_name}
|
||||
{lic}
|
||||
",
|
||||
src_exe = src_exe,
|
||||
copy_exe = copy_exe_cmd(&src_exe, &exe, &path),
|
||||
broker_exe = crate::ui::win_privacy::INJECTED_PROCESS_EXE,
|
||||
path = path,
|
||||
app_name = crate::get_app_name(),
|
||||
lic = register_licence(),
|
||||
cur_pid = get_current_pid(),
|
||||
);
|
||||
std::thread::sleep(std::time::Duration::from_millis(1000));
|
||||
run_cmds(cmds, false, "update")?;
|
||||
@@ -1087,8 +1101,6 @@ if exist \"{tmp_path}\\{app_name} Tray.lnk\" del /f /q \"{tmp_path}\\{app_name}
|
||||
chcp 65001
|
||||
md \"{path}\"
|
||||
{copy_exe}
|
||||
copy /Y \"{ORIGIN_PROCESS_EXE}\" \"{path}\\{broker_exe}\"
|
||||
\"{src_exe}\" --extract \"{path}\"
|
||||
reg add {subkey} /f
|
||||
reg add {subkey} /f /v DisplayIcon /t REG_SZ /d \"{exe}\"
|
||||
reg add {subkey} /f /v DisplayName /t REG_SZ /d \"{app_name}\"
|
||||
@@ -1119,10 +1131,7 @@ sc delete {app_name}
|
||||
",
|
||||
uninstall_str=uninstall_str,
|
||||
path=path,
|
||||
src_exe=src_exe,
|
||||
exe=exe,
|
||||
ORIGIN_PROCESS_EXE = crate::ui::win_privacy::ORIGIN_PROCESS_EXE,
|
||||
broker_exe=crate::ui::win_privacy::INJECTED_PROCESS_EXE,
|
||||
subkey=subkey,
|
||||
app_name=crate::get_app_name(),
|
||||
version=crate::VERSION,
|
||||
@@ -1178,13 +1187,14 @@ fn get_before_uninstall() -> String {
|
||||
sc stop {app_name}
|
||||
sc delete {app_name}
|
||||
taskkill /F /IM {broker_exe}
|
||||
taskkill /F /IM {app_name}.exe
|
||||
taskkill /F /IM {app_name}.exe /FI \"PID ne {cur_pid}\"
|
||||
reg delete HKEY_CLASSES_ROOT\\.{ext} /f
|
||||
netsh advfirewall firewall delete rule name=\"{app_name} Service\"
|
||||
",
|
||||
app_name = app_name,
|
||||
broker_exe = crate::ui::win_privacy::INJECTED_PROCESS_EXE,
|
||||
ext = ext
|
||||
ext = ext,
|
||||
cur_pid = get_current_pid(),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1324,7 +1334,12 @@ fn get_reg_of(subkey: &str, name: &str) -> String {
|
||||
}
|
||||
|
||||
fn get_license_from_exe_name() -> ResultType<License> {
|
||||
let exe = std::env::current_exe()?.to_str().unwrap_or("").to_owned();
|
||||
let mut exe = std::env::current_exe()?.to_str().unwrap_or("").to_owned();
|
||||
// if defined portable appname entry, replace original executable name with it.
|
||||
if let Ok(portable_exe) = std::env::var(PORTABLE_APPNAME_RUNTIME_ENV_KEY) {
|
||||
exe = portable_exe;
|
||||
log::debug!("update portable executable name to {}", exe);
|
||||
}
|
||||
get_license_from_string(&exe)
|
||||
}
|
||||
|
||||
@@ -1613,3 +1628,7 @@ pub fn is_foreground_window_elevated() -> ResultType<bool> {
|
||||
is_elevated(Some(process_id))
|
||||
}
|
||||
}
|
||||
|
||||
fn get_current_pid() -> u32 {
|
||||
unsafe { GetCurrentProcessId() }
|
||||
}
|
||||
|
||||
@@ -725,7 +725,7 @@ fn legacy_keyboard_mode(evt: &KeyEvent) {
|
||||
// disable numlock if press home etc when numlock is on,
|
||||
// because we will get numpad value (7,8,9 etc) if not
|
||||
#[cfg(windows)]
|
||||
let mut disable_numlock = false;
|
||||
let mut _disable_numlock = false;
|
||||
#[cfg(target_os = "macos")]
|
||||
en.reset_flag();
|
||||
// When long-pressed the command key, then press and release
|
||||
@@ -775,8 +775,8 @@ fn legacy_keyboard_mode(evt: &KeyEvent) {
|
||||
if let Some(key) = KEY_MAP.get(&ck.value()) {
|
||||
#[cfg(windows)]
|
||||
if let Some(_) = NUMPAD_KEY_MAP.get(&ck.value()) {
|
||||
disable_numlock = en.get_key_state(Key::NumLock);
|
||||
if disable_numlock {
|
||||
_disable_numlock = en.get_key_state(Key::NumLock);
|
||||
if _disable_numlock {
|
||||
en.key_down(Key::NumLock).ok();
|
||||
en.key_up(Key::NumLock);
|
||||
}
|
||||
|
||||
@@ -468,6 +468,7 @@ fn run(sp: GenericService) -> ResultType<()> {
|
||||
#[cfg(windows)]
|
||||
start_uac_elevation_check();
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
let mut would_block_count = 0u32;
|
||||
|
||||
while sp.ok() {
|
||||
@@ -570,9 +571,9 @@ fn run(sp: GenericService) -> ResultType<()> {
|
||||
try_gdi += 1;
|
||||
}
|
||||
|
||||
would_block_count += 1;
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
would_block_count += 1;
|
||||
if !scrap::is_x11() {
|
||||
if would_block_count >= 100 {
|
||||
// For now, the user should choose and agree screen sharing agiain.
|
||||
@@ -600,7 +601,10 @@ fn run(sp: GenericService) -> ResultType<()> {
|
||||
return Err(err.into());
|
||||
}
|
||||
_ => {
|
||||
would_block_count = 0;
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
would_block_count = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,18 +17,18 @@ pub fn set_wayland_scrap_map_err() {
|
||||
}
|
||||
|
||||
fn map_err_scrap(err: String) -> io::Error {
|
||||
// REMOVE ME ===================================== uncomment to handle error
|
||||
// // to-do: Handle error better, do not restart server
|
||||
// if err.starts_with("Did not receive a reply") {
|
||||
// log::error!("Fatal pipewire error, {}", &err);
|
||||
// std::process::exit(-1);
|
||||
// }
|
||||
|
||||
// to-do: Remove this the following log
|
||||
log::error!(
|
||||
"REMOVE ME ===================================== wayland scrap error {}",
|
||||
&err
|
||||
);
|
||||
|
||||
// to-do: Handle error better, do not restart server
|
||||
if err.starts_with("Did not receive a reply") {
|
||||
log::error!("Fatal pipewire error, {}", &err);
|
||||
std::process::exit(-1);
|
||||
}
|
||||
|
||||
if DISTRO.name.to_uppercase() == "Ubuntu".to_uppercase() {
|
||||
if DISTRO.version_id < "21".to_owned() {
|
||||
io::Error::new(io::ErrorKind::Other, SCRAP_UBUNTU_HIGHER_REQUIRED)
|
||||
|
||||
@@ -15,7 +15,7 @@ use hbb_common::{
|
||||
protobuf::Message as _,
|
||||
rendezvous_proto::*,
|
||||
tcp::FramedStream,
|
||||
tokio::{self, sync::mpsc, time},
|
||||
tokio::{self, sync::mpsc},
|
||||
};
|
||||
|
||||
use crate::common::get_app_name;
|
||||
|
||||
@@ -1242,9 +1242,3 @@ function refreshCurrentUser() {
|
||||
function getHttpHeaders() {
|
||||
return "Authorization: Bearer " + handler.get_local_option("access_token");
|
||||
}
|
||||
|
||||
$(body).timer(1000, function check_elevation(){
|
||||
if (is_win && handler.is_release() && !handler.is_installed() && !handler.is_root()) {
|
||||
msgbox("custom-elevation-nocancel", "Prompt", "elevation_prompt");
|
||||
}
|
||||
});
|
||||
@@ -18,8 +18,6 @@ use hbb_common::{
|
||||
allow_err, fs::TransferJobMeta, log, message_proto::*, rendezvous_proto::ConnType,
|
||||
};
|
||||
|
||||
#[cfg(windows)]
|
||||
use crate::clipboard_file::*;
|
||||
use crate::{
|
||||
client::*,
|
||||
ui_interface::has_hwcodec,
|
||||
|
||||
@@ -11,7 +11,7 @@ use std::{
|
||||
};
|
||||
|
||||
#[cfg(windows)]
|
||||
use clipboard::{cliprdr::CliprdrClientContext, empty_clipboard, ContextSend};
|
||||
use clipboard::{cliprdr::CliprdrClientContext, empty_clipboard, set_conn_enabled, ContextSend};
|
||||
use serde_derive::Serialize;
|
||||
|
||||
use crate::ipc::{self, new_listener, Connection, Data};
|
||||
@@ -247,10 +247,10 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> {
|
||||
.await
|
||||
);
|
||||
}
|
||||
clipboard::set_conn_enabled(conn_id, enabled);
|
||||
set_conn_enabled(conn_id, enabled);
|
||||
if !enabled {
|
||||
ContextSend::proc(|context: &mut Box<CliprdrClientContext>| -> u32 {
|
||||
clipboard::empty_clipboard(context, conn_id);
|
||||
empty_clipboard(context, conn_id);
|
||||
0
|
||||
});
|
||||
}
|
||||
|
||||
@@ -141,6 +141,11 @@ pub fn has_rendezvous_service() -> bool {
|
||||
pub fn get_license() -> String {
|
||||
#[cfg(windows)]
|
||||
if let Some(lic) = crate::platform::windows::get_license() {
|
||||
#[cfg(feature = "flutter")]
|
||||
{
|
||||
return format!("Key: {}\nHost: {}\nApi: {}", lic.key, lic.host, lic.api);
|
||||
}
|
||||
// default license format is html formed (sciter)
|
||||
return format!(
|
||||
"<br /> Key: {} <br /> Host: {} Api: {}",
|
||||
lic.key, lic.host, lic.api
|
||||
|
||||
Reference in New Issue
Block a user