Feature/auto vpn#777
Open
gitzone83 wants to merge 1 commit intotailscale:mainfrom
Open
Conversation
Author
Add an Auto-VPN Manager that automatically enables/disables the Tailscale VPN tunnel based on the device's current network connection. When enabled, VPN is disabled on user-configured trusted Wi-Fi networks and enabled automatically on untrusted Wi-Fi, cellular data, or when no network is connected (fail-secure). New files: - autoconnect/TrustedNetworks.kt: SharedPreferences persistence for trusted SSID list and feature toggle - autoconnect/NetworkWatcher.kt: ConnectivityManager.NetworkCallback with debounced evaluation, VPN network filtering, action deduplication, SSID retry on null, and triple SSID detection fallback - ui/view/TrustedNetworksView.kt: Jetpack Compose settings screen with feature toggle, current network detection, manual SSID entry, trusted network list, and runtime location permission handling - ui/viewModel/TrustedNetworksViewModel.kt: ViewModel with re-evaluation on settings changes Modified files: - App.kt: Register NetworkWatcher in onCreate()/onTerminate() - MainActivity.kt: Add "trustedNetworks" route and SettingsNav callback - SettingsView.kt: Add Auto-VPN menu entry in settings - SettingsViewModel.kt: Extend SettingsNav with onNavigateToTrustedNetworks - Permissions.kt: Add ACCESS_FINE_LOCATION to permissions list - AndroidManifest.xml: Add ACCESS_FINE_LOCATION permission - strings.xml: Add auto_vpn, permission_location string resources Updates tailscale/tailscale#19408 Signed-off-by: Marek Hajduczenia <mxhajduczenia@gmail.com>
e6389f9 to
c0325be
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Add an Auto-VPN Manager that automatically enables/disables the Tailscale VPN tunnel based on the device's current network connection. When enabled, VPN is disabled on user-configured trusted Wi-Fi networks and enabled automatically on untrusted Wi-Fi, cellular data, or when no network is connected (fail-secure).
Motivation
Most commercial VPN clients already include network-based auto-connect as a core feature:
Tailscale's Android client currently lacks this capability --- users must manually toggle VPN on/off when moving between home and public networks. This creates two problems:
The Auto-VPN feature addresses both by applying a simple, proven model: maintain a user-defined list of trusted SSIDs, and automatically toggle VPN based on whether the current network is trusted. This is the same approach used by the VPN clients listed above, and is the most commonly requested missing feature in Tailscale's mobile clients.
The implementation is fail-secure by design --- if the SSID cannot be determined (location permission denied, transient state, unknown network), VPN defaults to enabled, ensuring the user is never left unprotected.
New files
handling
Modified files
Technical notes
running
Test plan