Skip to content

Commit

Permalink
android: omit excludedRoutes for API<33
Browse files Browse the repository at this point in the history
updates tailscale/corp#25083

excludedRoutes is only supported on API 33 and up so
it needs a version check.

Signed-off-by: Jonathan Nobels <[email protected]>
  • Loading branch information
barnstar committed Dec 5, 2024
1 parent 4e9cceb commit f527618
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions android/src/main/java/com/tailscale/ipn/VPNServiceBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

package com.tailscale.ipn

import android.net.IpPrefix as AndroidIpPrefix
import android.net.VpnService
import libtailscale.ParcelFileDescriptor
import android.os.Build
import java.net.InetAddress
import android.net.IpPrefix as AndroidIpPrefix
import libtailscale.ParcelFileDescriptor

class VPNServiceBuilder(private val builder: VpnService.Builder) : libtailscale.VPNServiceBuilder {
override fun addAddress(p0: String, p1: Int) {
Expand All @@ -22,9 +23,12 @@ class VPNServiceBuilder(private val builder: VpnService.Builder) : libtailscale.
}

override fun excludeRoute(p0: String, p1: Int) {
val inetAddress = InetAddress.getByName(p0)
val prefix = AndroidIpPrefix(inetAddress, p1)
builder.excludeRoute(prefix)
// Only run this for API level 33 and up
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
val inetAddress = InetAddress.getByName(p0)
val prefix = AndroidIpPrefix(inetAddress, p1)
builder.excludeRoute(prefix)
}
}

override fun addSearchDomain(p0: String) {
Expand All @@ -40,8 +44,7 @@ class VPNServiceBuilder(private val builder: VpnService.Builder) : libtailscale.
}
}

class ParcelFileDescriptor(private val fd: android.os.ParcelFileDescriptor) :
libtailscale.ParcelFileDescriptor {
class ParcelFileDescriptor(private val fd: android.os.ParcelFileDescriptor) : ParcelFileDescriptor {
override fun detach(): Int {
return fd.detachFd()
}
Expand Down

0 comments on commit f527618

Please sign in to comment.