From de1c4a05f93c1ee2772ef248c8e8679ac242f31e Mon Sep 17 00:00:00 2001 From: John Smith Date: Thu, 4 Jan 2024 13:03:24 +0300 Subject: [PATCH] fix: enable_tun block the process (#232) --- backend/tauri/src/core/core.rs | 22 +++++++--------------- rust-toolchain.toml | 2 ++ 2 files changed, 9 insertions(+), 15 deletions(-) create mode 100644 rust-toolchain.toml diff --git a/backend/tauri/src/core/core.rs b/backend/tauri/src/core/core.rs index 5476317825..ef769fe3f4 100644 --- a/backend/tauri/src/core/core.rs +++ b/backend/tauri/src/core/core.rs @@ -112,21 +112,13 @@ impl CoreManager { if enable_tun { log::debug!(target: "app", "try to set system dns"); - match (|| async { - let tun_device_ip = Config::clash().clone().latest().get_tun_device_ip(); - // 执行 networksetup -setdnsservers Wi-Fi $tun_device_ip - Command::new("networksetup") - .args(["-setdnsservers", "Wi-Fi", tun_device_ip.as_str()]) - .output() - })() - .await - { - Ok(_) => return Ok(()), - Err(err) => { - // 修改这个值,免得stop出错 - log::error!(target: "app", "{err}"); - } - } + let tun_device_ip = Config::clash().clone().latest().get_tun_device_ip(); + // 执行 networksetup -setdnsservers Wi-Fi $tun_device_ip + let (mut rx, _) = Command::new("networksetup") + .args(["-setdnsservers", "Wi-Fi", tun_device_ip.as_str()]) + .spawn()?; + let event = rx.recv().await; + log::debug!(target: "app", "{event:?}"); } } #[cfg(target_os = "windows")] diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000000..27ae62c5bc --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "1.74.1"