Skip to content

Commit

Permalink
Add providers model and enable it in the daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
Pururun committed Oct 25, 2023
1 parent 5d424ee commit 285f89f
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class RelayListListener(
location = Constraint.Any(),
ownership = Constraint.Any(),
wireguardConstraints = WireguardConstraints(Constraint.Any()),
providers = Constraint.Any()
)
)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package net.mullvad.mullvadvpn.model

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

@JvmInline @Parcelize value class Providers(val providers: HashSet<String>) : Parcelable
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import kotlinx.parcelize.Parcelize
@Parcelize
data class RelayConstraints(
val location: Constraint<LocationConstraint>,
val providers: Constraint<Providers>,
val ownership: Constraint<Ownership>,
val wireguardConstraints: WireguardConstraints,
) : Parcelable
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package net.mullvad.mullvadvpn.model

data class RelayConstraintsUpdate(
val location: Constraint<LocationConstraint>?,
val providers: Constraint<Providers>?,
val ownership: Constraint<Ownership>?,
val wireguardConstraints: WireguardConstraints?
)
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ class RelayListListener(endpoint: ServiceEndpoint) {
RelayConstraintsUpdate(
location = location,
wireguardConstraints = wireguardConstraints,
ownership = Constraint.Any()
ownership = Constraint.Any(),
providers = Constraint.Any()
)
)

Expand Down
2 changes: 2 additions & 0 deletions mullvad-jni/src/classes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pub const CLASSES: &[&str] = &[
"java/net/InetAddress",
"java/net/InetSocketAddress",
"java/util/ArrayList",
"java/util/HashSet",
"net/mullvad/mullvadvpn/model/AccountAndDevice",
"net/mullvad/mullvadvpn/model/AccountData",
"net/mullvad/mullvadvpn/model/AppVersionInfo",
Expand Down Expand Up @@ -43,6 +44,7 @@ pub const CLASSES: &[&str] = &[
"net/mullvad/mullvadvpn/model/QuantumResistantState",
"net/mullvad/mullvadvpn/model/Port",
"net/mullvad/mullvadvpn/model/PortRange",
"net/mullvad/mullvadvpn/model/Providers",
"net/mullvad/mullvadvpn/model/Relay",
"net/mullvad/mullvadvpn/model/RelayConstraints",
"net/mullvad/mullvadvpn/model/RelayEndpointData$Bridge",
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 @@ -369,7 +369,6 @@ impl<'a> fmt::Display for LocationConstraintFormatter<'a> {
#[cfg_attr(target_os = "android", jnix(package = "net.mullvad.mullvadvpn.model"))]
pub struct RelayConstraints {
pub location: Constraint<LocationConstraint>,
#[cfg_attr(target_os = "android", jnix(skip))]
pub providers: Constraint<Providers>,
pub ownership: Constraint<Ownership>,
#[cfg_attr(target_os = "android", jnix(skip))]
Expand Down Expand Up @@ -607,6 +606,8 @@ pub struct OwnershipParseError;
/// provider.
pub type Provider = String;

#[cfg_attr(target_os = "android", derive(IntoJava, FromJava))]
#[cfg_attr(target_os = "android", jnix(package = "net.mullvad.mullvadvpn.model"))]
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
pub struct Providers {
providers: HashSet<Provider>,
Expand Down Expand Up @@ -986,7 +987,6 @@ impl RelaySettingsUpdate {
#[serde(default)]
pub struct RelayConstraintsUpdate {
pub location: Option<Constraint<LocationConstraint>>,
#[cfg_attr(target_os = "android", jnix(default))]
pub providers: Option<Constraint<Providers>>,
pub ownership: Option<Constraint<Ownership>>,
#[cfg_attr(target_os = "android", jnix(default))]
Expand Down

0 comments on commit 285f89f

Please sign in to comment.