mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
remove more "rustdesk" built-in
This commit is contained in:
@@ -1527,14 +1527,11 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
},
|
||||
Some(message::Union::MessageBox(msgbox)) => {
|
||||
let mut link = msgbox.link;
|
||||
// Links from the remote side must be verified.
|
||||
if !link.starts_with("rustdesk://") {
|
||||
if let Some(v) = hbb_common::config::HELPER_URL.get(&link as &str) {
|
||||
link = v.to_string();
|
||||
} else {
|
||||
log::warn!("Message box ignore link {} for security", &link);
|
||||
link = "".to_string();
|
||||
}
|
||||
if let Some(v) = hbb_common::config::HELPER_URL.get(&link as &str) {
|
||||
link = v.to_string();
|
||||
} else {
|
||||
log::warn!("Message box ignore link {} for security", &link);
|
||||
link = "".to_string();
|
||||
}
|
||||
self.handler
|
||||
.msgbox(&msgbox.msgtype, &msgbox.title, &msgbox.text, &link);
|
||||
|
||||
@@ -979,10 +979,16 @@ async fn check_software_update_() -> hbb_common::ResultType<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_app_name() -> String {
|
||||
hbb_common::config::APP_NAME.read().unwrap().clone()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_uri_prefix() -> String {
|
||||
format!("{}://", get_app_name().to_lowercase())
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
pub fn get_full_name() -> String {
|
||||
format!(
|
||||
@@ -1512,7 +1518,7 @@ mod tests {
|
||||
assert_eq!(times, tokio_times);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_tokio_time_interval_sleep() {
|
||||
let mut timer = interval_maker();
|
||||
|
||||
@@ -24,10 +24,11 @@ macro_rules! my_println{
|
||||
|
||||
#[inline]
|
||||
fn is_empty_uni_link(arg: &str) -> bool {
|
||||
if !arg.starts_with("rustdesk://") {
|
||||
let prefix = crate::get_uri_prefix();
|
||||
if !arg.starts_with(&prefix) {
|
||||
return false;
|
||||
}
|
||||
arg["rustdesk://".len()..].chars().all(|c| c == '/')
|
||||
arg[prefix.len()..].chars().all(|c| c == '/')
|
||||
}
|
||||
|
||||
/// shared by flutter and sciter main function
|
||||
@@ -135,7 +136,7 @@ pub fn core_main() -> Option<Vec<String>> {
|
||||
|
||||
// linux uni (url) go here.
|
||||
#[cfg(all(target_os = "linux", feature = "flutter"))]
|
||||
if args.len() > 0 && args[0].starts_with("rustdesk:") {
|
||||
if args.len() > 0 && args[0].starts_with(&crate::get_uri_prefix()) {
|
||||
return try_send_by_dbus(args[0].clone());
|
||||
}
|
||||
|
||||
@@ -551,7 +552,14 @@ fn core_main_invoke_new_connection(mut args: std::env::Args) -> Option<Vec<Strin
|
||||
}
|
||||
let params = param_array.join("&");
|
||||
let params_flag = if params.is_empty() { "" } else { "?" };
|
||||
uni_links = format!("rustdesk://{}/{}{}{}", authority, id, params_flag, params);
|
||||
uni_links = format!(
|
||||
"{}{}/{}{}{}",
|
||||
crate::get_uri_prefix(),
|
||||
authority,
|
||||
id,
|
||||
params_flag,
|
||||
params
|
||||
);
|
||||
}
|
||||
}
|
||||
if uni_links.is_empty() {
|
||||
@@ -566,7 +574,7 @@ fn core_main_invoke_new_connection(mut args: std::env::Args) -> Option<Vec<Strin
|
||||
use winapi::um::winuser::WM_USER;
|
||||
let res = crate::platform::send_message_to_hnwd(
|
||||
"FLUTTER_RUNNER_WIN32_WINDOW",
|
||||
"RustDesk",
|
||||
&crate::get_app_name(),
|
||||
(WM_USER + 2) as _, // referred from unilinks desktop pub
|
||||
uni_links.as_str(),
|
||||
false,
|
||||
|
||||
@@ -804,6 +804,10 @@ pub fn main_get_app_name_sync() -> SyncReturn<String> {
|
||||
SyncReturn(get_app_name())
|
||||
}
|
||||
|
||||
pub fn main_uri_prefix_sync() -> SyncReturn<String> {
|
||||
SyncReturn(crate::get_uri_prefix())
|
||||
}
|
||||
|
||||
pub fn main_get_license() -> String {
|
||||
get_license()
|
||||
}
|
||||
|
||||
@@ -158,21 +158,21 @@ pub fn is_installed_daemon(prompt: bool) -> bool {
|
||||
let Some(install_script) = PRIVILEGES_SCRIPTS_DIR.get_file("install.scpt") else {
|
||||
return false;
|
||||
};
|
||||
let Some(install_script_body) = install_script.contents_utf8() else {
|
||||
let Some(install_script_body) = install_script.contents_utf8().map(correct_app_name) else {
|
||||
return false;
|
||||
};
|
||||
|
||||
let Some(daemon_plist) = PRIVILEGES_SCRIPTS_DIR.get_file(&daemon) else {
|
||||
let Some(daemon_plist) = PRIVILEGES_SCRIPTS_DIR.get_file("daemon.plist") else {
|
||||
return false;
|
||||
};
|
||||
let Some(daemon_plist_body) = daemon_plist.contents_utf8() else {
|
||||
let Some(daemon_plist_body) = daemon_plist.contents_utf8().map(correct_app_name) else {
|
||||
return false;
|
||||
};
|
||||
|
||||
let Some(agent_plist) = PRIVILEGES_SCRIPTS_DIR.get_file(&agent) else {
|
||||
let Some(agent_plist) = PRIVILEGES_SCRIPTS_DIR.get_file("agent.plist") else {
|
||||
return false;
|
||||
};
|
||||
let Some(agent_plist_body) = agent_plist.contents_utf8() else {
|
||||
let Some(agent_plist_body) = agent_plist.contents_utf8().map(correct_app_name) else {
|
||||
return false;
|
||||
};
|
||||
|
||||
@@ -213,6 +213,12 @@ pub fn is_installed_daemon(prompt: bool) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn correct_app_name(s: &str) -> String {
|
||||
let s = s.replace("rustdesk", &crate::get_app_name().to_lowercase());
|
||||
let s = s.replace("RustDesk", &crate::get_app_name());
|
||||
s
|
||||
}
|
||||
|
||||
pub fn uninstall_service(show_new_window: bool) -> bool {
|
||||
// to-do: do together with win/linux about refactory start/stop service
|
||||
if !is_installed_daemon(false) {
|
||||
@@ -222,7 +228,7 @@ pub fn uninstall_service(show_new_window: bool) -> bool {
|
||||
let Some(script_file) = PRIVILEGES_SCRIPTS_DIR.get_file("uninstall.scpt") else {
|
||||
return false;
|
||||
};
|
||||
let Some(script_body) = script_file.contents_utf8() else {
|
||||
let Some(script_body) = script_file.contents_utf8().map(correct_app_name) else {
|
||||
return false;
|
||||
};
|
||||
|
||||
@@ -625,7 +631,7 @@ pub fn handle_application_should_open_untitled_file() {
|
||||
let x = std::env::args().nth(1).unwrap_or_default();
|
||||
if x == "--server" || x == "--cm" || x == "--tray" {
|
||||
if crate::platform::macos::check_main_window() {
|
||||
allow_err!(crate::ipc::send_url_scheme("rustdesk:".into()));
|
||||
allow_err!(crate::ipc::send_url_scheme(crate::get_uri_prefix()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2408,11 +2408,12 @@ sc start {app_name}
|
||||
|
||||
fn run_after_run_cmds(silent: bool) {
|
||||
let (_, _, _, exe) = get_install_info();
|
||||
let app = crate::get_app_name().to_lowercase();
|
||||
if !silent {
|
||||
log::debug!("Spawn new window");
|
||||
allow_err!(std::process::Command::new("cmd")
|
||||
.arg("/c")
|
||||
.arg("timeout /t 2 & start rustdesk://")
|
||||
.arg("timeout /t 2 & start {app}://")
|
||||
.creation_flags(winapi::um::winbase::CREATE_NO_WINDOW)
|
||||
.spawn());
|
||||
}
|
||||
|
||||
@@ -91,14 +91,14 @@ pub fn make_tray() -> hbb_common::ResultType<()> {
|
||||
use std::process::Command;
|
||||
Command::new("cmd")
|
||||
.arg("/c")
|
||||
.arg("start rustdesk://")
|
||||
.arg(&format!("start {}", crate::get_uri_prefix()))
|
||||
.creation_flags(winapi::um::winbase::CREATE_NO_WINDOW)
|
||||
.spawn()
|
||||
.ok();
|
||||
}
|
||||
#[cfg(target_os = "linux")]
|
||||
if !std::process::Command::new("xdg-open")
|
||||
.arg("rustdesk://")
|
||||
.arg(&crate::get_uri_prefix())
|
||||
.spawn()
|
||||
.is_ok()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user