Commit Graph

69 Commits (87a8003d397174b54c2bc25b0dc8f32222a01420)

Author SHA1 Message Date
James Tucker 87a8003d39 *: add a CI check for license headers and fix all files
Updates tailscale/tailscale#10992

Signed-off-by: James Tucker <james@tailscale.com>
4 months ago
Jonathan Nobels 4f46c38c99
Jonathan/notifier (#179)
android: add notifier support a data model and compose dependencies

fixes ENG-2084
fixes ENG-2086

Adds support for the ipnBusWatcher directly via a JNI API rather than HTTP via LocalAPIClient

Adds a rudimentary controller class and a model from which we can construct ViewModels

Cleans up some of the JNI bindings.  Adds hooks for ensuring the JNI setup is complete before attempting to do LocalAPIClient things.

Cleans up some wildcard imports.

Signed-off-by: Jonathan Nobels <jonathan@tailscale.com>
Signed-off-by: Percy Wegmann <percy@tailscale.com>
Co-authored-by: Percy Wegmann <percy@tailscale.com>
4 months ago
kari-ts 9492b01946
cmd/tailscale, tailscale/ipn: fix alway-on VPN (#168)
=If a ConnectEvent is received before the first notification, (as happens when a connection is attempted due to always-on after device reboot) create state.Prefs.
-Create an intent to start the VPN worker in the case of an always-on intent received on device reboot
-Rename onConnect channel to onVPNRequested, since this isn't doing the actual connecting

Fixes tailscale/tailscale#2481

Signed-off-by: kari-ts <kari@tailscale.com>
4 months ago
Jonathan Nobels bb7ea7cf9f
android: add kotlin dependencies build the kotlin->go localAPIClient (#173)
updates ENG-2805

Adds all of the kotlin build dependencies and a partial implementation of a LocalAPIClient in the front end, wired up via JNI.  The general idea here is to mimic the architecture used on other Tailscale clients, where the front ends largely interact with the backend via "localapi".

The LocalAPIClient in go has been renamed to LocalAPIService to avoid confusion with the implementation on the future client side in Kotlin.  Some mild refactoring was done to make the localAPI invocations methods on the api service instead of App.

Streaming notifier endpoints like watch-ipn-bus are not supported.  We will build out a separate set of JNI methods for dealing with those.

The jni package is moved under cmd where it is used.

This constains mostly-complete implementation of the required localAPI data classes based on the pieces that are used by the iOS and macOS clients.  The LocalAPIClient itself does not implement all of the endpoints, but is ready to do so when those APIs are needed by a UI component.

Signed-off-by: Jonathan Nobels <jonathan@tailscale.com>
4 months ago
Nicola Beghin df9c75136b
Fixes Android quick settings tile - issue #2646 (#143)
* quicksettings - move to use intents com.tailscale.ipn.CONNECT_VPN and com.tailscale.ipn.DICONNECT_VPN - Fixes #2646

Signed-off-by: Nicola Beghin <nicolabeghin@gmail.com>

* cleanup imports - Fixes #2646

Signed-off-by: Nicola Beghin <nicolabeghin@gmail.com>

---------

Signed-off-by: Nicola Beghin <nicolabeghin@gmail.com>
4 months ago
David Anderson 3255d55e39 Record DNS search domains as well as nameservers.
We accidentally removed this in the big connectivity monitor fix.

Updates tailscale/tailscale#10107

Signed-off-by: David Anderson <danderson@tailscale.com>
5 months ago
kari-ts a76b36506c
DnsConfig: get rid of unnecessary isEmpty check (#149)
* DnsConfig: remove unnecessary isEmpty check

Updates #cleanup

* DnsConfig: remove unnecessary isEmpty check

Updates #cleanup

* k
5 months ago
kari-ts 1b42117791
use network callback to update DNS config when network changes (#147)
* use network callback to update DNS config when network changes

-Use requestNetwork, which gets the best network matching the passed in network request, to listen for changes to network and cache DNS config
-Call netmon.InjectEvent on network change to indicate a change
Follow-up will fix issue in netmon where IsMajorChangeFrom doesn't identify major changes when a network is added

Fixes #10107

* use network callback to update DNS config when network changes

-Use requestNetwork, which gets the best network matching the passed in network request, to listen for changes to network and cache DNS config
-Call netmon.InjectEvent on network change to indicate a change
Follow-up will fix issue in netmon where IsMajorChangeFrom doesn't identify major changes when a network is added

Updates tailscale/tailscale/#10107

hi

* hi

* .

* use network callback to update DNS config when network changes

-Use requestNetwork, which gets the best network matching the passed in network request, to listen for changes to network and cache DNS config
-Call netmon.InjectEvent on network change to indicate a change
Follow-up will fix issue in netmon where IsMajorChangeFrom doesn't identify major changes when a network is added

Updates tailscale/tailscale/#10107

* fixed missing connectivity manager
5 months ago
Denton Gentry c73f8533f0
build.gradle: update targetSdkVersion to 33. (#127)
"bluetooth_name" cannot be accessed after SDK 31, remove it from
getUserConfiguredDeviceName().

Fixes https://github.com/tailscale/tailscale/issues/8955

Signed-off-by: Denton Gentry <dgentry@tailscale.com>
10 months ago
Brett Jenkins 6348bb254a
Prevent connecting loops when using connect intent more than once (#95)
* startvpnworker.java: prevent connecting loops

If start intent called more than once.

Turns out there were still some cases where the bug would occur, also it turns out checking the status of a VPN connection isn't foolproof in android, so this is a safer way to fix it, we just ensure that the autoConnect var is set to false when disconnecting.

Fixes: https://github.com/tailscale/tailscale/issues/8013

Signed-off-by: Brett Jenkins <brett@brettjenkins.co.uk>
11 months ago
James Tucker 8e748afc47 android: update Android Gradle Plugin as recommended by Android Studio
Updates #cleanup
11 months ago
Brett Jenkins eb9599540c
Add intents (#87)
IPNReceiver: Add intents to connect and disconnect VPN

Added a new class IPNReceiver to listen to intents silently and connect and disconnect the VPN. This uses workers to avoid doing too much in the IPNReceiver which is to be avoided according to documentation.

Also includes a fix for vpn occasionally not starting. Think this was due to a race condition, but now only sets autoConnect to false when we know a connection is connecting or connected.

Fixes https://github.com/tailscale/tailscale/issues/3547
Updates https://github.com/tailscale/tailscale/issues/2481

Signed-off-by: Brett Jenkins <brett@brettjenkins.co.uk>
1 year ago
Denton Gentry d0c45c1de1 Revert "IPNReceiver: Add intents to connect and disconnect VPN (#84)"
Reverting according to discussion in
https://github.com/tailscale/tailscale/issues/3547#issuecomment-1465035410

This reverts commit 51a53e5472.
1 year ago
Brett Jenkins 51a53e5472
IPNReceiver: Add intents to connect and disconnect VPN (#84)
* IPNReceiver: Add intents to connect and disconnect VPN

Added a new class IPNReceiver to listen to intents silently and connect and disconnect the VPN
Also removed unneeded comment

Fixes: https://github.com/tailscale/tailscale/issues/3547

Signed-off-by: Brett Jenkins <brett@brettjenkins.co.uk>
1 year ago
Denton Gentry e7ceb58224 IPNService: add Chromecast to the apps allowed to bypass the VPN.
Needed for LAN discovery of Chromecast devices.
Fixes https://github.com/tailscale/tailscale/issues/3636

Signed-off-by: Denton Gentry <dgentry@tailscale.com>
1 year ago
Denton Gentry 908c634a6a
IPNService: add Sonos S1 to the apps allowed to bypass the VPN. (#76)
Fixes https://github.com/tailscale/tailscale/issues/2548

Signed-off-by: Denton Gentry <dgentry@tailscale.com>

Signed-off-by: Denton Gentry <dgentry@tailscale.com>
1 year ago
Denton Gentry 9ce897ed8f
IPNService: add Sonos to the apps allowed to bypass the VPN. (#69)
Updates https://github.com/tailscale/tailscale/issues/2548

Signed-off-by: Denton Gentry <dgentry@tailscale.com>

Signed-off-by: Denton Gentry <dgentry@tailscale.com>
2 years ago
Denton Gentry ac5e24a63d
build.gradle: update to SDK31 (#68)
Required for apps to update in the Play Store after November 1.

This requires:
- manifest must specify if Intents are exported.
- PendingIntent must declare FLAG_IMMUTABLE or MUTABLE

Signed-off-by: Denton Gentry <dgentry@tailscale.com>

Signed-off-by: Denton Gentry <dgentry@tailscale.com>
2 years ago
Denton Gentry d1d72859b4 Add GoPro to the apps allowed to skip the VPN.
Fixes https://github.com/tailscale/tailscale/issues/2554

Signed-off-by: Denton Gentry <dgentry@tailscale.com>
2 years ago
Denton Gentry 283dd77bcc Add a unit test for DnsConfig.intToInetString
adds JUnit dependencies and basic gradle support to run unit tests,
and a test for DnsConfig.intToInetString().

Signed-off-by: Denton Gentry <dgentry@tailscale.com>
2 years ago
Denton Gentry 63dba694af DnsConfig: don't use signed bytes when printing.
intToInetString(0x0101a8c0) returns "-64.-88.1.1" because Java
integers are always signed. There is not a %u format specifier.

Though the quads of an IP address literally are bytes, they can
be left as an int to pass to String.format. This allows room for
sign bits, so intToInetString(0x0101a8c0) returns "192.168.1.1"

Signed-off-by: Denton Gentry <dgentry@tailscale.com>
2 years ago
Denton Gentry 2597b82c3f Add inherently local apps to disallowed list.
Google Stadia, Messages (RCS/Jibe), and Android Auto
don't benefit from being on the VPN, and don't work.
Either they need access to local hardware (Auto, Stadia)
or they're accessing an entirely different communications
channel (Messages). Don't send them through the VPN.

Fixes https://github.com/tailscale/tailscale/issues/2322
Fixes https://github.com/tailscale/tailscale/issues/3460
Fixes https://github.com/tailscale/tailscale/issues/3828

Signed-off-by: Denton Gentry <dgentry@tailscale.com>
2 years ago
Ross Zurowski c7afe66e9a android: update Android TV banner dimensions 2 years ago
Ross Zurowski 052ba2755f android: update Android TV launcher icon 2 years ago
Brad Fitzpatrick 9101d9adc4 android: try to add a Android TV Leanback launcher icon
Maybe it works on Android TV, but this doesn't work on a Fire Stick.

Updates tailscale/tailscale#4179

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2 years ago
Elias Naur 83bfea18bb cmd/tailscale,com/tailscale/ipn: implement QR sign-in for TV devices
This is a cleand up version of #27.

Fixes tailscale/tailscale#1611

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2 years ago
Aman Karmani d9c64011f5 android: make apk android tv compatible 2 years ago
Denton Gentry fd42b4b352 java: format strings containing integers in ROOT locale.
We use strings to pass structured data from the JVM to Go.
In a locale using Indian-Arabic numerals: ۰ ۱ ۲ ۳ ۴ ۵ ۶ ۷ ۸ ۹
the Java code will format decimal strings using Indian-Arabic
glyphs.

Go doesn't get a locale set automatically by the Android
runtime, so it always parses strings in a default en-US
`unable to parse "lo ١ ٦٥٥٣٦ true false true false false |": expected integer`

Make the Java code format using the ROOT locale. These strings
are purely internal to pass between the two runtimes, they are
not shown to the user.

Fixes https://github.com/tailscale/tailscale/issues/4156

Signed-off-by: Denton Gentry <dgentry@tailscale.com>
2 years ago
Denton Gentry 79bb2f33d0 ui: more robust isConnected check.
1. Follow
   https://developer.android.com/training/monitoring-device-state/connectivity-status-type
   to determine whether to report ourself as having connectivity or not.

   Tested by turning the Wifi & LTE off and on, seems to work well in
   the contrived test case.

2. Call superclass for onLost() and onLinkPropertiesChanged() handlers.
   Current Android versions have no code in the superclass of these two
   callbacks, but future proofiness.

3. Log when the UI report of LostInternet changes, so we can find it.

Fixes https://github.com/tailscale/tailscale/issues/3542

Signed-off-by: Denton Gentry <dgentry@tailscale.com>
3 years ago
Denton Gentry 5c9cec0064 retrieve current DNS servers.
Add getDnsConfigAsString() to retrieve the current DNS
configuration from the Android platform. This implements
several mechanisms to retrieve DNS information, suitable
for different Android versions:

Android 7 and later use ConnectivityManager getAllNetworks(),
then iterate over each network to retrieve DNS servers and
search domains using the LinkProperties.

Android 6 and earlier can only retrieve the currently active
interface using ConnectivityManager getActiveNetwork(), but have
two additional fallback options which leverage the system
properties available in older Android releases.

--------

Also changed how LinkChange notification works, switching from
the older BroadcastReceiver of a ConnectivityManager Intent to
the newer ConnectivityManager.registerNetworkCallback. We need
this because the onAvailable event is too early, we get notified
that LTE is up before its DNS servers have been set. We need
to wait for the onLinkPropertiesChanged event instead, which is
only available with registerNetworkCallback.

Fixes https://github.com/tailscale/tailscale/issues/2116
Updates https://github.com/tailscale/tailscale/issues/988

Signed-off-by: Denton Gentry <dgentry@tailscale.com>
3 years ago
Denton Gentry 02a6ae0e0d cmd/tailscale: implement getInterfaces + SDK 30
SDK 30 prohibits syscall.NetlinkRIB(syscall.RTM_GETADDR, ...)
which Go's net.Interfaces uses. Implement an Android
specific version of net.Interfaces to use instead.

Passing primitive types across JNI is relatively straightforward,
passing a single object of a complex class is annoying but still
possible, but passing lists and other more complex data structures is
way harder. As such, this commit added a Java routine to render the
interface information to a string and pass that across JNI as a
primitive type for Go code to parse.

Fixes https://github.com/tailscale/tailscale/issues/2293
3 years ago
Elias Naur 84b484a954 android,cmd/tailscale: implement taildrop receive for Android < 10
Fixes tailscale/tailscale#2720
Fixes tailscale/tailscale#2296

Signed-off-by: Elias Naur <mail@eliasnaur.com>
3 years ago
Elias Naur f37cf72d81 android/ipn: ignore shared files we have no access to
I'm not able to reproduce the crash described in #2720; sharing files
from an SD-card through taildrop works for me (ChromeOS 93.0) without
issues. However, this change makes sure that we don't crash should we
lack permission for some reason.

Updates tailscale/tailscale#2720

Signed-off-by: Elias Naur <mail@eliasnaur.com>
3 years ago
Elias Naur 078356613f android: fix persistent notification intent target
Signed-off-by: Elias Naur <mail@eliasnaur.com>
3 years ago
Elias Naur 10ded1bad2 cmd/tailscale,java: implement file sharing
Fixes tailscale/tailscale#1809

Signed-off-by: Elias Naur <mail@eliasnaur.com>
3 years ago
Brad Fitzpatrick b97cc703d8 Fix routing loop prevention, MagicDNS forwarding over Tailscale.
Fixes tailscale/tailscale#2102
Updates tailscale/tailscale#1809

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
3 years ago
Elias Naur 633d81287a cmd/tailscale,com/tailscale/ipn: delete unused constant, reformat
Signed-off-by: Elias Naur <mail@eliasnaur.com>
3 years ago
Elias Naur 07b2373e6b com/tailscale/ipn,cmd/tailscale: handle quick tile clicks while signed out
Specifically, start the main activity to prompt the user to sign in or
be notified of a pending machine auth.

Fixes tailscale/tailscale#1225

Signed-off-by: Elias Naur <mail@eliasnaur.com>
3 years ago
Elias Naur 71a9bd537c com/tailscale/ipn,AndroidManifest.xml: make quick tile service passive
Active mode is more efficient, but otherwise equivalent to passive mode.
However, some Android versions don't implement active mode reliably. See
also

https://stackoverflow.com/questions/58035971/tileservice-requestlisteningstate-not-working-on-android-q-couldnt-find-tile-f
https://issuetracker.google.com/issues?q=requestListeningState

I can reproduce issue 1225 on an Android 10 emulator, but no longer with
this change applied.

For tailscale/tailscale#1225

Signed-off-by: Elias Naur <mail@eliasnaur.com>
3 years ago
David Anderson 8daee9c431 com/tailscale/ipn: exclude the app from its own VPN.
This means that the Tailscale app's traffic will never use
the VPN that it sets up, which avoids routing loops in
scenarios like publishing a default route over Tailscale.

Signed-off-by: David Anderson <danderson@tailscale.com>
Signed-off-by: Elias Naur <mail@eliasnaur.com>
4 years ago
Elias Naur 2c9fddab4f cmd/tailscale: warn when debug signed and Google Sign-In fails
Fixes tailscale/tailscale#1036

Signed-off-by: Elias Naur <mail@eliasnaur.com>
4 years ago
Elias Naur 9c38bebfa9 android: create build flavor for omitting non-free Google dependency
The F-Droid app store don't support non-free dependencies. Create two build
flavors, "fdroid" for building without Google Sign-In, and "play" for including
it.

Modify Makefile to target the play flavor.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
4 years ago
Elias Naur 6d9acbb479 cmd/tailscale,java: refactor Google Sign-In into separate class
In preparation for the F-Droid release, refactor the non-free Google dependency
into a separate Java class and make the Go client tolerate missing support.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
4 years ago
Elias Naur 6eeb9d8ac4 AndroidManifest.xml: disable auto-backup of (encrypted) app data
Android 6.0 and later automatically backs up app data and allow the user
to restore it when setting up a new device. Unfortunately, the app data
is encrypted with a device specific master key, rendering the data
unreadable on the second device.

Apply the allowBackup=false hammer since we only store device-specific
(logs) and sensitive (private keys, authentication tokens) data for now.

Fixes tailscale/tailscale#732

Signed-off-by: Elias Naur <mail@eliasnaur.com>
4 years ago
Elias Naur d221e0db42 java/com/tailscale/ipn: run attachPeer on main thread
Signed-off-by: Elias Naur <mail@eliasnaur.com>
4 years ago
Elias Naur 1b402aebb0 cmd/tailscale,java/com/tailscale/ipn: always register the Peer Fragment
Before this change, the Peer would be registered across Activity restarts
but not after Activity destruction (for example, when the user pressed the
back button).

Use the newer Gio ViewEvent API for tracking the Activity lifecycle and
the most recent Activity reference.

Move Java calls that need an Activity from Peer to App, leaving Peer solely
as a method for receiving onActivityResult.

Fixes tailscale/tailscale#670

Signed-off-by: Elias Naur <mail@eliasnaur.com>
4 years ago
Elias Naur 3089ad8347 cmd/tailsca,java/comt/tailscale/ipn: don't require an Activity for Google sign-out
The GoogleSignIn.getClient has a version that only needs a Context, not an Activity.

Updates tailscale/tailscale#670

Signed-off-by: Elias Naur <mail@eliasnaur.com>
4 years ago
Elias Naur 39cb01da42 java/com/tailscale/ipn: upgrade Android security to support Android 5.1
As luck would have it, there's a new version of the androidx.security
library available that support Android 5+. Use that, and adjust to the
incompatible API changes.

Fixes tailscale/tailscale#577

Signed-off-by: Elias Naur <mail@eliasnaur.com>
4 years ago
Elias Naur 3ced33d812 java/com/tailscale/ipn: make App Android 5.1 compatible
Fragment.commitNow doesn't exist on Android 5.1. Calling commit and then all
flushing pending transactions is just as good, because we're not using any
other fragments.

Updates tailscale/tailscale#577

Signed-off-by: Elias Naur <mail@eliasnaur.com>
4 years ago
Elias Naur a7dfea267c cmd/tailscale: fallback back to Google DNS on ChromeOS
Contrary to the VpnService.Builder documentation, ChromeOS doesn't
automatically fall back to the underlying network nameservers when
none are provided.

Updates tailscale/tailscale#431

Signed-off-by: Elias Naur <mail@eliasnaur.com>
4 years ago