diff options
| author | Jonatan Rhodin <jonatan.rhodin@mullvad.net> | 2025-04-10 17:30:00 +0200 |
|---|---|---|
| committer | Jonatan Rhodin <jonatan.rhodin@mullvad.net> | 2025-04-10 17:30:00 +0200 |
| commit | 2142bb3c1cb8c7ecb52751fdc4c03622870d7733 (patch) | |
| tree | 23ca41e984b0742882bedf192bcd808708df55fb /android/lib | |
| parent | 1c5712f028250920fe34ce7686c77a7d80da9481 (diff) | |
| parent | 4fdf70105137c33b63a56a08688b27b7d3ec2260 (diff) | |
| download | mullvadvpn-2142bb3c1cb8c7ecb52751fdc4c03622870d7733.tar.xz mullvadvpn-2142bb3c1cb8c7ecb52751fdc4c03622870d7733.zip | |
Merge branch 'deeplink-feature-chips-to-settings-droid-1877'
Diffstat (limited to 'android/lib')
5 files changed, 45 insertions, 8 deletions
diff --git a/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/ManagementService.kt b/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/ManagementService.kt index 4d1baab550..5e0077d1f8 100644 --- a/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/ManagementService.kt +++ b/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/ManagementService.kt @@ -62,6 +62,7 @@ import net.mullvad.mullvadvpn.lib.model.CustomList as ModelCustomList import net.mullvad.mullvadvpn.lib.model.CustomListAlreadyExists import net.mullvad.mullvadvpn.lib.model.CustomListId import net.mullvad.mullvadvpn.lib.model.CustomListName +import net.mullvad.mullvadvpn.lib.model.DefaultDnsOptions import net.mullvad.mullvadvpn.lib.model.DeleteCustomListError import net.mullvad.mullvadvpn.lib.model.DeleteDeviceError import net.mullvad.mullvadvpn.lib.model.Device @@ -71,6 +72,7 @@ import net.mullvad.mullvadvpn.lib.model.DeviceUpdateError import net.mullvad.mullvadvpn.lib.model.DnsOptions as ModelDnsOptions import net.mullvad.mullvadvpn.lib.model.DnsOptions import net.mullvad.mullvadvpn.lib.model.DnsState as ModelDnsState +import net.mullvad.mullvadvpn.lib.model.DnsState import net.mullvad.mullvadvpn.lib.model.GetAccountDataError import net.mullvad.mullvadvpn.lib.model.GetAccountHistoryError import net.mullvad.mullvadvpn.lib.model.GetDeviceListError @@ -124,7 +126,7 @@ import net.mullvad.mullvadvpn.lib.model.WebsiteAuthToken import net.mullvad.mullvadvpn.lib.model.WireguardEndpointData as ModelWireguardEndpointData import net.mullvad.mullvadvpn.lib.model.addresses import net.mullvad.mullvadvpn.lib.model.customOptions -import net.mullvad.mullvadvpn.lib.model.enabled +import net.mullvad.mullvadvpn.lib.model.defaultOptions import net.mullvad.mullvadvpn.lib.model.entryLocation import net.mullvad.mullvadvpn.lib.model.ipVersion import net.mullvad.mullvadvpn.lib.model.isMultihopEnabled @@ -139,7 +141,7 @@ import net.mullvad.mullvadvpn.lib.model.state import net.mullvad.mullvadvpn.lib.model.udp2tcp import net.mullvad.mullvadvpn.lib.model.wireguardConstraints -@Suppress("TooManyFunctions") +@Suppress("TooManyFunctions", "LargeClass") class ManagementService( rpcSocketFile: File, private val extensiveLogging: Boolean, @@ -389,6 +391,19 @@ class ManagementService( .onLeft { Logger.e("Create account error") } .mapLeft(CreateAccountError::Unknown) + suspend fun updateDnsContentBlockers( + update: (DefaultDnsOptions) -> DefaultDnsOptions + ): Either<SetDnsOptionsError, Unit> = + Either.catch { + val currentDnsOptions = getSettings().tunnelOptions.dnsOptions + val newDefaultDnsOptions = update(currentDnsOptions.defaultOptions) + val updated = DnsOptions.defaultOptions.set(currentDnsOptions, newDefaultDnsOptions) + grpc.setDnsOptions(updated.fromDomain()) + } + .onLeft { Logger.e("Set dns state error") } + .mapLeft(SetDnsOptionsError::Unknown) + .mapEmpty() + suspend fun setDnsOptions(dnsOptions: ModelDnsOptions): Either<SetDnsOptionsError, Unit> = Either.catch { grpc.setDnsOptions(dnsOptions.fromDomain()) } .onLeft { Logger.e("Set dns options error") } @@ -423,7 +438,14 @@ class ManagementService( Either.catch { val currentDnsOptions = getSettings().tunnelOptions.dnsOptions val updatedDnsOptions = - DnsOptions.customOptions.addresses.modify(currentDnsOptions) { it + address } + currentDnsOptions.copy { + DnsOptions.customOptions.addresses set + currentDnsOptions.customOptions.addresses + address + // If it is the first address, then turn on Custom Dns + DnsOptions.state set + if (currentDnsOptions.customOptions.addresses.isEmpty()) DnsState.Custom + else currentDnsOptions.state + } grpc.setDnsOptions(updatedDnsOptions.fromDomain()) updatedDnsOptions.customOptions.addresses.lastIndex } @@ -433,11 +455,16 @@ class ManagementService( suspend fun deleteCustomDns(index: Int): Either<SetDnsOptionsError, Unit> = Either.catch { val currentDnsOptions = getSettings().tunnelOptions.dnsOptions + val mutableAddresses = currentDnsOptions.customOptions.addresses.toMutableList() + mutableAddresses.removeAt(index) + val updatedDnsOptions = - DnsOptions.customOptions.addresses.modify(currentDnsOptions) { - val mutableAddresses = it.toMutableList() - mutableAddresses.removeAt(index) - mutableAddresses.toList() + currentDnsOptions.copy { + DnsOptions.customOptions.addresses set mutableAddresses.toList() + // If it is the last address, then turn off Custom Dns + DnsOptions.state set + if (mutableAddresses.isEmpty()) DnsState.Default + else currentDnsOptions.state } grpc.setDnsOptions(updatedDnsOptions.fromDomain()) } diff --git a/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/mapper/ToDomain.kt b/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/mapper/ToDomain.kt index 10c417cf1c..eab0bc60a9 100644 --- a/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/mapper/ToDomain.kt +++ b/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/mapper/ToDomain.kt @@ -708,6 +708,7 @@ internal fun ManagementInterface.FeatureIndicator.toDomain() = ManagementInterface.FeatureIndicator.DAITA -> FeatureIndicator.DAITA ManagementInterface.FeatureIndicator.SHADOWSOCKS -> FeatureIndicator.SHADOWSOCKS ManagementInterface.FeatureIndicator.MULTIHOP -> FeatureIndicator.MULTIHOP + ManagementInterface.FeatureIndicator.DAITA_MULTIHOP -> FeatureIndicator.DAITA_MULTIHOP ManagementInterface.FeatureIndicator.LOCKDOWN_MODE, ManagementInterface.FeatureIndicator.BRIDGE_MODE, ManagementInterface.FeatureIndicator.CUSTOM_MSS_FIX, diff --git a/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/FeatureIndicator.kt b/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/FeatureIndicator.kt index 0da5704b4b..0213c06cef 100644 --- a/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/FeatureIndicator.kt +++ b/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/FeatureIndicator.kt @@ -3,6 +3,7 @@ package net.mullvad.mullvadvpn.lib.model // The order of the variants match the priority order and can be sorted on. enum class FeatureIndicator { DAITA, + DAITA_MULTIHOP, QUANTUM_RESISTANCE, MULTIHOP, SPLIT_TUNNELING, diff --git a/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/IpVersion.kt b/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/IpVersion.kt index 176809244c..4ca0a0be5f 100644 --- a/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/IpVersion.kt +++ b/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/IpVersion.kt @@ -2,5 +2,12 @@ package net.mullvad.mullvadvpn.lib.model enum class IpVersion { IPV4, - IPV6, + IPV6; + + companion object { + val constraints: List<Constraint<IpVersion>> = buildList { + add(Constraint.Any) + addAll(IpVersion.entries.map { Constraint.Only(it) }) + } + } } diff --git a/android/lib/resource/src/main/res/values/strings.xml b/android/lib/resource/src/main/res/values/strings.xml index 5ff72dfcd1..6c7f7da319 100644 --- a/android/lib/resource/src/main/res/values/strings.xml +++ b/android/lib/resource/src/main/res/values/strings.xml @@ -410,4 +410,5 @@ <string name="ip_version_v6_unavailable">IPv6 is not available, please try changing \"Device IP version\" setting.</string> <string name="device_ip_info_first_paragraph">This feature allows you to choose whether to use only IPv4, only IPv6, or allow the app to automatically decide the best option when connecting to a server.</string> <string name="device_ip_info_second_paragraph">It can be useful when you are aware of problems caused by a certain IP version.</string> + <string name="daita_multihop">%s: Multihop</string> </resources> |
