diff options
| author | Albin <albin@mullvad.net> | 2023-02-07 12:14:05 +0100 |
|---|---|---|
| committer | Albin <albin@mullvad.net> | 2023-02-08 10:52:45 +0100 |
| commit | 2a7515a1c4957a726d7923b93b5dd633acaa858d (patch) | |
| tree | a9deb49cc2cbda70757171c3d94112cd22fb7dc8 /android | |
| parent | 490570a2a382e18b1999cd01811860a727ddae69 (diff) | |
| download | mullvadvpn-2a7515a1c4957a726d7923b93b5dd633acaa858d.tar.xz mullvadvpn-2a7515a1c4957a726d7923b93b5dd633acaa858d.zip | |
Add IPC option to set DnsOptions
This makes it possible to submit the DnsOptions as a whole rather
than separate actions add/remove/replace.
Diffstat (limited to 'android')
| -rw-r--r-- | android/app/src/main/kotlin/net/mullvad/mullvadvpn/ipc/Request.kt | 4 | ||||
| -rw-r--r-- | android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/CustomDns.kt | 11 |
2 files changed, 15 insertions, 0 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ipc/Request.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ipc/Request.kt index 9584aee506..6c7745da9a 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ipc/Request.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ipc/Request.kt @@ -4,6 +4,7 @@ import android.os.Message as RawMessage import android.os.Messenger import java.net.InetAddress import kotlinx.parcelize.Parcelize +import net.mullvad.mullvadvpn.model.DnsOptions import net.mullvad.mullvadvpn.model.LocationConstraint // Requests that the service can handle @@ -103,6 +104,9 @@ sealed class Request : Message.RequestMessage() { @Parcelize data class VpnPermissionResponse(val isGranted: Boolean) : Request() + @Parcelize + data class SetDnsOptions(val dnsOptions: DnsOptions) : Request() + companion object { private const val MESSAGE_KEY = "request" diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/CustomDns.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/CustomDns.kt index b2ae560450..81a0d8e7aa 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/CustomDns.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/CustomDns.kt @@ -19,6 +19,8 @@ class CustomDns(private val endpoint: ServiceEndpoint) { class RemoveDnsServer(val server: InetAddress) : Command() class ReplaceDnsServer(val oldServer: InetAddress, val newServer: InetAddress) : Command() class SetEnabled(val enabled: Boolean) : Command() + + class SetDnsOptions(val dnsOptions: DnsOptions) : Command() } private val commandChannel = spawnActor() @@ -56,6 +58,10 @@ class CustomDns(private val endpoint: ServiceEndpoint) { registerHandler(Request.SetEnableCustomDns::class) { request -> commandChannel.trySendBlocking(Command.SetEnabled(request.enable)) } + + registerHandler(Request.SetDnsOptions::class) { request -> + commandChannel.trySendBlocking(Command.SetDnsOptions(request.dnsOptions)) + } } } @@ -76,6 +82,7 @@ class CustomDns(private val endpoint: ServiceEndpoint) { doReplaceDnsServer(command.oldServer, command.newServer) } is Command.SetEnabled -> changeDnsOptions(command.enabled) + is Command.SetDnsOptions -> setDnsOptions(command.dnsOptions) } } } catch (exception: ClosedReceiveChannelException) { @@ -116,4 +123,8 @@ class CustomDns(private val endpoint: ServiceEndpoint) { ) daemon.await().setDnsOptions(options) } + + private suspend fun setDnsOptions(dnsOptions: DnsOptions) { + daemon.await().setDnsOptions(dnsOptions) + } } |
