Browse Source

Update Desktop API to use returned state

pull/99/head
B. Blechschmidt 2 years ago
parent
commit
1d49ec87ad
  1. 9
      src/desktop_api.rs

9
src/desktop_api.rs

@ -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…
Cancel
Save