diff options
| author | Albin <albin@mullvad.net> | 2024-08-28 20:33:46 +0200 |
|---|---|---|
| committer | Albin <albin@mullvad.net> | 2024-08-28 20:44:14 +0200 |
| commit | b52c423d777213d5bb92430bccec880c6367a70b (patch) | |
| tree | 6ce254a809c1555fbde9a1c5692725042803854c /android/lib/daemon-grpc/src | |
| parent | a71f1e7a6888bc6af5a9df355afd26d3f56d0e5c (diff) | |
| download | mullvadvpn-b52c423d777213d5bb92430bccec880c6367a70b.tar.xz mullvadvpn-b52c423d777213d5bb92430bccec880c6367a70b.zip | |
Reformat kotlin code using updated ktfmt plugin
This commit mostly adds trailing commas throughout the project,
but also includes a few other formatting changes.
Diffstat (limited to 'android/lib/daemon-grpc/src')
4 files changed, 74 insertions, 76 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 c10f3b58e6..b51fd7eb2f 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 @@ -145,7 +145,7 @@ class ManagementService( private val channel = UdsChannelBuilder.forPath( rpcSocketFile.absolutePath, - LocalSocketAddress.Namespace.FILESYSTEM + LocalSocketAddress.Namespace.FILESYSTEM, ) // We need to provide a DummyNameResolver to avoid default NameResolver making incorrect // InetSocketAddress look ups. For more info see: @@ -264,14 +264,14 @@ class ManagementService( suspend fun removeDevice( token: AccountNumber, - deviceId: DeviceId + deviceId: DeviceId, ): Either<DeleteDeviceError, Unit> = Either.catch { grpc.removeDevice( ManagementInterface.DeviceRemoval.newBuilder() .setAccountToken(token.value) .setDeviceId(deviceId.value.toString()) - .build(), + .build() ) } .mapEmpty() @@ -363,7 +363,7 @@ class ManagementService( async { _mutableSettings.update { getSettings() } }, async { _mutableVersionInfo.update { getVersionInfo().getOrNull() } }, async { _mutableRelayList.update { getRelayList() } }, - async { _mutableCurrentAccessMethod.update { getCurrentApiAccessMethod() } } + async { _mutableCurrentAccessMethod.update { getCurrentApiAccessMethod() } }, ) } } @@ -584,7 +584,7 @@ class ManagementService( suspend fun setOwnershipAndProviders( ownershipConstraint: Constraint<ModelOwnership>, - providersConstraint: Constraint<Providers> + providersConstraint: Constraint<Providers>, ): Either<SetWireguardConstraintsError, Unit> = Either.catch { val relaySettings = getSettings().relaySettings 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 ca4e924b6c..5e8df1edc4 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 @@ -80,7 +80,7 @@ internal fun ManagementInterface.TunnelState.toDomain(): TunnelState = if (hasDisconnectedLocation()) { disconnectedLocation.toDomain() } else null - }, + } ) ManagementInterface.TunnelState.StateCase.CONNECTING -> TunnelState.Connecting( @@ -91,7 +91,7 @@ internal fun ManagementInterface.TunnelState.toDomain(): TunnelState = location.toDomain() } else null }, - featureIndicators = connected.featureIndicators.toDomain() + featureIndicators = connected.featureIndicators.toDomain(), ) ManagementInterface.TunnelState.StateCase.CONNECTED -> TunnelState.Connected( @@ -104,18 +104,16 @@ internal fun ManagementInterface.TunnelState.toDomain(): TunnelState = null } }, - featureIndicators = connected.featureIndicators.toDomain() + featureIndicators = connected.featureIndicators.toDomain(), ) ManagementInterface.TunnelState.StateCase.DISCONNECTING -> TunnelState.Disconnecting( - actionAfterDisconnect = disconnecting.afterDisconnect.toDomain(), + actionAfterDisconnect = disconnecting.afterDisconnect.toDomain() ) ManagementInterface.TunnelState.StateCase.ERROR -> TunnelState.Error(errorState = error.errorState.toDomain()) ManagementInterface.TunnelState.StateCase.STATE_NOT_SET -> - TunnelState.Disconnected( - location = disconnected.disconnectedLocation.toDomain(), - ) + TunnelState.Disconnected(location = disconnected.disconnectedLocation.toDomain()) } internal fun ManagementInterface.GeoIpLocation.toDomain(): GeoIpLocation = @@ -136,7 +134,7 @@ internal fun ManagementInterface.GeoIpLocation.toDomain(): GeoIpLocation = city = city, latitude = latitude, longitude = longitude, - hostname = hostname + hostname = hostname, ) internal fun ManagementInterface.TunnelEndpoint.toDomain(): TunnelEndpoint = @@ -150,7 +148,7 @@ internal fun ManagementInterface.TunnelEndpoint.toDomain(): TunnelEndpoint = Endpoint( address = InetSocketAddress(InetAddress.getByName(ipPart), portPart.toInt()), - protocol = protocol.toDomain() + protocol = protocol.toDomain(), ) }, quantumResistant = quantumResistant, @@ -159,14 +157,14 @@ internal fun ManagementInterface.TunnelEndpoint.toDomain(): TunnelEndpoint = obfuscation.toDomain() } else { null - } + }, ) internal fun ManagementInterface.ObfuscationEndpoint.toDomain(): ObfuscationEndpoint = ObfuscationEndpoint( endpoint = Endpoint(address = InetSocketAddress(address, port), protocol = protocol.toDomain()), - obfuscationType = obfuscationType.toDomain() + obfuscationType = obfuscationType.toDomain(), ) internal fun ManagementInterface.ObfuscationEndpoint.ObfuscationType.toDomain(): ObfuscationType = @@ -220,7 +218,7 @@ internal fun ManagementInterface.ErrorState.toDomain(): ErrorState = ManagementInterface.ErrorState.Cause.CREATE_TUNNEL_DEVICE -> throw IllegalArgumentException("Unrecognized error state cause") }, - isBlocking = !hasBlockingError() + isBlocking = !hasBlockingError(), ) internal fun ManagementInterface.ErrorState.FirewallPolicyError.toDomain(): @@ -258,14 +256,14 @@ internal fun ManagementInterface.Settings.toDomain(): Settings = relayOverrides = relayOverridesList.map { it.toDomain() }, showBetaReleases = showBetaReleases, splitTunnelSettings = splitTunnel.toDomain(), - apiAccessMethodSettings = apiAccessMethods.toDomain() + apiAccessMethodSettings = apiAccessMethods.toDomain(), ) internal fun ManagementInterface.RelayOverride.toDomain(): RelayOverride = RelayOverride( hostname = hostname, ipv4AddressIn = if (hasIpv4AddrIn()) InetAddress.getByName(ipv4AddrIn) else null, - ipv6AddressIn = if (hasIpv6AddrIn()) InetAddress.getByName(ipv6AddrIn) else null + ipv6AddressIn = if (hasIpv6AddrIn()) InetAddress.getByName(ipv6AddrIn) else null, ) internal fun ManagementInterface.RelaySettings.toDomain(): RelaySettings = @@ -283,7 +281,7 @@ internal fun ManagementInterface.NormalRelaySettings.toDomain(): RelayConstraint location = location.toDomain(), providers = providersList.toDomain(), ownership = ownership.toDomain(), - wireguardConstraints = wireguardConstraints.toDomain() + wireguardConstraints = wireguardConstraints.toDomain(), ) internal fun ManagementInterface.LocationConstraint.toDomain(): Constraint<RelayItemId> = @@ -320,7 +318,7 @@ internal fun ManagementInterface.WireguardConstraints.toDomain(): WireguardConst Constraint.Only(Port(port)) } else { Constraint.Any - }, + } ) internal fun ManagementInterface.Ownership.toDomain(): Constraint<Ownership> = @@ -335,7 +333,7 @@ internal fun ManagementInterface.Ownership.toDomain(): Constraint<Ownership> = internal fun ManagementInterface.ObfuscationSettings.toDomain(): ObfuscationSettings = ObfuscationSettings( selectedObfuscation = selectedObfuscation.toDomain(), - udp2tcp = udp2Tcp.toDomain() + udp2tcp = udp2Tcp.toDomain(), ) internal fun ManagementInterface.ObfuscationSettings.SelectedObfuscation.toDomain(): @@ -362,7 +360,7 @@ internal fun ManagementInterface.CustomList.toDomain(): CustomList = CustomList( id = CustomListId(id), name = CustomListName.fromString(name), - locations = locationsList.map { it.toDomain() } + locations = locationsList.map { it.toDomain() }, ) internal fun ManagementInterface.TunnelOptions.toDomain(): TunnelOptions = @@ -388,7 +386,7 @@ internal fun ManagementInterface.DnsOptions.toDomain(): DnsOptions = DnsOptions( state = state.toDomain(), defaultOptions = defaultOptions.toDomain(), - customOptions = customOptions.toDomain() + customOptions = customOptions.toDomain(), ) internal fun ManagementInterface.DnsOptions.DnsState.toDomain(): DnsState = @@ -406,7 +404,7 @@ internal fun ManagementInterface.DefaultDnsOptions.toDomain() = blockAdultContent = blockAdultContent, blockGambling = blockGambling, blockSocialMedia = blockSocialMedia, - blockTrackers = blockTrackers + blockTrackers = blockTrackers, ) internal fun ManagementInterface.CustomDnsOptions.toDomain() = @@ -426,7 +424,7 @@ internal fun QuantumResistantState.toDomain(): ManagementInterface.QuantumResist internal fun ManagementInterface.AppVersionInfo.toDomain(): AppVersionInfo = AppVersionInfo( supported = supported, - suggestedUpgrade = if (hasSuggestedUpgrade()) suggestedUpgrade else null + suggestedUpgrade = if (hasSuggestedUpgrade()) suggestedUpgrade else null, ) internal fun ConnectivityState.toDomain(): GrpcConnectivityState = @@ -465,7 +463,7 @@ internal fun ManagementInterface.RelayListCountry.toDomain(): RelayItem.Location citiesList .map { city -> city.toDomain(countryCode) } .filter { it.relays.isNotEmpty() } - .sortedBy { it.name } + .sortedBy { it.name }, ) } @@ -480,7 +478,7 @@ internal fun ManagementInterface.RelayListCity.toDomain( relaysList .filter { it.endpointType == ManagementInterface.Relay.RelayType.WIREGUARD } .map { it.toDomain(cityCode) } - .sortedWith(RelayNameComparator) + .sortedWith(RelayNameComparator), ) } @@ -493,8 +491,8 @@ internal fun ManagementInterface.Relay.toDomain( provider = Provider( ProviderId(provider), - ownership = if (owned) Ownership.MullvadOwned else Ownership.Rented - ) + ownership = if (owned) Ownership.MullvadOwned else Ownership.Rented, + ), ) internal fun ManagementInterface.Device.toDomain(): Device = @@ -514,19 +512,19 @@ internal fun ManagementInterface.DeviceState.toDomain(): DeviceState = internal fun ManagementInterface.AccountData.toDomain(): AccountData = AccountData( AccountId(UUID.fromString(id)), - expiryDate = Instant.ofEpochSecond(expiry.seconds).toDateTime() + expiryDate = Instant.ofEpochSecond(expiry.seconds).toDateTime(), ) internal fun ManagementInterface.VoucherSubmission.toDomain(): RedeemVoucherSuccess = RedeemVoucherSuccess( timeAdded = secondsAdded, - newExpiryDate = Instant.ofEpochSecond(newExpiry.seconds).toDateTime() + newExpiryDate = Instant.ofEpochSecond(newExpiry.seconds).toDateTime(), ) internal fun ManagementInterface.SplitTunnelSettings.toDomain(): SplitTunnelSettings = SplitTunnelSettings( enabled = enableExclusions, - excludedApps = appsList.map { AppId(it) }.toSet() + excludedApps = appsList.map { AppId(it) }.toSet(), ) internal fun ManagementInterface.PlayPurchasePaymentToken.toDomain(): PlayPurchasePaymentToken = @@ -540,7 +538,7 @@ internal fun ManagementInterface.AccessMethodSetting.toDomain(): ApiAccessMethod id = ApiAccessMethodId.fromString(id.value), name = ApiAccessMethodName.fromString(name), enabled = enabled, - apiAccessMethod = accessMethod.toDomain() + apiAccessMethod = accessMethod.toDomain(), ) internal fun ManagementInterface.AccessMethod.toDomain(): ApiAccessMethod = @@ -564,7 +562,7 @@ internal fun ManagementInterface.Shadowsocks.toDomain(): ApiAccessMethod.CustomP ip = ip, port = Port(port), password = password, - cipher = Cipher.fromString(cipher) + cipher = Cipher.fromString(cipher), ) internal fun ManagementInterface.Socks5Remote.toDomain(): ApiAccessMethod.CustomProxy.Socks5Remote = @@ -576,7 +574,7 @@ internal fun ManagementInterface.Socks5Remote.toDomain(): ApiAccessMethod.Custom auth.toDomain() } else { null - } + }, ) internal fun ManagementInterface.SocksAuth.toDomain(): SocksAuth = diff --git a/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/util/LogInterceptor.kt b/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/util/LogInterceptor.kt index b01b0266b7..1bff85300f 100644 --- a/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/util/LogInterceptor.kt +++ b/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/util/LogInterceptor.kt @@ -11,7 +11,7 @@ internal class LogInterceptor : ClientInterceptor { override fun <ReqT : Any?, RespT : Any?> interceptCall( method: MethodDescriptor<ReqT, RespT>?, callOptions: CallOptions?, - next: Channel? + next: Channel?, ): ClientCall<ReqT, RespT> { Logger.v("Intercepted call: ${method?.fullMethodName}") return next!!.newCall(method, callOptions) diff --git a/android/lib/daemon-grpc/src/test/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/RelayNameComparatorTest.kt b/android/lib/daemon-grpc/src/test/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/RelayNameComparatorTest.kt index 42cf745510..1494851bcb 100644 --- a/android/lib/daemon-grpc/src/test/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/RelayNameComparatorTest.kt +++ b/android/lib/daemon-grpc/src/test/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/RelayNameComparatorTest.kt @@ -27,7 +27,7 @@ class RelayNameComparatorTest { provider = Provider( providerId = ProviderId("Provider"), - ownership = Ownership.MullvadOwned + ownership = Ownership.MullvadOwned, ), ) val relay10 = @@ -37,8 +37,8 @@ class RelayNameComparatorTest { provider = Provider( providerId = ProviderId("Provider"), - ownership = Ownership.MullvadOwned - ) + ownership = Ownership.MullvadOwned, + ), ) relay9 assertOrderBothDirection relay10 @@ -53,8 +53,8 @@ class RelayNameComparatorTest { provider = Provider( providerId = ProviderId("Provider"), - ownership = Ownership.MullvadOwned - ) + ownership = Ownership.MullvadOwned, + ), ) val relay9b = RelayItem.Location.Relay( @@ -63,8 +63,8 @@ class RelayNameComparatorTest { provider = Provider( providerId = ProviderId("Provider"), - ownership = Ownership.MullvadOwned - ) + ownership = Ownership.MullvadOwned, + ), ) assertTrue(RelayNameComparator.compare(relay9a, relay9b) == 0) @@ -80,8 +80,8 @@ class RelayNameComparatorTest { provider = Provider( providerId = ProviderId("Provider"), - ownership = Ownership.MullvadOwned - ) + ownership = Ownership.MullvadOwned, + ), ) val relay1 = RelayItem.Location.Relay( @@ -90,8 +90,8 @@ class RelayNameComparatorTest { provider = Provider( providerId = ProviderId("Provider"), - ownership = Ownership.MullvadOwned - ) + ownership = Ownership.MullvadOwned, + ), ) val relay3 = RelayItem.Location.Relay( @@ -100,8 +100,8 @@ class RelayNameComparatorTest { provider = Provider( providerId = ProviderId("Provider"), - ownership = Ownership.MullvadOwned - ) + ownership = Ownership.MullvadOwned, + ), ) val relay100 = RelayItem.Location.Relay( @@ -110,8 +110,8 @@ class RelayNameComparatorTest { provider = Provider( providerId = ProviderId("Provider"), - ownership = Ownership.MullvadOwned - ) + ownership = Ownership.MullvadOwned, + ), ) relay001 assertOrderBothDirection relay1 @@ -129,8 +129,8 @@ class RelayNameComparatorTest { provider = Provider( providerId = ProviderId("Provider"), - ownership = Ownership.MullvadOwned - ) + ownership = Ownership.MullvadOwned, + ), ) val relay9b = RelayItem.Location.Relay( @@ -139,8 +139,8 @@ class RelayNameComparatorTest { provider = Provider( providerId = ProviderId("Provider"), - ownership = Ownership.MullvadOwned - ) + ownership = Ownership.MullvadOwned, + ), ) assertTrue(RelayNameComparator.compare(relay9a, relay9b) == 0) @@ -156,8 +156,8 @@ class RelayNameComparatorTest { provider = Provider( providerId = ProviderId("Provider"), - ownership = Ownership.MullvadOwned - ) + ownership = Ownership.MullvadOwned, + ), ) val relay005 = RelayItem.Location.Relay( @@ -166,8 +166,8 @@ class RelayNameComparatorTest { provider = Provider( providerId = ProviderId("Provider"), - ownership = Ownership.MullvadOwned - ) + ownership = Ownership.MullvadOwned, + ), ) relay001 assertOrderBothDirection relay005 @@ -182,8 +182,8 @@ class RelayNameComparatorTest { provider = Provider( providerId = ProviderId("Provider"), - ownership = Ownership.MullvadOwned - ) + ownership = Ownership.MullvadOwned, + ), ) val relayAr8 = RelayItem.Location.Relay( @@ -192,8 +192,8 @@ class RelayNameComparatorTest { provider = Provider( providerId = ProviderId("Provider"), - ownership = Ownership.MullvadOwned - ) + ownership = Ownership.MullvadOwned, + ), ) val relaySe5 = RelayItem.Location.Relay( @@ -202,8 +202,8 @@ class RelayNameComparatorTest { provider = Provider( providerId = ProviderId("Provider"), - ownership = Ownership.MullvadOwned - ) + ownership = Ownership.MullvadOwned, + ), ) val relaySe10 = RelayItem.Location.Relay( @@ -212,8 +212,8 @@ class RelayNameComparatorTest { provider = Provider( providerId = ProviderId("Provider"), - ownership = Ownership.MullvadOwned - ) + ownership = Ownership.MullvadOwned, + ), ) relayAr2 assertOrderBothDirection relayAr8 @@ -230,8 +230,8 @@ class RelayNameComparatorTest { provider = Provider( providerId = ProviderId("Provider"), - ownership = Ownership.MullvadOwned - ) + ownership = Ownership.MullvadOwned, + ), ) val relay2w = RelayItem.Location.Relay( @@ -240,8 +240,8 @@ class RelayNameComparatorTest { provider = Provider( providerId = ProviderId("Provider"), - ownership = Ownership.MullvadOwned - ) + ownership = Ownership.MullvadOwned, + ), ) relay2c assertOrderBothDirection relay2w @@ -256,8 +256,8 @@ class RelayNameComparatorTest { provider = Provider( providerId = ProviderId("Provider"), - ownership = Ownership.MullvadOwned - ) + ownership = Ownership.MullvadOwned, + ), ) val relay22b = RelayItem.Location.Relay( @@ -266,8 +266,8 @@ class RelayNameComparatorTest { provider = Provider( providerId = ProviderId("Provider"), - ownership = Ownership.MullvadOwned - ) + ownership = Ownership.MullvadOwned, + ), ) relay22a assertOrderBothDirection relay22b |
