summaryrefslogtreecommitdiffhomepage
path: root/android
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-07-16 13:41:14 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-07-20 14:01:46 +0000
commita97cb333d126125949beaae7ab776a1d69bc1e1e (patch)
tree71c1774287c768696cf3b09cf872ae8e3d561867 /android
parent59f5490318aa1a1206c82d888cf9729d467c9a4f (diff)
downloadmullvadvpn-a97cb333d126125949beaae7ab776a1d69bc1e1e.tar.xz
mullvadvpn-a97cb333d126125949beaae7ab776a1d69bc1e1e.zip
Allow forcing tunnel to be recreated
Diffstat (limited to 'android')
-rw-r--r--android/src/main/kotlin/net/mullvad/talpid/TalpidVpnService.kt10
1 files changed, 9 insertions, 1 deletions
diff --git a/android/src/main/kotlin/net/mullvad/talpid/TalpidVpnService.kt b/android/src/main/kotlin/net/mullvad/talpid/TalpidVpnService.kt
index 2e391f5cb7..3ad9809928 100644
--- a/android/src/main/kotlin/net/mullvad/talpid/TalpidVpnService.kt
+++ b/android/src/main/kotlin/net/mullvad/talpid/TalpidVpnService.kt
@@ -16,6 +16,7 @@ open class TalpidVpnService : VpnService() {
}
private var currentTunConfig = defaultTunConfig()
+ private var tunIsStale = false
protected var disallowedApps: List<String>? = null
@@ -33,13 +34,14 @@ open class TalpidVpnService : VpnService() {
synchronized(this) {
val tunDevice = activeTunDevice
- if (config == currentTunConfig && tunDevice != null) {
+ if (config == currentTunConfig && tunDevice != null && !tunIsStale) {
return tunDevice
} else {
val newTunDevice = createTun(config)
currentTunConfig = config
activeTunDevice = newTunDevice
+ tunIsStale = false
return newTunDevice
}
@@ -75,6 +77,12 @@ open class TalpidVpnService : VpnService() {
}
}
+ fun markTunAsStale() {
+ synchronized(this) {
+ tunIsStale = true
+ }
+ }
+
private fun createTun(config: TunConfig): Int {
if (VpnService.prepare(this) != null) {
// VPN permission wasn't granted