aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt')
-rw-r--r--app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt14
1 files changed, 7 insertions, 7 deletions
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 366e208..31541b3 100644
--- a/app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt
+++ b/app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt
@@ -15,17 +15,17 @@ import java.io.IOException
15 */ 15 */
16class TincVpnService : VpnService() { 16class TincVpnService : VpnService() {
17 17
18 private var netConf: AppPaths.NetConf? = null 18 private var netName: String? = null
19 19
20 override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int { 20 override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
21 netConf = intent.getSerializableExtra(INTENT_EXTRA_NET_CONF)!! as AppPaths.NetConf 21 netName = intent.getStringExtra(INTENT_EXTRA_NET_NAME)!!
22 22
23 val net = Builder().setSession(netConf!!.netName) 23 val net = Builder().setSession(netName)
24 net.apply(VpnInterfaceConfiguration(AppPaths.netConfFile(netConf!!))) 24 net.apply(VpnInterfaceConfiguration(AppPaths.netConfFile(netName!!)))
25 applyIgnoringException(net::addDisallowedApplication, BuildConfig.APPLICATION_ID) 25 applyIgnoringException(net::addDisallowedApplication, BuildConfig.APPLICATION_ID)
26 26
27 try { 27 try {
28 Tincd.start(netConf!!, net.establish().detachFd()) 28 Tincd.start(netName!!, net.establish().detachFd())
29 } catch (e: IOException) { 29 } catch (e: IOException) {
30 e.printStackTrace() 30 e.printStackTrace()
31 } 31 }
@@ -35,7 +35,7 @@ class TincVpnService : VpnService() {
35 35
36 override fun onDestroy() { 36 override fun onDestroy() {
37 try { 37 try {
38 Tinc.stop(netConf!!) 38 Tinc.stop(netName!!)
39 } catch (e: IOException) { 39 } catch (e: IOException) {
40 e.printStackTrace() 40 e.printStackTrace()
41 } 41 }
@@ -43,7 +43,7 @@ class TincVpnService : VpnService() {
43 } 43 }
44 44
45 companion object { 45 companion object {
46 val INTENT_EXTRA_NET_CONF = "netConf" 46 val INTENT_EXTRA_NET_NAME = "netName"
47 } 47 }
48 48
49} 49}