mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-04-23 15:29:10 +00:00
Update Desktop API to use returned state
This commit is contained in:
parent
5c228ca07e
commit
1d49ec87ad
1 changed files with 5 additions and 4 deletions
|
@ -115,6 +115,8 @@ pub async fn desktop_run_async(args: Args, shutdown_token: tokio_util::sync::Can
|
|||
tproxy_args = tproxy_args.tun_name(&tun_name);
|
||||
}
|
||||
|
||||
let mut restore: Option<tproxy_config::TproxyRestore> = None;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
setup = args.setup;
|
||||
|
@ -122,16 +124,15 @@ pub async fn desktop_run_async(args: Args, shutdown_token: tokio_util::sync::Can
|
|||
|
||||
#[cfg(any(target_os = "linux", target_os = "windows", target_os = "macos"))]
|
||||
if setup {
|
||||
log::trace!("Entering route setup");
|
||||
tproxy_config::tproxy_setup(&tproxy_args)?;
|
||||
restore = Some(tproxy_config::tproxy_setup(&tproxy_args)?);
|
||||
}
|
||||
|
||||
let join_handle = tokio::spawn(crate::run(device, MTU, args, shutdown_token));
|
||||
join_handle.await.map_err(std::io::Error::from)??;
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "windows", target_os = "macos"))]
|
||||
if setup {
|
||||
tproxy_config::tproxy_remove(&tproxy_args)?;
|
||||
if setup && restore.is_some() {
|
||||
tproxy_config::tproxy_remove(&restore.unwrap())?;
|
||||
}
|
||||
|
||||
Ok::<(), std::io::Error>(())
|
||||
|
|
Loading…
Add table
Reference in a new issue