diff --git a/mullvad-api/src/https_client_with_sni.rs b/mullvad-api/src/https_client_with_sni.rs index cc7557a8d2ad..e95fbf98fcdc 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::access_method::Socks5::Local(config) => { + mullvad_types::api_access::Socks5::Local(config) => { InnerConnectionMode::Socks5(SocksConfig { peer: SocketAddr::new("127.0.0.1".parse().unwrap(), config.port), }) } - mullvad_types::access_method::Socks5::Remote(config) => { + mullvad_types::api_access::Socks5::Remote(config) => { InnerConnectionMode::Socks5(SocksConfig { peer: config.peer }) } }, diff --git a/mullvad-api/src/proxy.rs b/mullvad-api/src/proxy.rs index 44a2309587e5..7d33840d6947 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::access_method; +use mullvad_types::api_access; 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(access_method::Shadowsocks), - Socks(access_method::Socks5), + Shadowsocks(api_access::Shadowsocks), + Socks(api_access::Socks5), } impl ProxyConfig { @@ -46,8 +46,8 @@ impl ProxyConfig { match self { ProxyConfig::Shadowsocks(ss) => ss.peer, ProxyConfig::Socks(socks) => match socks { - access_method::Socks5::Local(s) => s.peer, - access_method::Socks5::Remote(s) => s.peer, + api_access::Socks5::Local(s) => s.peer, + api_access::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 { - access_method::Socks5::Local(s) => { + api_access::Socks5::Local(s) => { write!(f, "Socks5 {}/TCP via localhost:{}", s.peer, s.port) } - access_method::Socks5::Remote(s) => write!(f, "Socks5 {}/TCP", s.peer), + api_access::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 d08f1b0b17bd..e18482f34eff 100644 --- a/mullvad-cli/src/cmds/api_access.rs +++ b/mullvad-cli/src/cmds/api_access.rs @@ -2,7 +2,7 @@ use anyhow::{anyhow, Result}; use mullvad_management_interface::{ types::rpc::api_access_method_update::ApiAccessMethodUpdate, MullvadProxyClient, }; -use mullvad_types::access_method::{AccessMethod, ApiAccessMethod, CustomAccessMethod}; +use mullvad_types::api_access::{AccessMethod, ApiAccessMethod, CustomAccessMethod}; use std::net::IpAddr; use clap::{Args, Subcommand}; @@ -107,27 +107,28 @@ impl ApiAccess { let cipher = cmd.params.cipher.unwrap_or(shadowsocks.cipher); let name = cmd.params.name.unwrap_or(api_access_method.name); let enabled = api_access_method.enabled; - mullvad_types::access_method::Shadowsocks::from_args(ip, port, cipher, password) - .map(|shadowsocks| { + mullvad_types::api_access::Shadowsocks::from_args(ip, port, cipher, password).map( + |shadowsocks| { ApiAccessMethod::new(name, enabled, AccessMethod::from(shadowsocks)) - }) + }, + ) } CustomAccessMethod::Socks5(socks) => match socks { - mullvad_types::access_method::Socks5::Local(local) => { + mullvad_types::api_access::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); let name = cmd.params.name.unwrap_or(api_access_method.get_name()); let enabled = api_access_method.enabled(); - mullvad_types::access_method::Socks5Local::from_args(ip, port, local_port) + mullvad_types::api_access::Socks5Local::from_args(ip, port, local_port) .map(|socks| ApiAccessMethod::new(name, enabled, AccessMethod::from(socks))) } - mullvad_types::access_method::Socks5::Remote(remote) => { + mullvad_types::api_access::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()); let name = cmd.params.name.unwrap_or(api_access_method.get_name()); let enabled = api_access_method.enabled(); - mullvad_types::access_method::Socks5Remote::from_args(ip, port) + mullvad_types::api_access::Socks5Remote::from_args(ip, port) .map(|socks| ApiAccessMethod::new(name, enabled, AccessMethod::from(socks))) } }, @@ -310,7 +311,7 @@ pub struct EditParams { /// we define them in a hidden-away module. mod conversions { use anyhow::{anyhow, Error}; - use mullvad_types::access_method as daemon_types; + use mullvad_types::api_access as daemon_types; use super::{AddCustomCommands, Socks5AddCommands}; @@ -394,7 +395,7 @@ mod conversions { /// Pretty printing of [`ApiAccessMethod`]s mod pp { - use mullvad_types::access_method::{AccessMethod, ApiAccessMethod, CustomAccessMethod, Socks5}; + use mullvad_types::api_access::{AccessMethod, ApiAccessMethod, CustomAccessMethod, Socks5}; pub struct ApiAccessMethodFormatter<'a> { api_access_method: &'a ApiAccessMethod, diff --git a/mullvad-daemon/src/access_method.rs b/mullvad-daemon/src/access_method.rs index a212de649dc8..536d122fe781 100644 --- a/mullvad-daemon/src/access_method.rs +++ b/mullvad-daemon/src/access_method.rs @@ -3,7 +3,7 @@ use crate::{ Daemon, EventListener, }; use mullvad_management_interface::types::rpc::api_access_method_update::ApiAccessMethodUpdate; -use mullvad_types::access_method::{ApiAccessMethod, ApiAccessMethodId}; +use mullvad_types::api_access::{ApiAccessMethod, ApiAccessMethodId}; #[derive(err_derive::Error, Debug)] pub enum Error { diff --git a/mullvad-daemon/src/api.rs b/mullvad-daemon/src/api.rs index e07037edada3..5605f567caf1 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::access_method::{self, AccessMethod, BuiltInAccessMethod}; +use mullvad_types::api_access::{self, AccessMethod, BuiltInAccessMethod}; use std::{ net::SocketAddr, path::PathBuf, @@ -131,12 +131,11 @@ impl ApiConnectionModeProvider { .get_bridge_forced() .and_then(|settings| match settings { ProxySettings::Shadowsocks(ss_settings) => { - let ss_settings: access_method::Shadowsocks = - access_method::Shadowsocks::new( - ss_settings.peer, - ss_settings.cipher, - ss_settings.password, - ); + let ss_settings: api_access::Shadowsocks = api_access::Shadowsocks::new( + ss_settings.peer, + ss_settings.cipher, + ss_settings.password, + ); Some(ApiConnectionMode::Proxied(ProxyConfig::Shadowsocks( ss_settings, ))) @@ -149,10 +148,10 @@ impl ApiConnectionModeProvider { .unwrap_or(ApiConnectionMode::Direct), }, AccessMethod::Custom(access_method) => match &access_method { - access_method::CustomAccessMethod::Shadowsocks(shadowsocks_config) => { + api_access::CustomAccessMethod::Shadowsocks(shadowsocks_config) => { ApiConnectionMode::Proxied(ProxyConfig::Shadowsocks(shadowsocks_config.clone())) } - access_method::CustomAccessMethod::Socks5(socks_config) => { + api_access::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 86218bbcd343..8bb296de4eae 100644 --- a/mullvad-daemon/src/lib.rs +++ b/mullvad-daemon/src/lib.rs @@ -40,8 +40,8 @@ use mullvad_relay_selector::{ RelaySelector, SelectorConfig, }; use mullvad_types::{ - access_method::{ApiAccessMethod, ApiAccessMethodId}, account::{AccountData, AccountToken, VoucherSubmission}, + api_access::{ApiAccessMethod, 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 2306c66a99ba..8e471ee26b4c 100644 --- a/mullvad-daemon/src/management_interface.rs +++ b/mullvad-daemon/src/management_interface.rs @@ -626,7 +626,7 @@ impl ManagementService for ManagementServiceImpl { ) -> ServiceResult<()> { log::debug!("add_api_access_method"); let api_access_method = - mullvad_types::access_method::ApiAccessMethod::try_from(request.into_inner())?; + mullvad_types::api_access::ApiAccessMethod::try_from(request.into_inner())?; let (tx, rx) = oneshot::channel(); self.send_command_to_daemon(DaemonCommand::AddApiAccessMethod(tx, api_access_method))?; self.wait_for_result(rx) @@ -638,7 +638,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::access_method::ApiAccessMethodId::from(request.into_inner()); + mullvad_types::api_access::ApiAccessMethodId::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) @@ -670,7 +670,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::access_method::ApiAccessMethodId::from(request.into_inner()); + mullvad_types::api_access::ApiAccessMethodId::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 a8aa9613657f..7b4358c74116 100644 --- a/mullvad-management-interface/src/client.rs +++ b/mullvad-management-interface/src/client.rs @@ -3,8 +3,8 @@ use crate::types::{self, rpc}; use futures::{Stream, StreamExt}; use mullvad_types::{ - access_method::{ApiAccessMethod, ApiAccessMethodId}, account::{AccountData, AccountToken, VoucherSubmission}, + api_access::{ApiAccessMethod, ApiAccessMethodId}, custom_list::{CustomList, CustomListLocationUpdate}, device::{Device, DeviceEvent, DeviceId, DeviceState, RemoveDeviceEvent}, location::GeoIpLocation, diff --git a/mullvad-management-interface/src/types/conversions/api_access_method.rs b/mullvad-management-interface/src/types/conversions/api_access_method.rs index b007543d87a0..a34faf63dd9d 100644 --- a/mullvad-management-interface/src/types/conversions/api_access_method.rs +++ b/mullvad-management-interface/src/types/conversions/api_access_method.rs @@ -5,10 +5,10 @@ pub mod settings { use crate::types::{ proto, rpc::api_access_method_update::ApiAccessMethodUpdate, FromProtobufTypeError, }; - use mullvad_types::access_method; + use mullvad_types::api_access; - impl From<&access_method::Settings> for proto::ApiAccessMethodSettings { - fn from(settings: &access_method::Settings) -> Self { + impl From<&api_access::Settings> for proto::ApiAccessMethodSettings { + fn from(settings: &api_access::Settings) -> Self { Self { api_access_methods: settings .api_access_methods @@ -19,13 +19,13 @@ pub mod settings { } } - impl From for proto::ApiAccessMethodSettings { - fn from(settings: access_method::Settings) -> Self { + impl From for proto::ApiAccessMethodSettings { + fn from(settings: api_access::Settings) -> Self { proto::ApiAccessMethodSettings::from(&settings) } } - impl TryFrom for access_method::Settings { + impl TryFrom for api_access::Settings { type Error = FromProtobufTypeError; fn try_from(settings: proto::ApiAccessMethodSettings) -> Result { @@ -33,8 +33,8 @@ pub mod settings { api_access_methods: settings .api_access_methods .iter() - .map(access_method::ApiAccessMethod::try_from) - .collect::, _>>()?, + .map(api_access::ApiAccessMethod::try_from) + .collect::, _>>()?, }) } } @@ -57,14 +57,14 @@ pub mod settings { .ok_or(FromProtobufTypeError::InvalidArgument( "Could not convert Access Method from protobuf", )) - .and_then(access_method::ApiAccessMethod::try_from)?; + .and_then(api_access::ApiAccessMethod::try_from)?; let id = value .id .ok_or(FromProtobufTypeError::InvalidArgument( "Could not convert Access Method from protobuf", )) - .map(access_method::ApiAccessMethodId::from)?; + .map(api_access::ApiAccessMethodId::from)?; Ok(ApiAccessMethodUpdate { id, @@ -79,7 +79,7 @@ pub mod settings { /// [`mullvad_types::access_method::AccessMethod`] data type. mod data { use crate::types::{proto, FromProtobufTypeError}; - use mullvad_types::access_method::{ + use mullvad_types::api_access::{ AccessMethod, ApiAccessMethod, ApiAccessMethodId, BuiltInAccessMethod, CustomAccessMethod, Shadowsocks, Socks5, Socks5Local, Socks5Remote, }; @@ -204,12 +204,12 @@ mod data { } }, AccessMethod::BuiltIn(value) => match value { - mullvad_types::access_method::BuiltInAccessMethod::Direct => { + mullvad_types::api_access::BuiltInAccessMethod::Direct => { proto::api_access_method::AccessMethod::Direct( proto::api_access_method::Direct {}, ) } - mullvad_types::access_method::BuiltInAccessMethod::Bridge => { + mullvad_types::api_access::BuiltInAccessMethod::Bridge => { proto::api_access_method::AccessMethod::Bridges( proto::api_access_method::Bridges {}, ) diff --git a/mullvad-management-interface/src/types/conversions/settings.rs b/mullvad-management-interface/src/types/conversions/settings.rs index 30e6f9e943da..1501f8c60616 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::access_method::Settings::try_from( + api_access_methods: mullvad_types::api_access::Settings::try_from( api_access_methods_settings, )?, }) diff --git a/mullvad-management-interface/src/types/rpc/api_access_method_update.rs b/mullvad-management-interface/src/types/rpc/api_access_method_update.rs index 0e50d0ff6740..b2708931026f 100644 --- a/mullvad-management-interface/src/types/rpc/api_access_method_update.rs +++ b/mullvad-management-interface/src/types/rpc/api_access_method_update.rs @@ -1,5 +1,5 @@ /// A short-lived datastructure used in the `ApiAccessMethodUpdate` RPC call. -use mullvad_types::access_method::{ApiAccessMethod, ApiAccessMethodId}; +use mullvad_types::api_access::{ApiAccessMethod, ApiAccessMethodId}; /// Argument to gRPC call `UpdateApiAccessMethod`. #[derive(Debug, Clone, PartialEq)] pub struct ApiAccessMethodUpdate { diff --git a/mullvad-types/src/access_method.rs b/mullvad-types/src/api_access.rs similarity index 100% rename from mullvad-types/src/access_method.rs rename to mullvad-types/src/api_access.rs diff --git a/mullvad-types/src/lib.rs b/mullvad-types/src/lib.rs index 8aefaeb4000b..e1af195220b5 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 6ade7dea3271..2c40172a2cc6 100644 --- a/mullvad-types/src/settings/mod.rs +++ b/mullvad-types/src/settings/mod.rs @@ -1,5 +1,5 @@ use crate::{ - access_method, + api_access, 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: access_method::Settings, + pub api_access_methods: api_access::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: access_method::Settings::default(), + api_access_methods: api_access::Settings::default(), } } }