mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
portable-service: add quick_start feature and ci
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
@@ -81,6 +81,13 @@ pub fn core_main() -> Option<Vec<String>> {
|
||||
}
|
||||
}
|
||||
#[cfg(windows)]
|
||||
#[cfg(feature = "quick_start")]
|
||||
if !crate::platform::is_installed() && args.is_empty() && !_is_elevate && !_is_run_as_system {
|
||||
if let Err(e) = crate::portable_service::client::start_portable_service() {
|
||||
log::error!("Failed to start portable service:{:?}", e);
|
||||
}
|
||||
}
|
||||
#[cfg(windows)]
|
||||
if !crate::platform::is_installed() && (_is_elevate || _is_run_as_system) {
|
||||
crate::platform::elevate_or_run_as_system(click_setup, _is_elevate, _is_run_as_system);
|
||||
return None;
|
||||
@@ -276,7 +283,7 @@ fn core_main_invoke_new_connection(mut args: std::env::Args) -> Option<Vec<Strin
|
||||
"RustDesk",
|
||||
(WM_USER + 2) as _, // refered from unilinks desktop pub
|
||||
uni_links.as_str(),
|
||||
true
|
||||
true,
|
||||
);
|
||||
return if res { None } else { Some(Vec::new()) };
|
||||
}
|
||||
|
||||
@@ -1553,6 +1553,13 @@ pub fn run_as_system(arg: &str) -> ResultType<()> {
|
||||
|
||||
pub fn elevate_or_run_as_system(is_setup: bool, is_elevate: bool, is_run_as_system: bool) {
|
||||
// avoid possible run recursively due to failed run.
|
||||
log::info!(
|
||||
"elevate:{}->{:?}, run_as_system:{}->{}",
|
||||
is_elevate,
|
||||
is_elevated(None),
|
||||
is_run_as_system,
|
||||
crate::username(),
|
||||
);
|
||||
let arg_elevate = if is_setup {
|
||||
"--noinstall --elevate"
|
||||
} else {
|
||||
|
||||
@@ -406,8 +406,9 @@ pub mod server {
|
||||
Pong => {
|
||||
nack = 0;
|
||||
}
|
||||
ConnCount(Some(n)) => {
|
||||
if n == 0 {
|
||||
ConnCount(Some(_n)) => {
|
||||
#[cfg(not(feature = "quick_start"))]
|
||||
if _n == 0 {
|
||||
log::info!("Connnection count equals 0, exit");
|
||||
stream.send(&Data::DataPortableService(WillClose)).await.ok();
|
||||
break;
|
||||
@@ -435,6 +436,7 @@ pub mod server {
|
||||
break;
|
||||
}
|
||||
stream.send(&Data::DataPortableService(Ping)).await.ok();
|
||||
#[cfg(not(feature = "quick_start"))]
|
||||
stream.send(&Data::DataPortableService(ConnCount(None))).await.ok();
|
||||
}
|
||||
}
|
||||
@@ -462,6 +464,7 @@ pub mod client {
|
||||
}
|
||||
|
||||
pub(crate) fn start_portable_service() -> ResultType<()> {
|
||||
log::info!("start portable service");
|
||||
if PORTABLE_SERVICE_RUNNING.lock().unwrap().clone() {
|
||||
bail!("already running");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user