GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Final production release: Real-time status, Direct Boot support, and … · roufsweb/cloudflared-android@68063ed

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • README.md
  • app
    • build.gradle.kts
    • src
      • main
        • AndroidManifest.xml
        • java/com/rouf/cloudflared
          • AppPreferences.kt
          • BootReceiver.kt
          • CloudflaredService.kt
          • FlavorUtils.kt
          • MainActivity.kt
          • UpdateManager.kt
        • jniLibs/arm64-v8a
          • libcloudflared.so
        • res/xml
          • file_paths.xml
      • nonroot
        • AndroidManifest.xml
      • root/java/com/rouf/cloudflared
        • CloudflaredService.kt
        • FlavorUtils.kt
  • gradlew
  • gradle
    • libs.versions.toml
    • wrapper
      • gradle-wrapper.jar
      • gradle-wrapper.properties
  • scratch
    • official_cloudflared
    • old_lib.so
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎README.md‎

Copy file name to clipboard
+28-59Lines changed: 28 additions & 59 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,44 @@
11
# Cloudflared Android
22

3-
An unofficial Android application to run [Cloudflared](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/) (Cloudflare Tunnel) directly on your Android device. This application provides a simple UI to manage and run the Cloudflared daemon, allowing you to expose local services or network routing securely from your phone.
3+
A high-performance, non-root Cloudflare Tunnel client for Android. This application allows you to securely expose local services to the internet or create private tunnels using Cloudflare Zero Trust.
44

5-
## 📱 Versions
5+
## 🚀 Features
66

7-
This app is available in two versions:
7+
- **Non-Root Execution**: Runs `cloudflared` without requiring superuser permissions.
8+
- **Direct Boot Support**: Automatically starts your tunnel after a reboot, even before the device is first unlocked.
9+
- **Auto-Patching Engine**: Automatically patches official `cloudflared` binaries to support Android DNS resolution.
10+
- **Real-Time Status**: Live foreground notification with connection status updates.
11+
- **Background Stability**: Integrated WakeLock and battery optimization handling to prevent the system from killing the tunnel.
12+
- **Seamless Updates**: Download and apply the latest official Cloudflare releases with a single tap.
813

9-
* **Rooted Version:** Uses root access to run the binary from system directories and setup proper DNS overrides. Recommended for the most stable experience.
10-
* **Non-Root Version:** Runs the binary using app-specific storage and basic redirection. Ideal for devices without root access, though it may have some limitations on certain Android versions.
14+
## 🛠 Installation
1115

12-
## ⚠️ Requirements
16+
1. Download the latest APK from the [Releases](https://github.com/roufsweb/cloudflared-android/releases) section.
17+
2. Install the APK on your Android device.
18+
3. Open the app and grant the **Post Notifications** permission.
19+
4. Follow the prompt to **Ignore Battery Optimizations** for consistent background performance.
1320

14-
* **Android Version:** Works on Android 9.0 (API level 28) and above.
15-
* **Privileges:**
16-
* **Rooted APK:** Requires root access (e.g., via Magisk or KernelSU).
17-
* **Non-Root APK:** No special privileges required.
21+
## 📖 Usage
1822

19-
## ✨ Features
23+
1. Obtain a **Tunnel Token** from the Cloudflare Zero Trust dashboard.
24+
2. Paste the token into the app.
25+
3. Click **Connect Tunnel**.
26+
4. (Optional) Enable **Start on Boot** to ensure your tunnel is always active.
2027

21-
* **Manage Cloudflare Tunnels:** Start and stop your Cloudflare tunnel directly from the app.
22-
* **Custom Token Input:** Easily paste and save your Cloudflare Tunnel token.
23-
* **Persistent Execution:** Runs the tunnel in the background using Android Services.
24-
* **Boot Auto-Start:** Automatically starts the tunnel when your device boots (configurable).
25-
* **Integrated Binary:** Manages the `cloudflared` binary for ARM64 architecture seamlessly.
28+
## 🛡 Security & Privacy
2629

27-
## 🚀 How to Use
30+
- **Device Protected Storage**: Sensitive configuration (like your tunnel token) is stored in device-protected storage, enabling safe boot-start functionality.
31+
- **Sandboxed Execution**: The `cloudflared` binary runs within the app's private data directory.
2832

29-
1. **Install the APK:** Download the appropriate APK (`cloudflared-rooted.apk` or `cloudflared-non-rooted.apk`) from the [Releases](https://github.com/roufsweb/cloudflared-android/releases) page.
30-
2. **Permissions:**
31-
* For the **Rooted** version, grant Superuser (Root) permissions when prompted.
32-
* For the **Non-Root** version, ensure the app is excluded from battery optimization if you use "Start on Boot".
33-
3. **Enter your Tunnel Token:** Paste your Cloudflare Tunnel token into the input field and tap "Save".
34-
4. **Start the Tunnel:** Tap the "Connect Tunnel" button. The status icon will indicate when the tunnel is active and running.
33+
## 🔧 Technical Details
3534

36-
### How to get a Cloudflare Tunnel Token
35+
- **Binary Patching**: The app replaces `/etc/resolv.conf` references in the Go binary with `//proc/self/fd/0` at runtime to facilitate DNS resolution via stdin redirection.
36+
- **Foreground Service**: Uses a high-priority foreground service with `dataSync` type for reliable execution on Android 12, 13, and 14.
3737

38-
1. Log in to your [Cloudflare Zero Trust Dashboard](https://one.dash.cloudflare.com/).
39-
2. Navigate to **Networks > Tunnels**.
40-
3. Click **Create a tunnel**. Provide a name and choose the Cloudflared connection type.
41-
4. On the installation page, under the "Choose your environment" section, select any OS (like Debian/Ubuntu).
42-
5. Look at the provided installation command in the code box. It will look something like this:
43-
`cloudflared.exe service install eyJhIjoiOT...<very-long-string>...XDIifQ==`
44-
6. The token is the **very long string of alphanumeric characters at the end of the command**.
45-
7. **Copy ONLY this long token string** and paste it into the Cloudflared Android app.
38+
## 🤝 Contributing
4639

47-
## 🛠️ Building the APK
40+
Contributions are welcome! Please feel free to submit a Pull Request.
4841

49-
This project uses Gradle. To build the APK from source, follow these steps:
42+
## 📄 License
5043

51-
1. Clone this repository:
52-
```bash
53-
git clone https://github.com/roufsweb/cloudflared-android.git
54-
cd cloudflared-android
55-
```
56-
2. Build the release APKs:
57-
```bash
58-
# On Windows
59-
.\gradlew.bat assembleRelease
60-
61-
# On Linux/macOS
62-
./gradlew assembleRelease
63-
```
64-
3. The generated APKs will be located in `app/build/outputs/apk/root/release/` and `app/build/outputs/apk/nonroot/release/`.
65-
66-
## 📜 License
67-
68-
This project is not officially affiliated with Cloudflare. The `cloudflared` binary is licensed under the Apache License 2.0 by Cloudflare, Inc. The Android wrapper is provided as-is.
69-
70-
---
71-
72-
### Connect with Rouf:
73-
* 🌐 **Website:** [rouf.top](https://rouf.top)
74-
* 🐙 **GitHub:** [@roufsweb](https://github.com/roufsweb)
75-
* ✈️ **Telegram:** [@roufsweb](https://t.me/roufsweb)
44+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
Collapse file

‎app/build.gradle.kts‎

Copy file name to clipboardExpand all lines: app/build.gradle.kts
+3-20Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ android {
1010
defaultConfig {
1111
applicationId = "com.rouf.cloudflared"
1212
minSdk = 21
13-
targetSdk = 34
13+
targetSdk = 28
1414
versionCode = 1
1515
versionName = "1.0"
1616

@@ -19,18 +19,6 @@ android {
1919
}
2020
}
2121

22-
flavorDimensions += "version"
23-
24-
productFlavors {
25-
create("root") {
26-
dimension = "version"
27-
}
28-
create("nonroot") {
29-
dimension = "version"
30-
applicationIdSuffix = ".nonroot"
31-
}
32-
}
33-
3422
buildTypes {
3523
release {
3624
isMinifyEnabled = false
@@ -66,13 +54,7 @@ android {
6654
applicationVariants.all {
6755
outputs.all {
6856
val output = this as com.android.build.gradle.internal.api.ApkVariantOutputImpl
69-
val flavor = flavorName
70-
val fileName = if (flavor == "root") {
71-
"cloudflared-rooted.apk"
72-
} else {
73-
"cloudflared-non-rooted.apk"
74-
}
75-
output.outputFileName = fileName
57+
output.outputFileName = "cloudflared-android.apk"
7658
}
7759
}
7860
}
@@ -86,6 +68,7 @@ dependencies {
8668
implementation("androidx.compose.ui:ui-graphics")
8769
implementation("androidx.compose.ui:ui-tooling-preview")
8870
implementation("androidx.compose.material3:material3")
71+
implementation("androidx.compose.material:material-icons-extended")
8972
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
9073
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")
9174
}
Collapse file

‎app/src/main/AndroidManifest.xml‎

Copy file name to clipboardExpand all lines: app/src/main/AndroidManifest.xml
+16-1Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33

44
<uses-permission android:name="android.permission.INTERNET" />
55
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
6+
<uses-permission android:name="android.permission.LOCKED_BOOT_COMPLETED" />
67
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
78
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
89
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
910
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
1011
<uses-permission android:name="android.permission.WAKE_LOCK" />
1112
<uses-permission android:name="android.permission.REQUEST_COMPANION_RUN_IN_BACKGROUND" />
13+
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
1214

1315
<application
1416
android:allowBackup="false"
@@ -29,9 +31,11 @@
2931
<receiver
3032
android:name=".BootReceiver"
3133
android:enabled="true"
32-
android:exported="true">
34+
android:exported="true"
35+
android:directBootAware="true">
3336
<intent-filter>
3437
<action android:name="android.intent.action.BOOT_COMPLETED" />
38+
<action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
3539
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
3640
</intent-filter>
3741
</receiver>
@@ -40,6 +44,17 @@
4044
android:name=".CloudflaredService"
4145
android:enabled="true"
4246
android:exported="false"
47+
android:directBootAware="true"
4348
android:foregroundServiceType="dataSync" />
49+
50+
<provider
51+
android:name="androidx.core.content.FileProvider"
52+
android:authorities="${applicationId}.provider"
53+
android:exported="false"
54+
android:grantUriPermissions="true">
55+
<meta-data
56+
android:name="android.support.FILE_PROVIDER_PATHS"
57+
android:resource="@xml/file_paths" />
58+
</provider>
4459
</application>
4560
</manifest>
Collapse file

‎app/src/main/java/com/rouf/cloudflared/AppPreferences.kt‎

Copy file name to clipboardExpand all lines: app/src/main/java/com/rouf/cloudflared/AppPreferences.kt
+19-2Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,22 @@ package com.rouf.cloudflared
22

33
import android.content.Context
44
import android.content.SharedPreferences
5+
import android.util.Log
56

67
class AppPreferences(context: Context) {
7-
private val prefs: SharedPreferences = context.getSharedPreferences("cloudflared_prefs", Context.MODE_PRIVATE)
8+
private val prefs: SharedPreferences = run {
9+
val storageContext = if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
10+
val deviceContext = context.createDeviceProtectedStorageContext()
11+
// Migrate from credential-protected storage if it exists and we haven't migrated yet
12+
if (!deviceContext.moveSharedPreferencesFrom(context, "cloudflared_prefs")) {
13+
Log.w("AppPreferences", "Failed to migrate shared preferences or already migrated")
14+
}
15+
deviceContext
16+
} else {
17+
context
18+
}
19+
storageContext.getSharedPreferences("cloudflared_prefs", Context.MODE_PRIVATE)
20+
}
821

922
var token: String
1023
get() = prefs.getString("token", "") ?: ""
@@ -15,6 +28,10 @@ class AppPreferences(context: Context) {
1528
set(value) = prefs.edit().putBoolean("autoStart", value).apply()
1629

1730
var startDelaySeconds: Int
18-
get() = prefs.getInt("startDelay", 5)
31+
get() = prefs.getInt("startDelay", 1)
1932
set(value) = prefs.edit().putInt("startDelay", value).apply()
33+
34+
var binaryVersion: String
35+
get() = prefs.getString("binaryVersion", "bundled") ?: "bundled"
36+
set(value) = prefs.edit().putString("binaryVersion", value).apply()
2037
}
Collapse file

‎app/src/main/java/com/rouf/cloudflared/BootReceiver.kt‎

Copy file name to clipboardExpand all lines: app/src/main/java/com/rouf/cloudflared/BootReceiver.kt
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import android.util.Log
77

88
class BootReceiver : BroadcastReceiver() {
99
override fun onReceive(context: Context, intent: Intent) {
10-
if (intent.action == Intent.ACTION_BOOT_COMPLETED || intent.action == "android.intent.action.QUICKBOOT_POWERON") {
10+
if (intent.action == Intent.ACTION_BOOT_COMPLETED ||
11+
intent.action == Intent.ACTION_LOCKED_BOOT_COMPLETED ||
12+
intent.action == "android.intent.action.QUICKBOOT_POWERON") {
1113
val prefs = AppPreferences(context)
1214
if (prefs.autoStart) {
1315
Log.d("CloudflaredBoot", "Auto-starting Cloudflared Service")

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.