diff --git a/mullvad-api/src/https_client_with_sni.rs b/mullvad-api/src/https_client_with_sni.rs index e95fbf98fcdc..cc7557a8d2ad 100644 --- a/mullvad-api/src/https_client_with_sni.rs +++ b/mullvad-api/src/https_client_with_sni.rs @@ -248,12 +248,12 @@ impl TryFrom for InnerConnectionMode { }) } ProxyConfig::Socks(config) => match config { - mullvad_types::api_access::Socks5::Local(config) => { + mullvad_types::access_method::Socks5::Local(config) => { InnerConnectionMode::Socks5(SocksConfig { peer: SocketAddr::new("127.0.0.1".parse().unwrap(), config.port), }) } - mullvad_types::api_access::Socks5::Remote(config) => { + mullvad_types::access_method::Socks5::Remote(config) => { InnerConnectionMode::Socks5(SocksConfig { peer: config.peer }) } }, diff --git a/mullvad-api/src/proxy.rs b/mullvad-api/src/proxy.rs index 7d33840d6947..44a2309587e5 100644 --- a/mullvad-api/src/proxy.rs +++ b/mullvad-api/src/proxy.rs @@ -1,6 +1,6 @@ use futures::Stream; use hyper::client::connect::Connected; -use mullvad_types::api_access; +use mullvad_types::access_method; use serde::{Deserialize, Serialize}; use std::{ fmt, io, @@ -36,8 +36,8 @@ impl fmt::Display for ApiConnectionMode { #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] pub enum ProxyConfig { - Shadowsocks(api_access::Shadowsocks), - Socks(api_access::Socks5), + Shadowsocks(access_method::Shadowsocks), + Socks(access_method::Socks5), } impl ProxyConfig { @@ -46,8 +46,8 @@ impl ProxyConfig { match self { ProxyConfig::Shadowsocks(ss) => ss.peer, ProxyConfig::Socks(socks) => match socks { - api_access::Socks5::Local(s) => s.peer, - api_access::Socks5::Remote(s) => s.peer, + access_method::Socks5::Local(s) => s.peer, + access_method::Socks5::Remote(s) => s.peer, }, } } @@ -59,10 +59,10 @@ impl fmt::Display for ProxyConfig { // TODO: Do not hardcode TCP ProxyConfig::Shadowsocks(ss) => write!(f, "Shadowsocks {}/TCP", ss.peer), ProxyConfig::Socks(socks) => match socks { - api_access::Socks5::Local(s) => { + access_method::Socks5::Local(s) => { write!(f, "Socks5 {}/TCP via localhost:{}", s.peer, s.port) } - api_access::Socks5::Remote(s) => write!(f, "Socks5 {}/TCP", s.peer), + access_method::Socks5::Remote(s) => write!(f, "Socks5 {}/TCP", s.peer), }, } } diff --git a/mullvad-cli/src/cmds/api_access.rs b/mullvad-cli/src/cmds/api_access.rs index 996e72bb2332..d502c0071eef 100644 --- a/mullvad-cli/src/cmds/api_access.rs +++ b/mullvad-cli/src/cmds/api_access.rs @@ -1,6 +1,6 @@ use anyhow::{anyhow, Result}; use mullvad_management_interface::MullvadProxyClient; -use mullvad_types::api_access::{AccessMethod, AccessMethodSetting, CustomAccessMethod}; +use mullvad_types::access_method::{AccessMethod, AccessMethodSetting, CustomAccessMethod}; use std::net::IpAddr; use clap::{Args, Subcommand}; @@ -102,21 +102,21 @@ impl ApiAccess { let port = cmd.params.port.unwrap_or(shadowsocks.peer.port()); let password = cmd.params.password.unwrap_or(shadowsocks.password); let cipher = cmd.params.cipher.unwrap_or(shadowsocks.cipher); - mullvad_types::api_access::Shadowsocks::from_args(ip, port, cipher, password) + mullvad_types::access_method::Shadowsocks::from_args(ip, port, cipher, password) .map(AccessMethod::from) } CustomAccessMethod::Socks5(socks) => match socks { - mullvad_types::api_access::Socks5::Local(local) => { + mullvad_types::access_method::Socks5::Local(local) => { let ip = cmd.params.ip.unwrap_or(local.peer.ip()).to_string(); let port = cmd.params.port.unwrap_or(local.peer.port()); let local_port = cmd.params.local_port.unwrap_or(local.port); - mullvad_types::api_access::Socks5Local::from_args(ip, port, local_port) + mullvad_types::access_method::Socks5Local::from_args(ip, port, local_port) .map(AccessMethod::from) } - mullvad_types::api_access::Socks5::Remote(remote) => { + mullvad_types::access_method::Socks5::Remote(remote) => { let ip = cmd.params.ip.unwrap_or(remote.peer.ip()).to_string(); let port = cmd.params.port.unwrap_or(remote.peer.port()); - mullvad_types::api_access::Socks5Remote::from_args(ip, port) + mullvad_types::access_method::Socks5Remote::from_args(ip, port) .map(AccessMethod::from) } }, @@ -315,7 +315,7 @@ pub struct EditParams { /// we define them in a hidden-away module. mod conversions { use anyhow::{anyhow, Error}; - use mullvad_types::api_access as daemon_types; + use mullvad_types::access_method as daemon_types; use super::{AddCustomCommands, AddSocks5Commands}; @@ -384,7 +384,7 @@ mod conversions { /// Pretty printing of [`ApiAccessMethod`]s mod pp { - use mullvad_types::api_access::{ + use mullvad_types::access_method::{ AccessMethod, AccessMethodSetting, CustomAccessMethod, Socks5, }; diff --git a/mullvad-daemon/src/access_method.rs b/mullvad-daemon/src/access_method.rs index fb249f9bd55b..02ec3a6c934d 100644 --- a/mullvad-daemon/src/access_method.rs +++ b/mullvad-daemon/src/access_method.rs @@ -2,7 +2,7 @@ use crate::{ settings::{self, MadeChanges}, Daemon, EventListener, }; -use mullvad_types::api_access::{AccessMethod, AccessMethodSetting, ApiAccessMethodId}; +use mullvad_types::access_method::{AccessMethod, AccessMethodSetting, ApiAccessMethodId}; #[derive(err_derive::Error, Debug)] pub enum Error { diff --git a/mullvad-daemon/src/api.rs b/mullvad-daemon/src/api.rs index c5a5bda73e2b..07329130809b 100644 --- a/mullvad-daemon/src/api.rs +++ b/mullvad-daemon/src/api.rs @@ -10,7 +10,7 @@ use mullvad_api::{ ApiEndpointUpdateCallback, }; use mullvad_relay_selector::RelaySelector; -use mullvad_types::api_access::{self, AccessMethod, BuiltInAccessMethod}; +use mullvad_types::access_method::{self, AccessMethod, BuiltInAccessMethod}; use std::{ net::SocketAddr, path::PathBuf, @@ -131,11 +131,12 @@ impl ApiConnectionModeProvider { .get_bridge_forced() .and_then(|settings| match settings { ProxySettings::Shadowsocks(ss_settings) => { - let ss_settings: api_access::Shadowsocks = api_access::Shadowsocks::new( - ss_settings.peer, - ss_settings.cipher, - ss_settings.password, - ); + let ss_settings: access_method::Shadowsocks = + access_method::Shadowsocks::new( + ss_settings.peer, + ss_settings.cipher, + ss_settings.password, + ); Some(ApiConnectionMode::Proxied(ProxyConfig::Shadowsocks( ss_settings, ))) @@ -148,10 +149,10 @@ impl ApiConnectionModeProvider { .unwrap_or(ApiConnectionMode::Direct), }, AccessMethod::Custom(access_method) => match &access_method { - api_access::CustomAccessMethod::Shadowsocks(shadowsocks_config) => { + access_method::CustomAccessMethod::Shadowsocks(shadowsocks_config) => { ApiConnectionMode::Proxied(ProxyConfig::Shadowsocks(shadowsocks_config.clone())) } - api_access::CustomAccessMethod::Socks5(socks_config) => { + access_method::CustomAccessMethod::Socks5(socks_config) => { ApiConnectionMode::Proxied(ProxyConfig::Socks(socks_config.clone())) } }, diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs index 406e07bf222e..f00b0578b535 100644 --- a/mullvad-daemon/src/lib.rs +++ b/mullvad-daemon/src/lib.rs @@ -39,8 +39,8 @@ use mullvad_relay_selector::{ RelaySelector, SelectorConfig, }; use mullvad_types::{ + access_method::{AccessMethod, AccessMethodSetting, ApiAccessMethodId}, account::{AccountData, AccountToken, VoucherSubmission}, - api_access::{AccessMethod, AccessMethodSetting, ApiAccessMethodId}, auth_failed::AuthFailed, custom_list::{CustomList, CustomListLocationUpdate}, device::{Device, DeviceEvent, DeviceEventCause, DeviceId, DeviceState, RemoveDeviceEvent}, diff --git a/mullvad-daemon/src/management_interface.rs b/mullvad-daemon/src/management_interface.rs index 99e2790cd82b..510f42a9a114 100644 --- a/mullvad-daemon/src/management_interface.rs +++ b/mullvad-daemon/src/management_interface.rs @@ -634,7 +634,7 @@ impl ManagementService for ManagementServiceImpl { request .access_method .ok_or(Status::invalid_argument("Could not find access method")) - .map(mullvad_types::api_access::AccessMethod::try_from)??, + .map(mullvad_types::access_method::AccessMethod::try_from)??, ))?; self.wait_for_result(rx) .await? @@ -646,7 +646,7 @@ impl ManagementService for ManagementServiceImpl { async fn remove_api_access_method(&self, request: Request) -> ServiceResult<()> { log::debug!("remove_api_access_method"); let api_access_method = - mullvad_types::api_access::ApiAccessMethodId::try_from(request.into_inner())?; + mullvad_types::access_method::ApiAccessMethodId::try_from(request.into_inner())?; let (tx, rx) = oneshot::channel(); self.send_command_to_daemon(DaemonCommand::RemoveApiAccessMethod(tx, api_access_method))?; self.wait_for_result(rx) @@ -661,7 +661,7 @@ impl ManagementService for ManagementServiceImpl { ) -> ServiceResult<()> { log::debug!("update_api_access_method"); let access_method_update = - mullvad_types::api_access::AccessMethodSetting::try_from(request.into_inner())?; + mullvad_types::access_method::AccessMethodSetting::try_from(request.into_inner())?; let (tx, rx) = oneshot::channel(); self.send_command_to_daemon(DaemonCommand::UpdateApiAccessMethod( tx, @@ -676,7 +676,7 @@ impl ManagementService for ManagementServiceImpl { async fn set_api_access_method(&self, request: Request) -> ServiceResult<()> { log::debug!("set_api_access_method"); let api_access_method = - mullvad_types::api_access::ApiAccessMethodId::try_from(request.into_inner())?; + mullvad_types::access_method::ApiAccessMethodId::try_from(request.into_inner())?; let (tx, rx) = oneshot::channel(); self.send_command_to_daemon(DaemonCommand::SetApiAccessMethod(tx, api_access_method))?; self.wait_for_result(rx) diff --git a/mullvad-management-interface/src/client.rs b/mullvad-management-interface/src/client.rs index 5770c275aca5..d5bd333eaa76 100644 --- a/mullvad-management-interface/src/client.rs +++ b/mullvad-management-interface/src/client.rs @@ -3,8 +3,8 @@ use crate::types; use futures::{Stream, StreamExt}; use mullvad_types::{ + access_method::{AccessMethod, AccessMethodSetting, ApiAccessMethodId}, account::{AccountData, AccountToken, VoucherSubmission}, - api_access::{AccessMethod, AccessMethodSetting, ApiAccessMethodId}, custom_list::{CustomList, CustomListLocationUpdate}, device::{Device, DeviceEvent, DeviceId, DeviceState, RemoveDeviceEvent}, location::GeoIpLocation, diff --git a/mullvad-management-interface/src/types/conversions/access_method.rs b/mullvad-management-interface/src/types/conversions/access_method.rs index 8652b065e473..ba5655ba4245 100644 --- a/mullvad-management-interface/src/types/conversions/access_method.rs +++ b/mullvad-management-interface/src/types/conversions/access_method.rs @@ -3,10 +3,10 @@ /// [`mullvad_types::access_method::Settings`] data type. mod settings { use crate::types::{proto, FromProtobufTypeError}; - use mullvad_types::api_access; + use mullvad_types::access_method; - impl From<&api_access::Settings> for proto::ApiAccessMethodSettings { - fn from(settings: &api_access::Settings) -> Self { + impl From<&access_method::Settings> for proto::ApiAccessMethodSettings { + fn from(settings: &access_method::Settings) -> Self { Self { access_method_settings: settings .access_method_settings @@ -17,13 +17,13 @@ mod settings { } } - impl From for proto::ApiAccessMethodSettings { - fn from(settings: api_access::Settings) -> Self { + impl From for proto::ApiAccessMethodSettings { + fn from(settings: access_method::Settings) -> Self { proto::ApiAccessMethodSettings::from(&settings) } } - impl TryFrom for api_access::Settings { + impl TryFrom for access_method::Settings { type Error = FromProtobufTypeError; fn try_from(settings: proto::ApiAccessMethodSettings) -> Result { @@ -31,8 +31,8 @@ mod settings { access_method_settings: settings .access_method_settings .iter() - .map(api_access::AccessMethodSetting::try_from) - .collect::, _>>()?, + .map(access_method::AccessMethodSetting::try_from) + .collect::, _>>()?, }) } } @@ -43,7 +43,7 @@ mod settings { /// [`mullvad_types::access_method::AccessMethodSetting`] data type. mod data { use crate::types::{proto, FromProtobufTypeError}; - use mullvad_types::api_access::{ + use mullvad_types::access_method::{ AccessMethod, AccessMethodSetting, ApiAccessMethodId, BuiltInAccessMethod, CustomAccessMethod, Shadowsocks, Socks5, Socks5Local, Socks5Remote, }; @@ -179,10 +179,10 @@ mod data { impl From for proto::AccessMethod { fn from(value: BuiltInAccessMethod) -> Self { let access_method = match value { - mullvad_types::api_access::BuiltInAccessMethod::Direct => { + mullvad_types::access_method::BuiltInAccessMethod::Direct => { proto::access_method::AccessMethod::Direct(proto::access_method::Direct {}) } - mullvad_types::api_access::BuiltInAccessMethod::Bridge => { + mullvad_types::access_method::BuiltInAccessMethod::Bridge => { proto::access_method::AccessMethod::Bridges(proto::access_method::Bridges {}) } }; diff --git a/mullvad-management-interface/src/types/conversions/settings.rs b/mullvad-management-interface/src/types/conversions/settings.rs index 1501f8c60616..30e6f9e943da 100644 --- a/mullvad-management-interface/src/types/conversions/settings.rs +++ b/mullvad-management-interface/src/types/conversions/settings.rs @@ -178,7 +178,7 @@ impl TryFrom for mullvad_types::settings::Settings { custom_lists: mullvad_types::custom_list::CustomListsSettings::try_from( custom_lists_settings, )?, - api_access_methods: mullvad_types::api_access::Settings::try_from( + api_access_methods: mullvad_types::access_method::Settings::try_from( api_access_methods_settings, )?, }) diff --git a/mullvad-types/src/api_access.rs b/mullvad-types/src/access_method.rs similarity index 100% rename from mullvad-types/src/api_access.rs rename to mullvad-types/src/access_method.rs diff --git a/mullvad-types/src/lib.rs b/mullvad-types/src/lib.rs index e1af195220b5..8aefaeb4000b 100644 --- a/mullvad-types/src/lib.rs +++ b/mullvad-types/src/lib.rs @@ -1,7 +1,7 @@ #![deny(rust_2018_idioms)] +pub mod access_method; pub mod account; -pub mod api_access; pub mod auth_failed; pub mod custom_list; pub mod device; diff --git a/mullvad-types/src/settings/mod.rs b/mullvad-types/src/settings/mod.rs index 2c40172a2cc6..6ade7dea3271 100644 --- a/mullvad-types/src/settings/mod.rs +++ b/mullvad-types/src/settings/mod.rs @@ -1,5 +1,5 @@ use crate::{ - api_access, + access_method, custom_list::CustomListsSettings, relay_constraints::{ BridgeConstraints, BridgeSettings, BridgeState, Constraint, GeographicLocationConstraint, @@ -79,7 +79,7 @@ pub struct Settings { pub custom_lists: CustomListsSettings, /// API access methods. #[cfg_attr(target_os = "android", jnix(skip))] - pub api_access_methods: api_access::Settings, + pub api_access_methods: access_method::Settings, /// If the daemon should allow communication with private (LAN) networks. pub allow_lan: bool, /// Extra level of kill switch. When this setting is on, the disconnected state will block @@ -140,7 +140,7 @@ impl Default for Settings { split_tunnel: SplitTunnelSettings::default(), settings_version: CURRENT_SETTINGS_VERSION, custom_lists: CustomListsSettings::default(), - api_access_methods: api_access::Settings::default(), + api_access_methods: access_method::Settings::default(), } } }