Skip to content

Commit

Permalink
Set "Direct only" to false as default
Browse files Browse the repository at this point in the history
For android, it is set to true, as multihop is not supported.

Note that in the daemon, the setting is called
`use_multihop_if_necessary` and has the inverse meaning.
  • Loading branch information
Serock3 committed Oct 7, 2024
1 parent b5fd766 commit 2f31950
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -510,10 +510,14 @@ class ManagementService(

suspend fun setDaitaEnabled(enabled: Boolean): Either<SetDaitaSettingsError, Unit> =
Either.catch {
val daitaSettings =
ManagementInterface.DaitaSettings.newBuilder().setEnabled(enabled).build()
grpc.setDaitaSettings(daitaSettings)
}
val daitaSettings =
ManagementInterface.DaitaSettings.newBuilder().setEnabled(enabled)
// TODO: Before Multihop is supported on Android, calling `setDirectOnly` with false
// will cause undefined behaviour.
.setDirectOnly(true)
.build()
grpc.setDaitaSettings(daitaSettings)
}
.mapLeft(SetDaitaSettingsError::Unknown)
.mapEmpty()

Expand Down
25 changes: 23 additions & 2 deletions mullvad-types/src/wireguard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,35 @@ impl FromStr for QuantumResistantState {
pub struct QuantumResistantStateParseError;

#[cfg(daita)]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct DaitaSettings {
pub enabled: bool,

#[serde(default)]
#[serde(default = "DaitaSettings::default_use_multihop_if_necessary")]
/// Whether to use multihop if the selected relay is not DAITA-compatible. Note that this is
/// the inverse of of "Direct only" in the GUI.
pub use_multihop_if_necessary: bool,
}

#[cfg(daita)]
impl DaitaSettings {
const fn default_use_multihop_if_necessary() -> bool {
cfg!(not(target_os = "android"))
}
}

#[cfg(daita)]
impl Default for DaitaSettings {
fn default() -> Self {
Self {
enabled: false,
// This setting should be enabled by default, expect on Android where multihop is not
// supported.
use_multihop_if_necessary: Self::default_use_multihop_if_necessary(),
}
}
}

/// Contains account specific wireguard data
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
pub struct WireguardData {
Expand Down

0 comments on commit 2f31950

Please sign in to comment.