mirror of https://github.com/ospab/ostp.git
fix(gui): resolve ERR_CONNECTION_REFUSED by disabling automatic relaunch in Tauri context and surfacing Admin requirement as UI alert
This commit is contained in:
parent
e21e612e5c
commit
57596143fa
|
|
@ -32,7 +32,7 @@ fn hide_console() {
|
|||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
fn is_admin() -> bool {
|
||||
pub fn is_admin() -> bool {
|
||||
std::process::Command::new("net")
|
||||
.arg("session")
|
||||
.stdout(std::process::Stdio::null())
|
||||
|
|
@ -100,6 +100,12 @@ fn relaunch_as_admin() -> Result<()> {
|
|||
}
|
||||
|
||||
pub async fn run_client(config: crate::config::ClientConfig) -> Result<()> {
|
||||
#[cfg(target_os = "windows")]
|
||||
if config.mode == "tun" && !is_admin() {
|
||||
println!("[ostp-client] TUN mode requires Administrator privileges. Relaunching executable as Admin...");
|
||||
relaunch_as_admin()?;
|
||||
}
|
||||
|
||||
let bg = std::env::args().any(|a| a == "--bg");
|
||||
|
||||
if bg {
|
||||
|
|
@ -130,8 +136,7 @@ pub async fn run_client_core(
|
|||
) -> Result<()> {
|
||||
#[cfg(target_os = "windows")]
|
||||
if config.mode == "tun" && !is_admin() {
|
||||
println!("[ostp-client] TUN mode requires Administrator privileges. Relaunching executable as Admin...");
|
||||
relaunch_as_admin()?;
|
||||
return Err(anyhow::anyhow!("Administrator privileges are required to initialize TUN mode. Please run the application as Administrator."));
|
||||
}
|
||||
|
||||
if config.mode == "tun" && !config.exclusions.processes.is_empty() {
|
||||
|
|
|
|||
|
|
@ -234,6 +234,11 @@ async fn start_tunnel(state: tauri::State<'_, AppState>) -> Result<bool, String>
|
|||
dns_server: client_cfg.tun.as_ref().and_then(|t| t.dns.clone()),
|
||||
};
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
if mapped_config.mode == "tun" && !ostp_client::runner::is_admin() {
|
||||
return Err("Administrator privileges are required to initialize TUN mode. Please run the application as Administrator.".to_string());
|
||||
}
|
||||
|
||||
let metrics = Arc::new(BridgeMetrics {
|
||||
bytes_sent: portable_atomic::AtomicU64::new(0),
|
||||
bytes_recv: portable_atomic::AtomicU64::new(0),
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ async function handleToggleConnect() {
|
|||
setUIState('disconnected');
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
alert('Error starting tunnel: ' + err);
|
||||
setUIState('disconnected');
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue