feat: suppress console window for tunnel helper commands on Windows
Add CREATE_NO_WINDOW flag to all tunnel helper Command invocations on Windows to prevent console window flashing during connect, disconnect, and metrics operations. Import CommandExt trait and define CREATE_NO_WINDOW constant for Windows builds.
This commit is contained in:
@@ -6,6 +6,12 @@ use std::{
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tauri::{AppHandle, Manager};
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
use std::os::windows::process::CommandExt;
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
const CREATE_NO_WINDOW: u32 = 0x08000000;
|
||||
|
||||
pub fn current_tunnel_strategy() -> &'static str {
|
||||
if cfg!(target_os = "windows") {
|
||||
"embedded-wireguard-windows-x64"
|
||||
@@ -18,10 +24,11 @@ pub fn current_tunnel_strategy() -> &'static str {
|
||||
|
||||
pub fn connect(app: &AppHandle, profile_path: &Path) -> Result<(), String> {
|
||||
let backend = bundled_backend(app)?;
|
||||
let output = Command::new(backend)
|
||||
.arg("connect")
|
||||
.arg("--profile")
|
||||
.arg(profile_path)
|
||||
let mut command = Command::new(backend);
|
||||
command.arg("connect").arg("--profile").arg(profile_path);
|
||||
#[cfg(target_os = "windows")]
|
||||
command.creation_flags(CREATE_NO_WINDOW);
|
||||
let output = command
|
||||
.output()
|
||||
.map_err(|err| format!("Unable to start embedded tunnel backend: {}", err))?;
|
||||
|
||||
@@ -34,10 +41,11 @@ pub fn connect(app: &AppHandle, profile_path: &Path) -> Result<(), String> {
|
||||
|
||||
pub fn disconnect(app: &AppHandle, profile_path: &Path) -> Result<(), String> {
|
||||
let backend = bundled_backend(app)?;
|
||||
let output = Command::new(backend)
|
||||
.arg("disconnect")
|
||||
.arg("--profile")
|
||||
.arg(profile_path)
|
||||
let mut command = Command::new(backend);
|
||||
command.arg("disconnect").arg("--profile").arg(profile_path);
|
||||
#[cfg(target_os = "windows")]
|
||||
command.creation_flags(CREATE_NO_WINDOW);
|
||||
let output = command
|
||||
.output()
|
||||
.map_err(|err| format!("Unable to stop embedded tunnel backend: {}", err))?;
|
||||
|
||||
@@ -54,10 +62,11 @@ pub fn is_active(app: &AppHandle, profile_path: &Path) -> Result<bool, String> {
|
||||
|
||||
pub fn metrics(app: &AppHandle, profile_path: &Path) -> Result<TunnelMetrics, String> {
|
||||
let backend = bundled_backend(app)?;
|
||||
let output = Command::new(backend)
|
||||
.arg("metrics")
|
||||
.arg("--profile")
|
||||
.arg(profile_path)
|
||||
let mut command = Command::new(backend);
|
||||
command.arg("metrics").arg("--profile").arg(profile_path);
|
||||
#[cfg(target_os = "windows")]
|
||||
command.creation_flags(CREATE_NO_WINDOW);
|
||||
let output = command
|
||||
.output()
|
||||
.map_err(|err| format!("Unable to query embedded tunnel backend: {}", err))?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user