From 2f2700ef0194fda7be3bb8140e680c6099fec1a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20G=C3=B6ransson?= Date: Thu, 16 Jan 2025 10:48:59 +0100 Subject: [PATCH] Fix remark --- .../main/kotlin/net/mullvad/talpid/TalpidVpnService.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/android/lib/talpid/src/main/kotlin/net/mullvad/talpid/TalpidVpnService.kt b/android/lib/talpid/src/main/kotlin/net/mullvad/talpid/TalpidVpnService.kt index 87499f08e15a..50c6897c27ff 100644 --- a/android/lib/talpid/src/main/kotlin/net/mullvad/talpid/TalpidVpnService.kt +++ b/android/lib/talpid/src/main/kotlin/net/mullvad/talpid/TalpidVpnService.kt @@ -2,6 +2,7 @@ package net.mullvad.talpid import android.net.ConnectivityManager import android.net.LinkProperties +import android.net.VpnService import android.os.ParcelFileDescriptor import androidx.annotation.CallSuper import androidx.core.content.getSystemService @@ -18,7 +19,6 @@ import java.net.InetAddress import kotlin.properties.Delegates.observable import kotlin.time.Duration import kotlin.time.Duration.Companion.milliseconds -import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.map import kotlinx.coroutines.runBlocking @@ -113,7 +113,7 @@ open class TalpidVpnService : LifecycleVpnService() { // then notify daemon to later enter blocked state. val dnsConfigureResult = config.dnsServers - .mapOrAccumulate { builder.addDnsServerE(it).bind() } + .mapOrAccumulate { builder.addDnsServerSafe(it).bind() } .map { /* Ignore right */ } .onLeft { // Avoid creating a tunnel with no DNS servers or if all DNS servers was @@ -154,7 +154,9 @@ open class TalpidVpnService : LifecycleVpnService() { is PrepareError.OtherAlwaysOnApp -> OtherAlwaysOnApp(appName) } - private fun Builder.addDnsServerE(dnsServer: InetAddress) = + private fun Builder.addDnsServerSafe( + dnsServer: InetAddress + ): Either = Either.catch { addDnsServer(dnsServer) } .mapLeft { when (it) {