diff --git a/mullvad-daemon/src/api.rs b/mullvad-daemon/src/api.rs index ac54382a57eb..930bba42c6c5 100644 --- a/mullvad-daemon/src/api.rs +++ b/mullvad-daemon/src/api.rs @@ -536,6 +536,9 @@ fn resolve_connection_mode( ); ApiConnectionMode::Direct }), + AccessMethod::BuiltIn(BuiltInAccessMethod::EncryptedDnsProxy) => { + todo!("Implement me!") + } AccessMethod::Custom(config) => ApiConnectionMode::Proxied(ProxyConfig::from(config)), } } diff --git a/mullvad-management-interface/proto/management_interface.proto b/mullvad-management-interface/proto/management_interface.proto index b57d63dcf3bd..62740438fbfa 100644 --- a/mullvad-management-interface/proto/management_interface.proto +++ b/mullvad-management-interface/proto/management_interface.proto @@ -411,10 +411,12 @@ message CustomProxy { message AccessMethod { message Direct {} message Bridges {} + message EncryptedDnsProxy {} oneof access_method { Direct direct = 1; Bridges bridges = 2; - CustomProxy custom = 3; + EncryptedDnsProxy encrypted_dns_proxy = 3; + CustomProxy custom = 4; } } @@ -434,7 +436,8 @@ message NewAccessMethodSetting { message ApiAccessMethodSettings { AccessMethodSetting direct = 1; AccessMethodSetting mullvad_bridges = 2; - repeated AccessMethodSetting custom = 3; + AccessMethodSetting encrypted_dns_proxy = 3; + repeated AccessMethodSetting custom = 4; } message Settings { diff --git a/mullvad-management-interface/src/types/conversions/access_method.rs b/mullvad-management-interface/src/types/conversions/access_method.rs index 9f45957db6b8..be3b4c20a801 100644 --- a/mullvad-management-interface/src/types/conversions/access_method.rs +++ b/mullvad-management-interface/src/types/conversions/access_method.rs @@ -10,6 +10,7 @@ mod settings { Self { direct: Some(settings.direct().clone().into()), mullvad_bridges: Some(settings.mullvad_bridges().clone().into()), + encrypted_dns_proxy: Some(settings.encrypted_dns_proxy().clone().into()), custom: settings .iter_custom() .cloned() @@ -37,6 +38,13 @@ mod settings { )) .and_then(access_method::AccessMethodSetting::try_from)?; + let encrypted_dns_proxy = settings + .encrypted_dns_proxy + .ok_or(FromProtobufTypeError::InvalidArgument( + "Could not deserialize Encrypted DNS proxy Access Method from protobuf", + )) + .and_then(access_method::AccessMethodSetting::try_from)?; + let custom = settings .custom .iter() @@ -46,6 +54,7 @@ mod settings { Ok(access_method::Settings::new( direct, mullvad_bridges, + encrypted_dns_proxy, custom, )) } @@ -118,6 +127,9 @@ mod data { Ok(match access_method { proto::access_method::AccessMethod::Direct(direct) => AccessMethod::from(direct), proto::access_method::AccessMethod::Bridges(bridge) => AccessMethod::from(bridge), + proto::access_method::AccessMethod::EncryptedDnsProxy(proxy) => { + AccessMethod::from(proxy) + } proto::access_method::AccessMethod::Custom(custom) => { CustomProxy::try_from(custom).map(AccessMethod::from)? } @@ -146,6 +158,12 @@ mod data { } } + impl From for AccessMethod { + fn from(_value: proto::access_method::EncryptedDnsProxy) -> Self { + AccessMethod::from(BuiltInAccessMethod::EncryptedDnsProxy) + } + } + impl TryFrom for AccessMethod { type Error = FromProtobufTypeError; @@ -187,6 +205,11 @@ mod data { mullvad_types::access_method::BuiltInAccessMethod::Bridge => { proto::access_method::AccessMethod::Bridges(proto::access_method::Bridges {}) } + mullvad_types::access_method::BuiltInAccessMethod::EncryptedDnsProxy => { + proto::access_method::AccessMethod::EncryptedDnsProxy( + proto::access_method::EncryptedDnsProxy {}, + ) + } } } } diff --git a/mullvad-types/src/access_method.rs b/mullvad-types/src/access_method.rs index 2b375efb920e..bf6f3ee33fc2 100644 --- a/mullvad-types/src/access_method.rs +++ b/mullvad-types/src/access_method.rs @@ -6,6 +6,7 @@ use talpid_types::net::proxy::{CustomProxy, Shadowsocks, Socks5Local, Socks5Remo pub struct Settings { direct: AccessMethodSetting, mullvad_bridges: AccessMethodSetting, + encrypted_dns_proxy: AccessMethodSetting, /// Custom API access methods. custom: Vec, } @@ -14,11 +15,13 @@ impl Settings { pub fn new( direct: AccessMethodSetting, mullvad_bridges: AccessMethodSetting, + encrypted_dns_proxy: AccessMethodSetting, custom: Vec, ) -> Settings { Settings { direct, mullvad_bridges, + encrypted_dns_proxy, custom, } } @@ -93,6 +96,7 @@ impl Settings { use std::iter::once; once(&self.direct) .chain(once(&self.mullvad_bridges)) + .chain(once(&self.encrypted_dns_proxy)) .chain(&self.custom) } @@ -125,6 +129,10 @@ impl Settings { &self.mullvad_bridges } + pub fn encrypted_dns_proxy(&self) -> &AccessMethodSetting { + &self.encrypted_dns_proxy + } + fn create_direct() -> AccessMethodSetting { let method = BuiltInAccessMethod::Direct; AccessMethodSetting::new(method.canonical_name(), true, AccessMethod::from(method)) @@ -134,6 +142,11 @@ impl Settings { let method = BuiltInAccessMethod::Bridge; AccessMethodSetting::new(method.canonical_name(), true, AccessMethod::from(method)) } + + fn create_encrypted_dns_proxy() -> AccessMethodSetting { + let method = BuiltInAccessMethod::EncryptedDnsProxy; + AccessMethodSetting::new(method.canonical_name(), true, AccessMethod::from(method)) + } } impl Default for Settings { @@ -141,6 +154,7 @@ impl Default for Settings { Self { direct: Settings::create_direct(), mullvad_bridges: Settings::create_mullvad_bridges(), + encrypted_dns_proxy: Settings::create_encrypted_dns_proxy(), custom: vec![], } } @@ -271,6 +285,7 @@ impl AccessMethodSetting { pub enum BuiltInAccessMethod { Direct, Bridge, + EncryptedDnsProxy, } impl AccessMethod { @@ -287,6 +302,7 @@ impl BuiltInAccessMethod { match self { BuiltInAccessMethod::Direct => "Direct".to_string(), BuiltInAccessMethod::Bridge => "Mullvad Bridges".to_string(), + BuiltInAccessMethod::EncryptedDnsProxy => "Encrypted DNS proxy".to_string(), } } }