Skip to content

Commit

Permalink
Update OpenVPN monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
dlon committed Oct 12, 2023
1 parent 5f0f746 commit 7f8b7e9
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 265 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions talpid-core/src/tunnel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,18 @@ impl TunnelMonitor {
config,
log,
resource_dir,
tunnel_close_rx,
#[cfg(target_os = "linux")]
route_manager,
)
.await?;

let close_handle = monitor.close_handle();
tokio::spawn(async move {
if tunnel_close_rx.await.is_ok() {
close_handle.close();
}
});

Ok(TunnelMonitor {
monitor: InternalTunnelMonitor::OpenVpn(monitor),
})
Expand Down Expand Up @@ -298,9 +305,12 @@ enum InternalTunnelMonitor {

impl InternalTunnelMonitor {
fn wait(self) -> Result<()> {
#[cfg(not(target_os = "android"))]
let handle = tokio::runtime::Handle::current();

match self {
#[cfg(not(target_os = "android"))]
InternalTunnelMonitor::OpenVpn(tun) => tun.wait()?,
InternalTunnelMonitor::OpenVpn(tun) => handle.block_on(tun.wait())?,
InternalTunnelMonitor::Wireguard(tun) => tun.wait()?,
}

Expand Down
2 changes: 0 additions & 2 deletions talpid-openvpn/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ err-derive = { workspace = true }
futures = "0.3.15"
once_cell = { workspace = true }
log = { workspace = true }
os_pipe = "1.1.4"
parking_lot = "0.12.0"
shell-escape = "0.1"
talpid-routing = { path = "../talpid-routing" }
talpid-tunnel = { path = "../talpid-tunnel" }
Expand Down
Loading

0 comments on commit 7f8b7e9

Please sign in to comment.