2022-08-11 18:59:26 +08:00
|
|
|
use hbb_common::log;
|
|
|
|
|
2022-09-13 21:19:08 +08:00
|
|
|
use crate::{flutter::connection_manager, start_os_service, start_server};
|
2022-08-11 18:59:26 +08:00
|
|
|
|
2022-05-30 16:16:20 +08:00
|
|
|
/// Main entry of the RustDesk Core.
|
|
|
|
/// Return true if the app should continue running with UI(possibly Flutter), false if the app should exit.
|
|
|
|
pub fn core_main() -> bool {
|
|
|
|
let args = std::env::args().collect::<Vec<_>>();
|
|
|
|
// TODO: implement core_main()
|
|
|
|
if args.len() > 1 {
|
|
|
|
if args[1] == "--cm" {
|
2022-08-11 18:59:26 +08:00
|
|
|
// call connection manager to establish connections
|
|
|
|
// meanwhile, return true to call flutter window to show control panel
|
2022-08-17 17:23:55 +08:00
|
|
|
connection_manager::start_listen_ipc_thread();
|
2022-08-11 18:59:26 +08:00
|
|
|
return true;
|
|
|
|
}
|
2022-09-13 21:19:08 +08:00
|
|
|
|
|
|
|
use hbb_common::env_logger::*;
|
|
|
|
init_from_env(Env::default().filter_or(DEFAULT_FILTER_ENV, "info"));
|
2022-08-11 18:59:26 +08:00
|
|
|
if args[1] == "--service" {
|
|
|
|
log::info!("start --service");
|
|
|
|
start_os_service();
|
2022-05-30 16:16:20 +08:00
|
|
|
return false;
|
|
|
|
}
|
2022-08-25 17:35:45 +08:00
|
|
|
if args[1] == "--server" {
|
2022-09-07 20:08:12 +08:00
|
|
|
log::info!("start --server");
|
|
|
|
#[cfg(not(target_os = "macos"))]
|
|
|
|
{
|
|
|
|
start_server(true);
|
|
|
|
}
|
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
{
|
|
|
|
std::thread::spawn(move || start_server(true));
|
|
|
|
}
|
2022-08-25 17:35:45 +08:00
|
|
|
return false;
|
|
|
|
}
|
2022-05-30 16:16:20 +08:00
|
|
|
}
|
|
|
|
true
|
|
|
|
}
|