aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorpacien2023-01-09 00:01:03 +0100
committerpacien2023-01-09 00:22:49 +0100
commit136f395ed1bdecdd633432dc08cc53d96825fa36 (patch)
treebdf99a13cb4163629d2f684455df0b047dce9e08 /app
parent7aafc91bc8a2e9e1cf84204c9aa2b0437748c1c3 (diff)
downloadtincapp-136f395ed1bdecdd633432dc08cc53d96825fa36.tar.gz
net: inherit metered property from underlying network
Since API 29, all VPN connections were treated as metered by default. This is not relevant for tinc networks, so it's preferable to simply inherit that property from the underlying link. GitHub: closes #114
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt5
1 files changed, 4 insertions, 1 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 ac68c9f..af5966e 100644
--- a/app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt
+++ b/app/src/main/java/org/pacien/tincapp/service/TincVpnService.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-2020 Pacien TRAN-GIRARD 3 * Copyright (C) 2017-2023 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
@@ -23,6 +23,7 @@ import android.content.Context
23import android.content.Intent 23import android.content.Intent
24import android.net.LocalServerSocket 24import android.net.LocalServerSocket
25import android.net.VpnService 25import android.net.VpnService
26import android.os.Build
26import android.os.ParcelFileDescriptor 27import android.os.ParcelFileDescriptor
27import androidx.localbroadcastmanager.content.LocalBroadcastManager 28import androidx.localbroadcastmanager.content.LocalBroadcastManager
28import java8.util.concurrent.CompletableFuture 29import java8.util.concurrent.CompletableFuture
@@ -133,6 +134,8 @@ class TincVpnService : VpnService() {
133 Builder().setSession(netName) 134 Builder().setSession(netName)
134 .applyCfg(interfaceCfg) 135 .applyCfg(interfaceCfg)
135 .also { applyIgnoringException(it::addDisallowedApplication, BuildConfig.APPLICATION_ID) } 136 .also { applyIgnoringException(it::addDisallowedApplication, BuildConfig.APPLICATION_ID) }
137 // inherit metered property from underlying network
138 .also { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) it.setMetered(false) }
136 .establish()!! 139 .establish()!!
137 } catch (e: IllegalArgumentException) { 140 } catch (e: IllegalArgumentException) {
138 return reportError(resources.getString(R.string.notification_error_message_network_config_invalid_format, e.defaultMessage()), e, "network-interface") 141 return reportError(resources.getString(R.string.notification_error_message_network_config_invalid_format, e.defaultMessage()), e, "network-interface")