Skip to content

Commit

Permalink
fix: enable_tun block the process (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
dyxushuai authored and greenhat616 committed Jan 4, 2024
1 parent eacfcf3 commit de1c4a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
22 changes: 7 additions & 15 deletions backend/tauri/src/core/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
2 changes: 2 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "1.74.1"

0 comments on commit de1c4a0

Please sign in to comment.