diff options
| author | David Göransson <david.goransson@mullvad.net> | 2025-03-31 09:36:52 +0200 |
|---|---|---|
| committer | Jonatan Rhodin <jonatan.rhodin@mullvad.net> | 2025-04-10 17:29:33 +0200 |
| commit | 042820a80d994a09a58dfcdc7dce1ee1d891ac39 (patch) | |
| tree | b35efcceebded11d98cec4adc08a52febb2eedf8 /android/lib/daemon-grpc/src | |
| parent | 1c5712f028250920fe34ce7686c77a7d80da9481 (diff) | |
| download | mullvadvpn-042820a80d994a09a58dfcdc7dce1ee1d891ac39.tar.xz mullvadvpn-042820a80d994a09a58dfcdc7dce1ee1d891ac39.zip | |
Implement quick access to active features
- Add Daita: Multihop feature indicator
- Make feature indicators clickable
- Add animations when accessing the features through the indicators
- Rework VpnSettings in order to support navigating to a feature in the
list
Diffstat (limited to 'android/lib/daemon-grpc/src')
2 files changed, 35 insertions, 7 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, |
