diff options
| author | Markus Pettersson <markus.pettersson@mullvad.net> | 2023-09-20 13:41:43 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2023-10-09 14:40:06 +0200 |
| commit | 7fcaad31643ca324c5dd4a17ddf0f445ac679384 (patch) | |
| tree | 9a913059321b437857863efed43b4d47ed9c0eb4 /mullvad-daemon/src | |
| parent | fc477f4e4df6db2973ff88fc4b6819d38d64d8cc (diff) | |
| download | mullvadvpn-7fcaad31643ca324c5dd4a17ddf0f445ac679384.tar.xz mullvadvpn-7fcaad31643ca324c5dd4a17ddf0f445ac679384.zip | |
Add `mullvad proxy test`
For quickly assessing whether an api access method can reach the API or not.
Diffstat (limited to 'mullvad-daemon/src')
| -rw-r--r-- | mullvad-daemon/src/lib.rs | 10 | ||||
| -rw-r--r-- | mullvad-daemon/src/management_interface.rs | 11 |
2 files changed, 21 insertions, 0 deletions
diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs index 3c822fdf4e..ed7bafd007 100644 --- a/mullvad-daemon/src/lib.rs +++ b/mullvad-daemon/src/lib.rs @@ -275,6 +275,8 @@ pub enum DaemonCommand { ToggleApiAccessMethod(ResponseTx<(), Error>, ApiAccessMethodToggle), /// Set the API access method to use SetApiAccessMethod(ResponseTx<(), Error>, AccessMethod), + /// Get the addresses of all known API endpoints + GetApiAddresses(ResponseTx<Vec<std::net::SocketAddr>, Error>), /// Get information about the currently running and latest app versions GetVersionInfo(oneshot::Sender<Option<AppVersionInfo>>), /// Return whether the daemon is performing post-upgrade tasks @@ -1067,6 +1069,7 @@ where } ToggleApiAccessMethod(tx, method) => self.on_toggle_api_access_method(tx, method).await, SetApiAccessMethod(tx, method) => self.on_set_api_access_method(tx, method).await, + GetApiAddresses(tx) => self.on_get_api_addresses(tx).await, IsPerformingPostUpgrade(tx) => self.on_is_performing_post_upgrade(tx), GetCurrentVersion(tx) => self.on_get_current_version(tx), #[cfg(not(target_os = "android"))] @@ -2298,6 +2301,13 @@ where Self::oneshot_send(tx, result, "set_api_access_method response"); } + async fn on_get_api_addresses(&mut self, tx: ResponseTx<Vec<std::net::SocketAddr>, Error>) { + let api_proxy = mullvad_api::ApiProxy::new(self.api_handle.clone()); + let result = api_proxy.get_api_addrs().await.map_err(Error::RestError); + + Self::oneshot_send(tx, result, "on_get_api_adressess response"); + } + fn on_get_settings(&self, tx: oneshot::Sender<Settings>) { Self::oneshot_send(tx, self.settings.to_settings(), "get_settings response"); } diff --git a/mullvad-daemon/src/management_interface.rs b/mullvad-daemon/src/management_interface.rs index 2b6481207a..88ea87056c 100644 --- a/mullvad-daemon/src/management_interface.rs +++ b/mullvad-daemon/src/management_interface.rs @@ -654,6 +654,17 @@ impl ManagementService for ManagementServiceImpl { .map_err(map_daemon_error) } + async fn get_api_addressess(&self, _: Request<()>) -> ServiceResult<()> { + log::debug!("test_api"); + let (tx, rx) = oneshot::channel(); + self.send_command_to_daemon(DaemonCommand::GetApiAddresses(tx))?; + self.wait_for_result(rx) + .await? + .map(drop) + .map(Response::new) + .map_err(map_daemon_error) + } + // Split tunneling // |
