diff options
Diffstat (limited to 'android/src')
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/MullvadVpnService.kt | 31 | ||||
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/talpid/TalpidVpnService.kt | 32 |
2 files changed, 34 insertions, 29 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/MullvadVpnService.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/MullvadVpnService.kt index 174387eabb..67fe711a6c 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/MullvadVpnService.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/MullvadVpnService.kt @@ -1,7 +1,6 @@ package net.mullvad.mullvadvpn import android.content.Intent -import android.net.VpnService import android.os.Binder import android.os.IBinder import kotlinx.coroutines.CompletableDeferred @@ -11,9 +10,9 @@ import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.async import kotlinx.coroutines.runBlocking import net.mullvad.mullvadvpn.dataproxy.ConnectionProxy -import net.mullvad.talpid.tun_provider.TunConfig +import net.mullvad.talpid.TalpidVpnService -class MullvadVpnService : VpnService() { +class MullvadVpnService : TalpidVpnService() { private val binder = LocalBinder() private val created = CompletableDeferred<Unit>() @@ -50,32 +49,6 @@ class MullvadVpnService : VpnService() { created.cancel() } - fun createTun(config: TunConfig): Int { - val builder = Builder().apply { - for (address in config.addresses) { - addAddress(address, 32) - } - - for (dnsServer in config.dnsServers) { - addDnsServer(dnsServer) - } - - for (route in config.routes) { - addRoute(route.address, route.prefixLength.toInt()) - } - - setMtu(config.mtu) - } - - val vpnInterface = builder.establish() - - return vpnInterface.detachFd() - } - - fun bypass(socket: Int): Boolean { - return protect(socket) - } - inner class LocalBinder : Binder() { val daemon get() = this@MullvadVpnService.daemon diff --git a/android/src/main/kotlin/net/mullvad/talpid/TalpidVpnService.kt b/android/src/main/kotlin/net/mullvad/talpid/TalpidVpnService.kt new file mode 100644 index 0000000000..96de4082cc --- /dev/null +++ b/android/src/main/kotlin/net/mullvad/talpid/TalpidVpnService.kt @@ -0,0 +1,32 @@ +package net.mullvad.talpid + +import android.net.VpnService +import net.mullvad.talpid.tun_provider.TunConfig + +open class TalpidVpnService : VpnService() { + fun createTun(config: TunConfig): Int { + val builder = Builder().apply { + for (address in config.addresses) { + addAddress(address, 32) + } + + for (dnsServer in config.dnsServers) { + addDnsServer(dnsServer) + } + + for (route in config.routes) { + addRoute(route.address, route.prefixLength.toInt()) + } + + setMtu(config.mtu) + } + + val vpnInterface = builder.establish() + + return vpnInterface.detachFd() + } + + fun bypass(socket: Int): Boolean { + return protect(socket) + } +} |
