|
1 | 1 | # Cloudflared Android |
2 | 2 |
|
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. |
4 | 4 |
|
5 | | -## 📱 Versions |
| 5 | +## 🚀 Features |
6 | 6 |
|
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. |
8 | 13 |
|
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 |
11 | 15 |
|
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. |
13 | 20 |
|
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 |
18 | 22 |
|
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. |
20 | 27 |
|
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 |
26 | 29 |
|
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. |
28 | 32 |
|
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 |
35 | 34 |
|
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. |
37 | 37 |
|
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 |
46 | 39 |
|
47 | | -## 🛠️ Building the APK |
| 40 | +Contributions are welcome! Please feel free to submit a Pull Request. |
48 | 41 |
|
49 | | -This project uses Gradle. To build the APK from source, follow these steps: |
| 42 | +## 📄 License |
50 | 43 |
|
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. |