summaryrefslogtreecommitdiffhomepage
path: root/android/lib/talpid
diff options
context:
space:
mode:
authorDavid Göransson <david.goransson@mullvad.net>2024-09-06 07:56:31 +0200
committerDavid Göransson <david.goransson@mullvad.net>2024-09-06 16:01:53 +0200
commit4c711955d02ef6847dd3c8a5906657698c8a9ce9 (patch)
tree132784af66b606a0e65a66482c5de7d8e851c7cb /android/lib/talpid
parent3c486de4c8ffce5803e82fc8f47d2b468ad8d4d0 (diff)
downloadmullvadvpn-4c711955d02ef6847dd3c8a5906657698c8a9ce9.tar.xz
mullvadvpn-4c711955d02ef6847dd3c8a5906657698c8a9ce9.zip
Handle Exception when tunnel fails to establish
Diffstat (limited to 'android/lib/talpid')
-rw-r--r--android/lib/talpid/src/main/kotlin/net/mullvad/talpid/TalpidVpnService.kt17
1 files changed, 14 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 eabb8c49fd..cf8a775e13 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
@@ -117,13 +117,24 @@ open class TalpidVpnService : LifecycleVpnService() {
setMeteredIfSupported(false)
}
- val vpnInterface = builder.establish()
- val tunFd = vpnInterface?.detachFd()
+ val vpnInterfaceFd =
+ try {
+ builder.establish()
+ } catch (e: IllegalStateException) {
+ Logger.e("Failed to establish, a parameter could not be applied", e)
+ return CreateTunResult.TunnelDeviceError
+ } catch (e: IllegalArgumentException) {
+ Logger.e("Failed to establish a parameter was not accepted", e)
+ return CreateTunResult.TunnelDeviceError
+ }
- if (tunFd == null) {
+ if (vpnInterfaceFd == null) {
+ Logger.e("VpnInterface returned null")
return CreateTunResult.TunnelDeviceError
}
+ val tunFd = vpnInterfaceFd.detachFd()
+
waitForTunnelUp(tunFd, config.routes.any { route -> route.isIpv6 })
if (invalidDnsServerAddresses.isNotEmpty()) {