Commit Graph

16795 Commits

Author SHA1 Message Date
Tobias Brunner a5f565646a android: Use Java 8 features 2018-07-03 11:31:37 +02:00
Tobias Brunner ab5dbbc4ab android: Show an error if client certificate is unavailable
This can happen on systems (e.g. Android 7.x) where Always-on VPNs are
triggered right after booting before the KeyChain is unlocked by the user.
Retrieving the certificate chain or private key then fails with
"KeyChainException: IllegalStateException: keystore is LOCKED" until the
user unlocks the screen once.

The built-in client actually also fails in this situation (e.g. with XAuth
RSA), it tries three times then stops and shows an error notification.
2018-07-03 11:31:37 +02:00
Tobias Brunner f0b3e303c4 android: Show an error if a profile without a password is initiated
This could happen if an incomplete profile is used with Always-on VPN.
2018-07-03 11:31:37 +02:00
Tobias Brunner e145a5e66d android: Use modern shortcuts on Android 8+ 2018-07-03 11:31:37 +02:00
Tobias Brunner 5b6a0a3f9e android: Add an adaptive launcher icon
Using <inset> in a mipmap folder apparently is not fully valid, at least
Android Studio complains about it (it seems to work fine, though).
2018-07-03 11:31:36 +02:00
Tobias Brunner a7d679ff1b android: Show the actual error description in the notification 2018-07-03 11:31:36 +02:00
Tobias Brunner c353734f47 android: Change format for error strings
Place the dot in the main message not the descriptions of the individual
errors.
2018-07-03 11:31:36 +02:00
Tobias Brunner 4dbe7ffa3e android: Collapse Quick Settings drawer if password entry is required 2018-07-03 11:31:36 +02:00
Tobias Brunner 56f599560c android: Initiate configured default profile when triggered as Always-on VPN
With Android 8.1 this isn't triggered after a reboot until the device
has been unlocked once (solving the issue with the key store) and traffic
may optionally be blocked by the user until the VPN is established.

There are still some issues (e.g. password prompts and fatal errors), and we
might need some workaround for older Android releases.
2018-07-03 11:31:36 +02:00
Tobias Brunner d56f1bf832 android: Just reconnect if the tile is clicked even if there was an error
A long press click on the tile (or a click on the notification) will open
the main activity if more information about the error are necessary.
2018-07-03 11:31:35 +02:00
Tobias Brunner be89310784 android: Allow reconnecting without confirmation in case of an error 2018-07-03 11:31:35 +02:00
Tobias Brunner 6987ddb313 android: Show connection errors as banner, not as modal dialog 2018-07-03 11:31:35 +02:00
Tobias Brunner 64b7a6d622 android: Add Quick Settings tile to toggle VPN state
Only if there is no currently active (or previously active) profile does
this currently operate on the configured (or stored most recently used)
profile.  This way it's possible to use a different connection and
quickly disable and re-enable it again.  When unlocked the profile name
is shown, when locked a generic text is used (this detection doesn't seem
to work 100% reliably).  To disconnect, the user is forced to unlock the
device, connecting is possible without, if the credentials are available
and no fatal error occurs (it even works with the system credential store,
at least on Android 8.1).

Note that the tile is not available right after a reboot.  It seems that
the system has to be unlocked once to activate third-party tiles (will
be interesting to see how this works together with Always-on VPN).
2018-07-03 11:31:35 +02:00
Tobias Brunner 08c79d5112 android: Store the ID of the most recently used profile as preference 2018-07-03 11:31:35 +02:00
Tobias Brunner acdac14818 android: Add settings activity and default profile selection
The default profile can then be used for a Quick Settings tile or the
Always-on VPN feature.
2018-07-03 11:31:34 +02:00
Tobias Brunner 6e73a939a9 android: Reset error state after user confirmed it
This allows other listeners to change their display.
2018-07-03 11:31:34 +02:00
Tobias Brunner 52aaffdeb4 android: Use specific icon when connecting to the VPN 2018-07-03 11:31:34 +02:00
Tobias Brunner 70d6a0cf33 android: Use a handler to show/remove notification from main UI thread
This avoids races that were previously seen (e.g. when disconnecting
while connecting, which sometimes showed a "Disconnecting..."
notification).
2018-07-03 11:31:34 +02:00
Tobias Brunner 58d139dad3 android: Use separate activity to control VPN connections
This way we don't have to open the main window, but only show a dialog
if necessary (or nothing in many cases).
2018-07-03 11:31:34 +02:00
Tobias Brunner 1d336cc2ae android: Migrate onAttach() from deprecated version 2018-07-03 11:31:33 +02:00
Tobias Brunner 4671f023c3 android: Make certificate import activity properly transparent 2018-07-03 11:31:33 +02:00
Tobias Brunner d390d97da4 android: Remove deprecated progress indicator in MainActivity
Support for this was already removed with API level 21. On modern
devices loading CA certs should be quick enough anyway.
2018-07-03 11:31:33 +02:00
Tobias Brunner ed9d5a314c android: Replace deprecated ProgressDialog during profile import 2018-07-03 11:31:33 +02:00
Tobias Brunner 6ca0b46c20 android: Add notification channel for API level 26+
Unfortunately, setLockscreenVisibility() doesn't seem to have any
effect. So the full notification is shown unless the user manually
configures the notification settings.
2018-07-03 11:31:33 +02:00
Tobias Brunner 56dec924ec android: Set compile-/targetSdkVersion to 26
This allows us to add tiles to Quick Settings and enabling the Always-on
VPN feature in the VPN settings (both require API level 24, but 26 will
be required as targetSdkVersion later this year).
2018-07-03 11:31:33 +02:00
Tobias Brunner 71f4a20aa1 android: Show profile ID at bottom of advanced settings
Can be selected and copied to the clipboard to use in automation
software that doesn't support the shortcut.
2018-07-03 11:31:32 +02:00
Tobias Brunner 93033728a9 android: Accept a profile's UUID when initiating 2018-07-03 11:31:32 +02:00
Tobias Brunner 581f4326d5 android: Add additional Intent filter for import Activity with MIME type mask
Chrome creates such an Intent when opening downloaded files (not when
directly opening them), a MIME type is set, but apparently not ours.
2018-07-03 11:31:32 +02:00
Tobias Brunner 93489acc0d android: UUID is now mandatory
Unless there are profiles created with old versions of the app (< 1.8.0)
that were never updated since, all profiles should already have a UUID
assigned.  If not, we do that now with a DB migration.
2018-07-03 11:31:32 +02:00
Tobias Brunner 0917caa195 android: Show an error dialog if we can't get permission for VPNs
This is either because a third-party VPN app has the always-on feature
enabled, or because the user denied the permission in the system's confirmation
dialog.

If the always-on feature is enabled for a connection of the built-in VPN
client we get an IllegalStateException, for which we show an updated and
clearer error message.
2018-07-03 11:31:32 +02:00
Tobias Brunner 08601c58e9 android: Suppress self-assign warnings with clang
These are triggered by the little endian functions in byteorder.h.
2018-07-03 11:31:31 +02:00
Tobias Brunner 2afdb92dd0 atomics: Use type of destination in CAS implementation
The type of the value was incorrect (void**) if NULL was passed to cas_ptr()
as expected value, which caused a compiler warning with Clang because
__atomic_compare_exchange_n() expects the types of the first two arguments
to be the same.
2018-07-03 11:31:31 +02:00
Tobias Brunner 942599b623 atomics: Define HAVE_GCC_ATOMIC_OPERATIONS when building with clang
We should probably check for stdatomic.h and use the c11 functions if
available.
2018-07-03 11:31:31 +02:00
Tobias Brunner 929badfefd android: Build native libraries for all non-deprecated ABIs
armeabi has been superseded by armeabi-v7a and the MIPS ABIs were removed
with the latest NDK (r17), after being marked deprecated for a while.
By not specifying APP_ABI we build for all non-deprecated ABIs.
2018-07-03 11:31:31 +02:00
Tobias Brunner 4bb0a589ff android: Update Gradle plugin and wrapper 2018-07-03 11:31:31 +02:00
Tobias Brunner b68a0adace ike: Include length of reassembled IKE message in log message
Also simplify wording a bit when fragmenting.
2018-07-02 12:19:00 +02:00
Tobias Brunner 707b70725a dhcp: Only use DHCP server port if explicitly configured
If a DHCP server is running on the same host it isn't necessary to
bind the server port and might even cause conflicts.
2018-07-02 11:39:22 +02:00
Tobias Brunner 50c4c1bb40 kernel-pfkey: Avoid updating policies if nothing significant changed
The FreeBSD kernel doesn't update policies atomically, causing
unnecessary traffic loss during simple rekeyings.

Fixes #2677.
2018-07-02 10:17:04 +02:00
Tobias Brunner daa0a0cc1b settings: Fix compilation with newer versions of Clang
Depending on the actual va_list definition it's not valid to compare it
directly or assign NULL.
2018-06-29 11:47:26 +02:00
Tobias Brunner fecafaaca3 Merge branch 'ike-proposal-switch'
This allows switching the originally selected IKE config (based on the
IPs and IKE version) to a different one if no matching proposal is found.

This way we don't rely that much on the order of configs anymore and it's
possible to configure separate configs for clients that require weak
algorithms.
2018-06-28 18:47:15 +02:00
Tobias Brunner 1ecac75f37 testing: Fix IKE proposal in swanctl/net2net-gw scenario
Also simplify config by using references.
2018-06-28 18:46:42 +02:00
Tobias Brunner 187a01cc9f backend-manager: Change how IKE/peer config matches are logged
Instead of logging the search parameters for IKE configs (which were already
before starting the lookup) we log the configured settings.

The peer config lookup is also changed slightly by doing the IKE config
match first and skipping some checks if that or the local peer identity
doesn't match.
2018-06-28 18:46:42 +02:00
Tobias Brunner 2ad1df9571 Replace 'inacceptable' with the more common 'unacceptable' 2018-06-28 18:46:42 +02:00
Tobias Brunner 84cdfbc9bc child-cfg: Allow suppressing log messages when selecting traffic selectors
Although being already logged on level 2, these messages are usually just
confusing if they pop up randomly in the log when e.g. querying the configs
or installing traps.  So after this the log messages will only be logged when
actually proposing or selecting traffic selectors during IKE.
2018-06-28 18:46:42 +02:00
Tobias Brunner 054ee5e7c0 ike-init: Switch to an alternative config if proposals don't match
This way we don't rely on the order of equally matching configs as
heavily anymore (which is actually tricky in vici) and this also doesn't
require repeating weak algorithms in all configs that might potentially be
selected if there are some clients that require them.

There is currently no ordering, so an explicitly configured exactly matching
proposal isn't a better match than e.g. the default proposal that also
contains the proposed algorithms.
2018-06-28 18:46:42 +02:00
Tobias Brunner da288a07aa ike-auth: Consider negotiated IKE proposal when selecting peer configs
In some scenarios we might find multiple usable peer configs with different
IKE proposals.  This is a problem if we use a config with non-matching
proposals that later causes IKE rekeying to fail.  It might even be a problem
already when creating the CHILD_SA if the proposals of IKE and CHILD_SA
are consistent.
2018-06-28 18:46:41 +02:00
Tobias Brunner 29e7fe63c3 ike-cfg: Add method to check if config contains matching proposal
This way we can check whether the config should be considered or not if
we have a selected proposal.
2018-06-28 18:46:41 +02:00
Tobias Brunner f72aa13a29 proposal: Add method to check if two proposals match
Similar to select() but does not return a proposal and does not log
anything.
2018-06-28 18:46:41 +02:00
Tobias Brunner 90f5fe1ca9 child-cfg: Log the selected proposal on level 1 2018-06-28 16:53:35 +02:00
Tobias Brunner 4d338b9acf ike-cfg: Log the selected proposal on level 1 2018-06-28 16:53:35 +02:00