Fixed popup window
This commit is contained in:
@@ -15,18 +15,30 @@ pub async fn run_traceroute(app: AppHandle, ip: String) -> Result<(), String> {
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
.spawn()
|
||||
.map_err(|e| format!("Failed to start tracepath: {}. Is iputils-tracepath installed?", e))?;
|
||||
.map_err(|e| {
|
||||
format!(
|
||||
"Failed to start tracepath: {}. Is iputils-tracepath installed?",
|
||||
e
|
||||
)
|
||||
})?;
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
let mut child = Command::new("tracert")
|
||||
.arg("-d")
|
||||
.arg(&ip)
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
.spawn()
|
||||
.map_err(|e| format!("Failed to start tracert: {}", e))?;
|
||||
let mut child = {
|
||||
use std::os::windows::process::CommandExt;
|
||||
const CREATE_NO_WINDOW: u32 = 0x08000000;
|
||||
Command::new("tracert")
|
||||
.arg("-d")
|
||||
.arg(&ip)
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
.creation_flags(CREATE_NO_WINDOW)
|
||||
.spawn()
|
||||
.map_err(|e| format!("Failed to start tracert: {}", e))?
|
||||
};
|
||||
|
||||
let stdout = child.stdout.take()
|
||||
let stdout = child
|
||||
.stdout
|
||||
.take()
|
||||
.ok_or_else(|| "Failed to capture stdout".to_string())?;
|
||||
|
||||
let mut reader = BufReader::new(stdout).lines();
|
||||
@@ -35,7 +47,9 @@ pub async fn run_traceroute(app: AppHandle, ip: String) -> Result<(), String> {
|
||||
let _ = app.emit("traceroute:hop", &line);
|
||||
}
|
||||
|
||||
let status = child.wait().await
|
||||
let status = child
|
||||
.wait()
|
||||
.await
|
||||
.map_err(|e| format!("tracepath failed: {}", e))?;
|
||||
|
||||
if status.success() {
|
||||
@@ -45,4 +59,4 @@ pub async fn run_traceroute(app: AppHandle, ip: String) -> Result<(), String> {
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user