Skip to content

Commit

Permalink
Fix remark
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawa committed Jan 16, 2025
1 parent 15fcb35 commit 451ddb0
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<InetAddress, VpnService.Builder> =
Either.catch { addDnsServer(dnsServer) }
.mapLeft {
when (it) {
Expand Down

0 comments on commit 451ddb0

Please sign in to comment.