Skip to content

Commit

Permalink
Add relay ownership enum to relay constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
Pururun committed Oct 20, 2023
1 parent 61f8d70 commit 3d163de
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ class RelayListListener(
relaySettings =
newRelaySettings
?: RelaySettings.Normal(
RelayConstraints(Constraint.Any(), WireguardConstraints(Constraint.Any()))
RelayConstraints(
location = Constraint.Any(),
ownership = Constraint.Any(),
wireguardConstraints = WireguardConstraints(Constraint.Any()),
)
)

if (relayCountries != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package net.mullvad.mullvadvpn.model

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
enum class Ownership : Parcelable {
MullvadOwned,
Rented
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ import kotlinx.parcelize.Parcelize
@Parcelize
data class RelayConstraints(
val location: Constraint<LocationConstraint>,
val wireguardConstraints: WireguardConstraints
val ownership: Constraint<Ownership>,
val wireguardConstraints: WireguardConstraints,
) : Parcelable
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ package net.mullvad.mullvadvpn.model

data class RelayConstraintsUpdate(
val location: Constraint<LocationConstraint>?,
val ownership: Constraint<Ownership>?,
val wireguardConstraints: WireguardConstraints?
)
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,13 @@ class RelayListListener(endpoint: ServiceEndpoint) {
val wireguardConstraints: WireguardConstraints? = selectedWireguardConstraints

val update =
RelaySettingsUpdate.Normal(RelayConstraintsUpdate(location, wireguardConstraints))
RelaySettingsUpdate.Normal(
RelayConstraintsUpdate(
location = location,
wireguardConstraints = wireguardConstraints,
ownership = Constraint.Any()
)
)

daemon.await().updateRelaySettings(update)
}
Expand Down
1 change: 1 addition & 0 deletions mullvad-jni/src/classes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub const CLASSES: &[&str] = &[
"net/mullvad/mullvadvpn/model/LocationConstraint$Location",
"net/mullvad/mullvadvpn/model/LocationConstraint$CustomList",
"net/mullvad/mullvadvpn/model/ObfuscationSettings",
"net/mullvad/mullvadvpn/model/Ownership",
"net/mullvad/mullvadvpn/model/PlayPurchase",
"net/mullvad/mullvadvpn/model/PlayPurchaseInitError",
"net/mullvad/mullvadvpn/model/PlayPurchaseInitResult",
Expand Down
4 changes: 2 additions & 2 deletions mullvad-types/src/relay_constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,6 @@ pub struct RelayConstraints {
pub location: Constraint<LocationConstraint>,
#[cfg_attr(target_os = "android", jnix(skip))]
pub providers: Constraint<Providers>,
#[cfg_attr(target_os = "android", jnix(skip))]
pub ownership: Constraint<Ownership>,
#[cfg_attr(target_os = "android", jnix(skip))]
pub tunnel_protocol: Constraint<TunnelType>,
Expand Down Expand Up @@ -560,6 +559,8 @@ impl Set<Constraint<Vec<GeographicLocationConstraint>>>

/// Limits the set of servers to choose based on ownership.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[cfg_attr(target_os = "android", derive(IntoJava, FromJava))]
#[cfg_attr(target_os = "android", jnix(package = "net.mullvad.mullvadvpn.model"))]
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
pub enum Ownership {
MullvadOwned,
Expand Down Expand Up @@ -987,7 +988,6 @@ pub struct RelayConstraintsUpdate {
pub location: Option<Constraint<LocationConstraint>>,
#[cfg_attr(target_os = "android", jnix(default))]
pub providers: Option<Constraint<Providers>>,
#[cfg_attr(target_os = "android", jnix(default))]
pub ownership: Option<Constraint<Ownership>>,
#[cfg_attr(target_os = "android", jnix(default))]
pub tunnel_protocol: Option<Constraint<TunnelType>>,
Expand Down

0 comments on commit 3d163de

Please sign in to comment.