aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/org/pacien
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/org/pacien')
-rw-r--r--app/src/main/java/org/pacien/tincapp/data/VpnInterfaceConfiguration.kt9
-rw-r--r--app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt3
2 files changed, 8 insertions, 4 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/data/VpnInterfaceConfiguration.kt b/app/src/main/java/org/pacien/tincapp/data/VpnInterfaceConfiguration.kt
index 26a194c..c98b567 100644
--- a/app/src/main/java/org/pacien/tincapp/data/VpnInterfaceConfiguration.kt
+++ b/app/src/main/java/org/pacien/tincapp/data/VpnInterfaceConfiguration.kt
@@ -1,6 +1,6 @@
1/* 1/*
2 * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon 2 * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon
3 * Copyright (C) 2017-2018 Pacien TRAN-GIRARD 3 * Copyright (C) 2017-2019 Pacien TRAN-GIRARD
4 * 4 *
5 * This program is free software: you can redistribute it and/or modify 5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -42,7 +42,8 @@ data class VpnInterfaceConfiguration(val addresses: List<CidrAddress> = emptyLis
42 val allowedFamilies: List<Int> = emptyList(), 42 val allowedFamilies: List<Int> = emptyList(),
43 val allowBypass: Boolean = false, 43 val allowBypass: Boolean = false,
44 val blocking: Boolean = false, 44 val blocking: Boolean = false,
45 val mtu: Int? = null) { 45 val mtu: Int? = null,
46 val reconnectOnNetworkChange: Boolean = true) {
46 companion object { 47 companion object {
47 private const val KEY_ADDRESSES = "Address" 48 private const val KEY_ADDRESSES = "Address"
48 private const val KEY_ROUTES = "Route" 49 private const val KEY_ROUTES = "Route"
@@ -54,6 +55,7 @@ data class VpnInterfaceConfiguration(val addresses: List<CidrAddress> = emptyLis
54 private const val KEY_ALLOW_BYPASS = "AllowBypass" 55 private const val KEY_ALLOW_BYPASS = "AllowBypass"
55 private const val KEY_BLOCKING = "Blocking" 56 private const val KEY_BLOCKING = "Blocking"
56 private const val KEY_MTU = "MTU" 57 private const val KEY_MTU = "MTU"
58 private const val KEY_RECONNECT_ON_NETWORK_CHANGE = "ReconnectOnNetworkChange"
57 59
58 private const val INVITATION_KEY_ADDRESSES = "Ifconfig" 60 private const val INVITATION_KEY_ADDRESSES = "Ifconfig"
59 private const val INVITATION_KEY_ROUTES = "Route" 61 private const val INVITATION_KEY_ROUTES = "Route"
@@ -69,7 +71,8 @@ data class VpnInterfaceConfiguration(val addresses: List<CidrAddress> = emptyLis
69 c.getIntList(KEY_ALLOWED_FAMILIES), 71 c.getIntList(KEY_ALLOWED_FAMILIES),
70 c.getBoolean(KEY_ALLOW_BYPASS, false), 72 c.getBoolean(KEY_ALLOW_BYPASS, false),
71 c.getBoolean(KEY_BLOCKING, false), 73 c.getBoolean(KEY_BLOCKING, false),
72 c.getInteger(KEY_MTU, null)) 74 c.getInteger(KEY_MTU, null),
75 c.getBoolean(KEY_RECONNECT_ON_NETWORK_CHANGE, true))
73 76
74 fun fromInvitation(f: File) = fromInvitation(Configurations().properties(f)) 77 fun fromInvitation(f: File) = fromInvitation(Configurations().properties(f))
75 private fun fromInvitation(c: Configuration) = VpnInterfaceConfiguration( 78 private fun fromInvitation(c: Configuration) = VpnInterfaceConfiguration(
diff --git a/app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt b/app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt
index be5b11d..18388f6 100644
--- a/app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt
+++ b/app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt
@@ -152,7 +152,8 @@ class TincVpnService : VpnService() {
152 broadcastEvent(Actions.EVENT_CONNECTED) 152 broadcastEvent(Actions.EVENT_CONNECTED)
153 } 153 }
154 154
155 connectivityChangeReceiver.registerWatcher(this) 155 if (interfaceCfg.reconnectOnNetworkChange)
156 connectivityChangeReceiver.registerWatcher(this)
156 } 157 }
157 } 158 }
158 159