Connlib's routing logic and networking code is entirely platform agnostic. The only platform-specific bit is how we interact with the TUN device. From connlib's perspective though, all it needs is an interface for reading and writing. How the device gets initialised and updated is client-business. For the most part, this is the same on all platforms: We call callbacks and the client updates the state accordingly. The only annoying bit here is that Android recreates the TUN interface on every update and thus our old file descriptor is invalid. The current design works around this by returning the new file descriptor on Android. This is a problematic design for several reasons: - It forces the callback handler to finish synchronously, and halting connlib until this is complete. - The synchronous nature also means we cannot replace the callbacks with events as events don't have a return value. To fix this, we introduce a new `set_tun` method on `Tunnel`. This moves the business of how the `Tun` device is created up to the client. The clients are already platform-specific so this makes sense. In a future iteration, we can move all the various `Tun` implementations all the way up to the client-specific crates, thus co-locating the platform-specific code. Initialising `Tun` from the outside surfaces another issue: The routes are still set via the `Tun` handle on Windows. To fix this, we introduce a `make_tun` function on `TunDeviceManager` in order for it to remember the interface index on Windows and being able to move the setting of routes to `TunDeviceManager`. This simplifies several of connlib's APIs which are now infallible. Resolves: #4473. --------- Co-authored-by: Reactor Scram <ReactorScram@users.noreply.github.com> Co-authored-by: conectado <gabrielalejandro7@gmail.com>
Firezone Android client
This README contains instructions for building and testing the Android client locally.
Dev Setup
-
Install your JDK 17 of choice. We recommend just updating your CLI environment to use the JDK bundled in Android Studio to ensure you're using the same JDK on the CLI as Android Studio.
-
Install the Android SDK through Android Studio.
- Open Android studio, go to Android Studio > Preferences
- Search for
sdk - Find the
Android SDKnav item underSystem Settingsand select - Click the
Editbutton next to theAndroid SDK Locationfield - Follow the steps presented to install Android SDK
-
Install
NDKusing Android StudioTo see which version is installed, make sure to select the
Show Package Detailscheckbox in theAndroid SDKsettings page in Android StudioMake sure the correct NDK version is installed by looking at:
../../rust/connlib/clients/android/connlib/build.gradle.kts -
Set the following ENV variables in the start up config for your shell:
JAVA_HOME=/Applications/Android\ Studio.app/Contents/jbr/Contents/Home ANDROID_HOME=/Users/<username>/Library/Android/sdk NDK_HOME=$ANDROID_HOME/ndk-bundle PATH=$PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin -
Make sure the following Rust targets are installed into the correct toolchain.
aarch64-linux-android arm-linux-androideabi armv7-linux-androideabi i686-linux-android x86_64-linux-androidEnsure you've activated the correct toolchain version for your local environment with
rustup default <toolchain>(find this from the root/rust/rust-toolchain.tomlfile), then run:rustup target add aarch64-linux-android arm-linux-androideabi armv7-linux-androideabi i686-linux-android x86_64-linux-android -
Perform a test build:
./gradlew assembleDebug.
Release Setup
We release from GitHub CI, so this shouldn't be necessary. But if you're looking
to test the release variant locally:
- Download the keystore from 1Pass and save to
app/.signing/keystore.jksdir. - Download firebase credentials from 1Pass and save to
app/.signing/firebase.json - Now you can execute the
*Releasetasks with:
export KEYSTORE_PATH="$(pwd)/app/.signing/keystore.jks"
export FIREBASE_CREDENTIALS_PATH="$(pwd)/app/.signing/firebase.json"
HISTCONTROL=ignorespace # prevents saving the next line in shell history
KEYSTORE_PASSWORD='keystore_password' KEYSTORE_KEY_PASSWORD='keystore_key_password' ./gradlew assembleRelease
