summaryrefslogtreecommitdiffhomepage
path: root/android
diff options
context:
space:
mode:
authorCubxity <contact@cubxity.dev>2022-10-19 18:27:58 +0200
committerJonatan Rhodin <jonatan.rhodin@mullvad.net>2023-05-09 16:18:13 +0200
commit411fbd4a5470e95ca0048d5ac959350190c199e8 (patch)
treef0765756110779cc78aa4370c02ed644b57966cc /android
parenta3299ad74fcd58f9c4b435ea57cf2c7350f1dd9f (diff)
downloadmullvadvpn-411fbd4a5470e95ca0048d5ac959350190c199e8.tar.xz
mullvadvpn-411fbd4a5470e95ca0048d5ac959350190c199e8.zip
Propagate udp2tcp settings between app and daemon
Co-authored-by: Albin <albin@mullvad.net> Co-authored-by: David Lönnhager <david.l@mullvad.net> Co-authored-by: Odd Stranne <odd@mullvad.net>
Diffstat (limited to 'android')
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/ipc/Request.kt3
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/model/ObfuscationSettings.kt10
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/model/SelectedObfuscation.kt11
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/model/Settings.kt1
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/model/Udp2TcpObfuscationSettings.kt9
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadDaemon.kt10
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/SettingsListener.kt17
-rw-r--r--android/app/src/main/kotlin/net/mullvad/talpid/net/ObfuscationEndpoint.kt8
-rw-r--r--android/app/src/main/kotlin/net/mullvad/talpid/net/ObfuscationType.kt9
-rw-r--r--android/app/src/main/kotlin/net/mullvad/talpid/net/TunnelEndpoint.kt6
10 files changed, 80 insertions, 4 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 56900e4440..189dc27087 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
@@ -6,6 +6,7 @@ import java.net.InetAddress
import kotlinx.parcelize.Parcelize
import net.mullvad.mullvadvpn.model.DnsOptions
import net.mullvad.mullvadvpn.model.LocationConstraint
+import net.mullvad.mullvadvpn.model.ObfuscationSettings
// Requests that the service can handle
sealed class Request : Message.RequestMessage() {
@@ -82,6 +83,8 @@ sealed class Request : Message.RequestMessage() {
@Parcelize data class SetDnsOptions(val dnsOptions: DnsOptions) : Request()
+ @Parcelize data class SetObfuscationSettings(val settings: ObfuscationSettings) : Request()
+
companion object {
private const val MESSAGE_KEY = "request"
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/model/ObfuscationSettings.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/model/ObfuscationSettings.kt
new file mode 100644
index 0000000000..19b5c0e5f2
--- /dev/null
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/model/ObfuscationSettings.kt
@@ -0,0 +1,10 @@
+package net.mullvad.mullvadvpn.model
+
+import android.os.Parcelable
+import kotlinx.parcelize.Parcelize
+
+@Parcelize
+data class ObfuscationSettings(
+ val selectedObfuscation: SelectedObfuscation,
+ val udp2tcp: Udp2TcpObfuscationSettings
+) : Parcelable
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/model/SelectedObfuscation.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/model/SelectedObfuscation.kt
new file mode 100644
index 0000000000..8124bcc6a6
--- /dev/null
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/model/SelectedObfuscation.kt
@@ -0,0 +1,11 @@
+package net.mullvad.mullvadvpn.model
+
+import android.os.Parcelable
+import kotlinx.parcelize.Parcelize
+
+@Parcelize
+enum class SelectedObfuscation : Parcelable {
+ Auto,
+ Off,
+ Udp2Tcp
+}
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/model/Settings.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/model/Settings.kt
index 2fcae9f4ea..0d45b38179 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/model/Settings.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/model/Settings.kt
@@ -6,6 +6,7 @@ import kotlinx.parcelize.Parcelize
@Parcelize
data class Settings(
val relaySettings: RelaySettings,
+ val obfuscationSettings: ObfuscationSettings,
val allowLan: Boolean,
val autoConnect: Boolean,
val tunnelOptions: TunnelOptions,
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/model/Udp2TcpObfuscationSettings.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/model/Udp2TcpObfuscationSettings.kt
new file mode 100644
index 0000000000..49f466a147
--- /dev/null
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/model/Udp2TcpObfuscationSettings.kt
@@ -0,0 +1,9 @@
+package net.mullvad.mullvadvpn.model
+
+import android.os.Parcelable
+import kotlinx.parcelize.Parcelize
+
+@Parcelize
+data class Udp2TcpObfuscationSettings(
+ val port: Constraint<Int>
+) : Parcelable
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadDaemon.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadDaemon.kt
index 6d82ee617c..86291f8c30 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadDaemon.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadDaemon.kt
@@ -13,6 +13,7 @@ import net.mullvad.mullvadvpn.model.DnsOptions
import net.mullvad.mullvadvpn.model.GeoIpLocation
import net.mullvad.mullvadvpn.model.GetAccountDataResult
import net.mullvad.mullvadvpn.model.LoginResult
+import net.mullvad.mullvadvpn.model.ObfuscationSettings
import net.mullvad.mullvadvpn.model.RelayList
import net.mullvad.mullvadvpn.model.RelaySettingsUpdate
import net.mullvad.mullvadvpn.model.RemoveDeviceEvent
@@ -173,6 +174,10 @@ class MullvadDaemon(
updateRelaySettings(daemonInterfaceAddress, update)
}
+ fun setObfuscationSettings(settings: ObfuscationSettings) {
+ setObfuscationSettings(daemonInterfaceAddress, settings)
+ }
+
fun onDestroy() {
onSettingsChange.unsubscribeAll()
onTunnelStateChange.unsubscribeAll()
@@ -245,6 +250,11 @@ class MullvadDaemon(
update: RelaySettingsUpdate
)
+ private external fun setObfuscationSettings(
+ daemonInterfaceAddress: Long,
+ settings: ObfuscationSettings
+ )
+
private fun notifyAppVersionInfoEvent(appVersionInfo: AppVersionInfo) {
onAppVersionInfoChange?.invoke(appVersionInfo)
}
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/SettingsListener.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/SettingsListener.kt
index 772e3127b9..2e688cda56 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/SettingsListener.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/SettingsListener.kt
@@ -8,9 +8,7 @@ import kotlinx.coroutines.channels.actor
import kotlinx.coroutines.channels.trySendBlocking
import net.mullvad.mullvadvpn.ipc.Event
import net.mullvad.mullvadvpn.ipc.Request
-import net.mullvad.mullvadvpn.model.DnsOptions
-import net.mullvad.mullvadvpn.model.RelaySettings
-import net.mullvad.mullvadvpn.model.Settings
+import net.mullvad.mullvadvpn.model.*
import net.mullvad.mullvadvpn.service.MullvadDaemon
import net.mullvad.talpid.util.EventNotifier
@@ -19,6 +17,7 @@ class SettingsListener(endpoint: ServiceEndpoint) {
class SetAllowLan(val allow: Boolean) : Command()
class SetAutoConnect(val autoConnect: Boolean) : Command()
class SetWireGuardMtu(val mtu: Int?) : Command()
+ class SetObfuscationSettings(val settings: ObfuscationSettings) : Command()
}
private val commandChannel = spawnActor()
@@ -26,6 +25,7 @@ class SettingsListener(endpoint: ServiceEndpoint) {
val dnsOptionsNotifier = EventNotifier<DnsOptions?>(null)
val relaySettingsNotifier = EventNotifier<RelaySettings?>(null)
+ val obfuscationSettingsNotifier = EventNotifier<ObfuscationSettings?>(null)
val settingsNotifier = EventNotifier<Settings?>(null)
var settings by settingsNotifier.notifiable()
@@ -55,6 +55,10 @@ class SettingsListener(endpoint: ServiceEndpoint) {
registerHandler(Request.SetWireGuardMtu::class) { request ->
commandChannel.trySendBlocking(Command.SetWireGuardMtu(request.mtu))
}
+
+ registerHandler(Request.SetObfuscationSettings::class) { request ->
+ commandChannel.trySendBlocking(Command.SetObfuscationSettings(request.settings))
+ }
}
}
@@ -64,6 +68,7 @@ class SettingsListener(endpoint: ServiceEndpoint) {
dnsOptionsNotifier.unsubscribeAll()
relaySettingsNotifier.unsubscribeAll()
+ obfuscationSettingsNotifier.unsubscribeAll()
settingsNotifier.unsubscribeAll()
}
@@ -96,6 +101,10 @@ class SettingsListener(endpoint: ServiceEndpoint) {
relaySettingsNotifier.notify(newSettings.relaySettings)
}
+ if (settings?.obfuscationSettings != newSettings.obfuscationSettings) {
+ obfuscationSettingsNotifier.notify(newSettings.obfuscationSettings)
+ }
+
settings = newSettings
}
}
@@ -110,6 +119,8 @@ class SettingsListener(endpoint: ServiceEndpoint) {
is Command.SetAutoConnect ->
daemon.await().setAutoConnect(command.autoConnect)
is Command.SetWireGuardMtu -> daemon.await().setWireguardMtu(command.mtu)
+ is Command.SetObfuscationSettings ->
+ daemon.await().setObfuscationSettings(command.settings)
}
}
} catch (exception: ClosedReceiveChannelException) {
diff --git a/android/app/src/main/kotlin/net/mullvad/talpid/net/ObfuscationEndpoint.kt b/android/app/src/main/kotlin/net/mullvad/talpid/net/ObfuscationEndpoint.kt
new file mode 100644
index 0000000000..9ec96b1494
--- /dev/null
+++ b/android/app/src/main/kotlin/net/mullvad/talpid/net/ObfuscationEndpoint.kt
@@ -0,0 +1,8 @@
+package net.mullvad.talpid.net
+
+import android.os.Parcelable
+import kotlinx.parcelize.Parcelize
+
+@Parcelize
+data class ObfuscationEndpoint(val endpoint: Endpoint, val obfuscationType: ObfuscationType) :
+ Parcelable
diff --git a/android/app/src/main/kotlin/net/mullvad/talpid/net/ObfuscationType.kt b/android/app/src/main/kotlin/net/mullvad/talpid/net/ObfuscationType.kt
new file mode 100644
index 0000000000..72409d9026
--- /dev/null
+++ b/android/app/src/main/kotlin/net/mullvad/talpid/net/ObfuscationType.kt
@@ -0,0 +1,9 @@
+package net.mullvad.talpid.net
+
+import android.os.Parcelable
+import kotlinx.parcelize.Parcelize
+
+@Parcelize
+enum class ObfuscationType : Parcelable {
+ Udp2Tcp
+}
diff --git a/android/app/src/main/kotlin/net/mullvad/talpid/net/TunnelEndpoint.kt b/android/app/src/main/kotlin/net/mullvad/talpid/net/TunnelEndpoint.kt
index 7bb9eb2530..9c45833eb2 100644
--- a/android/app/src/main/kotlin/net/mullvad/talpid/net/TunnelEndpoint.kt
+++ b/android/app/src/main/kotlin/net/mullvad/talpid/net/TunnelEndpoint.kt
@@ -4,4 +4,8 @@ import android.os.Parcelable
import kotlinx.parcelize.Parcelize
@Parcelize
-data class TunnelEndpoint(val endpoint: Endpoint, val quantumResistant: Boolean) : Parcelable
+data class TunnelEndpoint(
+ val endpoint: Endpoint,
+ val quantumResistant: Boolean,
+ val obfuscation: ObfuscationEndpoint?
+) : Parcelable