chore: hide rustdesk provisioning consoles

This commit is contained in:
Esdras Renan 2025-11-11 23:00:29 -03:00
parent 20f80083f2
commit 2872c6e73c

View file

@ -8,6 +8,7 @@ use reqwest::blocking::Client;
use serde::Deserialize; use serde::Deserialize;
use sha2::{Digest, Sha256}; use sha2::{Digest, Sha256};
use std::env; use std::env;
use std::ffi::OsStr;
use std::fs::{self, File, OpenOptions}; use std::fs::{self, File, OpenOptions};
use std::io::{self, Write}; use std::io::{self, Write};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
@ -15,6 +16,7 @@ use std::process::{Command, Stdio};
use std::thread; use std::thread;
use std::time::Duration; use std::time::Duration;
use thiserror::Error; use thiserror::Error;
use std::os::windows::process::CommandExt;
const RELEASES_API: &str = "https://api.github.com/repos/rustdesk/rustdesk/releases/latest"; const RELEASES_API: &str = "https://api.github.com/repos/rustdesk/rustdesk/releases/latest";
const USER_AGENT: &str = "RavenDesktop/1.0"; const USER_AGENT: &str = "RavenDesktop/1.0";
@ -24,6 +26,7 @@ const DEFAULT_PASSWORD: &str = "FMQ9MA>e73r.FI<b*34Vmx_8P";
const SERVICE_NAME: &str = "RustDesk"; const SERVICE_NAME: &str = "RustDesk";
const CACHE_DIR_NAME: &str = "Rever\\RustDeskCache"; const CACHE_DIR_NAME: &str = "Rever\\RustDeskCache";
const LOCAL_SERVICE_CONFIG: &str = r"C:\\Windows\\ServiceProfiles\\LocalService\\AppData\\Roaming\\RustDesk\\config"; const LOCAL_SERVICE_CONFIG: &str = r"C:\\Windows\\ServiceProfiles\\LocalService\\AppData\\Roaming\\RustDesk\\config";
const CREATE_NO_WINDOW: u32 = 0x08000000;
static PROVISION_MUTEX: Lazy<Mutex<()>> = Lazy::new(|| Mutex::new(())); static PROVISION_MUTEX: Lazy<Mutex<()>> = Lazy::new(|| Mutex::new(()));
@ -209,7 +212,7 @@ fn download_latest_installer(cache_root: &Path) -> Result<(PathBuf, String), Rus
} }
fn run_installer(installer_path: &Path) -> Result<(), RustdeskError> { fn run_installer(installer_path: &Path) -> Result<(), RustdeskError> {
let status = Command::new(installer_path) let status = hidden_command(installer_path)
.arg("--silent-install") .arg("--silent-install")
.stdout(Stdio::null()) .stdout(Stdio::null())
.stderr(Stdio::null()) .stderr(Stdio::null())
@ -292,7 +295,7 @@ api-server = "https://{host}"
} }
fn apply_config(exe_path: &Path, config_path: &Path) -> Result<(), RustdeskError> { fn apply_config(exe_path: &Path, config_path: &Path) -> Result<(), RustdeskError> {
let status = Command::new(exe_path) let status = hidden_command(exe_path)
.arg("--import-config") .arg("--import-config")
.arg(config_path) .arg(config_path)
.stdout(Stdio::null()) .stdout(Stdio::null())
@ -336,7 +339,7 @@ fn ensure_service_running() -> Result<(), RustdeskError> {
} }
fn run_sc(args: &[&str]) -> Result<(), RustdeskError> { fn run_sc(args: &[&str]) -> Result<(), RustdeskError> {
let status = Command::new("sc") let status = hidden_command("sc")
.args(args) .args(args)
.stdout(Stdio::null()) .stdout(Stdio::null())
.stderr(Stdio::null()) .stderr(Stdio::null())
@ -370,7 +373,7 @@ fn query_id_with_retries(exe_path: &Path, attempts: usize) -> Result<String, Rus
} }
fn query_id(exe_path: &Path) -> Result<String, RustdeskError> { fn query_id(exe_path: &Path) -> Result<String, RustdeskError> {
let output = Command::new(exe_path) let output = hidden_command(exe_path)
.arg("--get-id") .arg("--get-id")
.output()?; .output()?;
if !output.status.success() { if !output.status.success() {
@ -387,7 +390,7 @@ fn query_id(exe_path: &Path) -> Result<String, RustdeskError> {
} }
fn query_version(exe_path: &Path) -> Result<String, RustdeskError> { fn query_version(exe_path: &Path) -> Result<String, RustdeskError> {
let output = Command::new(exe_path) let output = hidden_command(exe_path)
.arg("--version") .arg("--version")
.output()?; .output()?;
if !output.status.success() { if !output.status.success() {
@ -500,7 +503,7 @@ fn parse_assignment(line: &str, key: &str) -> Option<String> {
} }
fn run_with_args(exe_path: &Path, args: &[&str]) -> Result<(), RustdeskError> { fn run_with_args(exe_path: &Path, args: &[&str]) -> Result<(), RustdeskError> {
let status = Command::new(exe_path) let status = hidden_command(exe_path)
.args(args) .args(args)
.stdout(Stdio::null()) .stdout(Stdio::null())
.stderr(Stdio::null()) .stderr(Stdio::null())
@ -514,6 +517,12 @@ fn run_with_args(exe_path: &Path, args: &[&str]) -> Result<(), RustdeskError> {
Ok(()) Ok(())
} }
fn hidden_command(program: impl AsRef<OsStr>) -> Command {
let mut cmd = Command::new(program);
cmd.creation_flags(CREATE_NO_WINDOW);
cmd
}
fn log_event(message: impl AsRef<str>) { fn log_event(message: impl AsRef<str>) {
if let Some(dir) = logs_directory() { if let Some(dir) = logs_directory() {
if let Err(error) = append_log(dir, message.as_ref()) { if let Err(error) = append_log(dir, message.as_ref()) {