Skip to content

Commit

Permalink
Return error from get_tunnel_interface to ease error propagation
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusPettersson98 committed Nov 15, 2024
1 parent 8e9b2ff commit ba7cedf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion test/test-manager/src/tests/audits/mllvd_cr_24_03.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub async fn test_mllvd_cr_24_03(
connect_and_wait(&mut mullvad_client).await?;
// Get the private ip address
let in_tunnel_ip = {
let vpn_interface = get_tunnel_interface(&mut mullvad_client).await.unwrap(); // :cat-scream:
let vpn_interface = get_tunnel_interface(&mut mullvad_client).await?;
rpc.get_interface_ip(vpn_interface).await?
};
// Invoke arping
Expand Down
11 changes: 7 additions & 4 deletions test/test-manager/src/tests/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,15 @@ pub async fn using_mullvad_exit(rpc: &ServiceClient) -> bool {
}

/// Get VPN tunnel interface name
pub async fn get_tunnel_interface(client: &mut MullvadProxyClient) -> Option<String> {
match client.get_tunnel_state().await.ok()? {
pub async fn get_tunnel_interface(client: &mut MullvadProxyClient) -> anyhow::Result<String> {
match client.get_tunnel_state().await? {
TunnelState::Connecting { endpoint, .. } | TunnelState::Connected { endpoint, .. } => {
endpoint.tunnel_interface
let Some(tunnel_interface) = endpoint.tunnel_interface else {
bail!("Unknown tunnel interface");
};
Ok(tunnel_interface)
}
_ => None,
_ => bail!("Tunnel is not up"),
}
}

Expand Down

0 comments on commit ba7cedf

Please sign in to comment.