mirror of
https://github.com/kalarina-bit/Sparkledns.git
synced 2026-11-22 07:36:09 +00:00
Compare commits
19
Commits
180a9a65fd
...
access-key
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
92dfd31faf | ||
|
|
3b4d9b049b | ||
|
|
618a9403c7 | ||
|
|
582511607c | ||
|
|
d6f77045e3 | ||
|
|
f3000b7706 | ||
|
|
3c026aaec3 | ||
|
|
1818973abc | ||
|
|
f6a98b8785 | ||
|
|
1fb87a1e99 | ||
|
|
667b1b2dc5 | ||
|
|
399fc5ea36 | ||
|
|
83789c8510 | ||
|
|
64728e5fcd | ||
|
|
2578af2bed | ||
|
|
6d015e9527 | ||
|
|
fb0c13bbcc | ||
|
|
4ef8cef4e8 | ||
|
|
64a122fe25 |
@@ -4,3 +4,6 @@ local.properties
|
|||||||
.idea/
|
.idea/
|
||||||
*.iml
|
*.iml
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
# Signing keys must never be committed
|
||||||
|
*.jks
|
||||||
|
*.keystore
|
||||||
|
|||||||
@@ -12,13 +12,16 @@
|
|||||||
> [!IMPORTANT]
|
> [!IMPORTANT]
|
||||||
> **SparkleDNS is coming to Google Play!** The app is now in closed testing there ahead of the public release. Ideas, wishes and suggestions for improvement are very welcome — send them wherever is easiest for you: an issue on [Gitea](https://git.skysparkle.cc/kalarina/Sparkledns/issues) or [GitHub](https://github.com/kalarina-bit/Sparkledns/issues), or an email to [cuken107@proton.me](mailto:cuken107@proton.me).
|
> **SparkleDNS is coming to Google Play!** The app is now in closed testing there ahead of the public release. Ideas, wishes and suggestions for improvement are very welcome — send them wherever is easiest for you: an issue on [Gitea](https://git.skysparkle.cc/kalarina/Sparkledns/issues) or [GitHub](https://github.com/kalarina-bit/Sparkledns/issues), or an email to [cuken107@proton.me](mailto:cuken107@proton.me).
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> **Looking for designers!** SparkleDNS is looking for volunteer designers to help with icons, logos, animations, cover art (store graphics) and UI design. This is unpaid help for an open-source project. If you're interested, write to [cuken107@proton.me](mailto:cuken107@proton.me).
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://github.com/kalarina-bit/Sparkledns/releases/latest"><img src="https://img.shields.io/github/v/release/kalarina-bit/Sparkledns?style=for-the-badge&label=release&labelColor=1b1b1b&color=2e7d32" alt="Latest release"></a>
|
<a href="https://github.com/kalarina-bit/Sparkledns/releases/latest"><img src="https://img.shields.io/github/v/release/kalarina-bit/Sparkledns?style=for-the-badge&label=release&labelColor=1b1b1b&color=2e7d32" alt="Latest release"></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://f-droid.org/packages/cc.skysparkle.sparkledns/"><img src="assets/get-it-on%20(1).png" height="56" alt="Get it on F-Droid"></a>
|
<a href="https://f-droid.org/packages/cc.skysparkle.sparkledns/"><img src="assets/get-it-on%20(1).png" height="56" alt="Get it on F-Droid"></a>
|
||||||
<a href="https://apps.obtainium.imranr.dev/redirect?r=obtainium://add/https://git.skysparkle.cc/kalarina/Sparkledns"><img src="assets/badge_obtainium.png" height="56" alt="Get it on Obtainium"></a>
|
<a href="https://apps.obtainium.imranr.dev/redirect?r=obtainium://add/https://github.com/kalarina-bit/Sparkledns"><img src="assets/badge_obtainium.png" height="56" alt="Get it on Obtainium"></a>
|
||||||
<a href="https://github.com/kalarina-bit/Sparkledns/releases/latest"><img src="assets/get-it-on-github.png" height="56" alt="Get it on GitHub"></a>
|
<a href="https://github.com/kalarina-bit/Sparkledns/releases/latest"><img src="assets/get-it-on-github.png" height="56" alt="Get it on GitHub"></a>
|
||||||
<a href="https://git.skysparkle.cc/kalarina/Sparkledns/releases"><img src="assets/get-it-on-gitea.png" height="56" alt="Get it on Gitea"></a>
|
<a href="https://git.skysparkle.cc/kalarina/Sparkledns/releases"><img src="assets/get-it-on-gitea.png" height="56" alt="Get it on Gitea"></a>
|
||||||
</p>
|
</p>
|
||||||
@@ -26,7 +29,7 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="assets/screenshots/1-private-dns-left.png" width="160" alt="Private DNS in one tap"><img src="assets/screenshots/2-private-dns-right.png" width="160" alt="You're protected">
|
<img src="assets/screenshots/1-private-dns-left.png" width="160" alt="Private DNS in one tap"><img src="assets/screenshots/2-private-dns-right.png" width="160" alt="You're protected">
|
||||||
<img src="assets/screenshots/3-see-every-request.png" width="160" alt="See every request">
|
<img src="assets/screenshots/3-see-every-request.png" width="160" alt="See every request">
|
||||||
<img src="assets/screenshots/4-block-ads-and-trackers.png" width="160" alt="Block ads and trackers">
|
<img src="assets/screenshots/4-block-trackers-and-malware.png" width="160" alt="Block trackers and malware">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
> [!TIP]
|
> [!TIP]
|
||||||
@@ -45,7 +48,7 @@
|
|||||||
## <img src="assets/icon-install.png" width="32" alt=""> Installation
|
## <img src="assets/icon-install.png" width="32" alt=""> Installation
|
||||||
|
|
||||||
- **[F-Droid](https://f-droid.org/packages/cc.skysparkle.sparkledns/)** — install and update through the F-Droid client.
|
- **[F-Droid](https://f-droid.org/packages/cc.skysparkle.sparkledns/)** — install and update through the F-Droid client.
|
||||||
- **[Obtainium](https://apps.obtainium.imranr.dev/redirect?r=obtainium://add/https://git.skysparkle.cc/kalarina/Sparkledns)** — installs the APK straight from Gitea releases and keeps it up to date.
|
- **[Obtainium](https://apps.obtainium.imranr.dev/redirect?r=obtainium://add/https://github.com/kalarina-bit/Sparkledns)** — installs the APK straight from GitHub releases and keeps it up to date.
|
||||||
- **Manually** — download the latest APK from [GitHub](https://github.com/kalarina-bit/Sparkledns/releases/latest) or [Gitea](https://git.skysparkle.cc/kalarina/Sparkledns/releases), allow installs from unknown sources for the app you open it with (Settings → Apps → Special access → Install unknown apps), then open the `.apk` and confirm.
|
- **Manually** — download the latest APK from [GitHub](https://github.com/kalarina-bit/Sparkledns/releases/latest) or [Gitea](https://git.skysparkle.cc/kalarina/Sparkledns/releases), allow installs from unknown sources for the app you open it with (Settings → Apps → Special access → Install unknown apps), then open the `.apk` and confirm.
|
||||||
|
|
||||||
## <img src="assets/icon-verify.png" width="32" alt=""> Verifying a download
|
## <img src="assets/icon-verify.png" width="32" alt=""> Verifying a download
|
||||||
@@ -82,6 +85,16 @@ Requires JDK 17+ and Android SDK 36.
|
|||||||
|
|
||||||
Bug reports, DoH server and blocklist suggestions, translation fixes and pull requests are welcome in the [issue tracker](https://git.skysparkle.cc/kalarina/Sparkledns/issues). Please read [CONTRIBUTING.md](CONTRIBUTING.md) first — it explains what fits the project and how to send changes. To open an issue or a pull request, [create an account](https://git.skysparkle.cc/user/sign_up) on this Gitea.
|
Bug reports, DoH server and blocklist suggestions, translation fixes and pull requests are welcome in the [issue tracker](https://git.skysparkle.cc/kalarina/Sparkledns/issues). Please read [CONTRIBUTING.md](CONTRIBUTING.md) first — it explains what fits the project and how to send changes. To open an issue or a pull request, [create an account](https://git.skysparkle.cc/user/sign_up) on this Gitea.
|
||||||
|
|
||||||
|
## 💙 Sponsor
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://skysparkle.cc"><img src="assets/skysparkle.svg" width="72" alt="Skysparkle"></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
SparkleDNS is sponsored and supported by <a href="https://skysparkle.cc"><b>Skysparkle</b></a> — independent encrypted DNS from Lithuania and the app’s default DoH server.
|
||||||
|
</p>
|
||||||
|
|
||||||
## 📄 License
|
## 📄 License
|
||||||
|
|
||||||
[GNU General Public License v3.0 only](LICENSE).
|
[GNU General Public License v3.0 only](LICENSE).
|
||||||
|
|||||||
+15
-14
@@ -1,11 +1,12 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("com.android.application")
|
alias(libs.plugins.android.application)
|
||||||
id("org.jetbrains.kotlin.plugin.compose")
|
alias(libs.plugins.kotlin.compose)
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = "cc.skysparkle.sparkledns"
|
namespace = "cc.skysparkle.sparkledns"
|
||||||
compileSdk = 36
|
// The current AndroidX libraries require it
|
||||||
|
compileSdk = 37
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId = "cc.skysparkle.sparkledns"
|
applicationId = "cc.skysparkle.sparkledns"
|
||||||
@@ -13,8 +14,8 @@ android {
|
|||||||
targetSdk = 36
|
targetSdk = 36
|
||||||
// Single source of truth: the About screen reads these through BuildConfig.
|
// Single source of truth: the About screen reads these through BuildConfig.
|
||||||
// Kept as plain literals so F-Droid can detect new versions. Code = major * 10000 + minor * 100 + patch.
|
// Kept as plain literals so F-Droid can detect new versions. Code = major * 10000 + minor * 100 + patch.
|
||||||
versionCode = 10103
|
versionCode = 10105
|
||||||
versionName = "1.1.3"
|
versionName = "1.1.5"
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
@@ -71,17 +72,17 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(platform("androidx.compose:compose-bom:2025.09.00"))
|
implementation(platform(libs.androidx.compose.bom))
|
||||||
implementation("androidx.activity:activity-compose:1.10.1")
|
implementation(libs.androidx.activity.compose)
|
||||||
implementation("androidx.compose.ui:ui")
|
implementation(libs.androidx.compose.ui)
|
||||||
implementation("androidx.compose.material3:material3")
|
implementation(libs.androidx.compose.material3)
|
||||||
// Already pulled in by Compose at this version; declared because the app uses it directly
|
// Already pulled in by Compose at this version; declared because the app uses it directly
|
||||||
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.9.0")
|
implementation(libs.androidx.lifecycle.runtime.compose)
|
||||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2")
|
implementation(libs.kotlinx.coroutines.android)
|
||||||
implementation("com.squareup.okhttp3:okhttp:4.12.0")
|
implementation(libs.okhttp)
|
||||||
|
|
||||||
// Debug builds only, never part of a release
|
// Debug builds only, never part of a release
|
||||||
debugImplementation("com.squareup.leakcanary:leakcanary-android:2.14")
|
debugImplementation(libs.leakcanary.android)
|
||||||
|
|
||||||
testImplementation("junit:junit:4.13.2")
|
testImplementation(libs.junit)
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SYSTEM_EXEMPTED" />
|
||||||
<!-- Keeps the scheduled blocklist update after a reboot -->
|
<!-- Keeps the scheduled blocklist update after a reboot -->
|
||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
|
|
||||||
@@ -21,6 +21,8 @@
|
|||||||
<application
|
<application
|
||||||
android:name=".SparkleApp"
|
android:name=".SparkleApp"
|
||||||
android:allowBackup="false"
|
android:allowBackup="false"
|
||||||
|
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||||
|
android:localeConfig="@xml/locales_config"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
@@ -40,7 +42,7 @@
|
|||||||
<service
|
<service
|
||||||
android:name=".DohVpnService"
|
android:name=".DohVpnService"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:foregroundServiceType="specialUse"
|
android:foregroundServiceType="systemExempted"
|
||||||
android:permission="android.permission.BIND_VPN_SERVICE">
|
android:permission="android.permission.BIND_VPN_SERVICE">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.net.VpnService" />
|
<action android:name="android.net.VpnService" />
|
||||||
@@ -48,9 +50,6 @@
|
|||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.net.VpnService.SUPPORTS_ALWAYS_ON"
|
android:name="android.net.VpnService.SUPPORTS_ALWAYS_ON"
|
||||||
android:value="true" />
|
android:value="true" />
|
||||||
<property
|
|
||||||
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
|
|
||||||
android:value="Local DNS-over-HTTPS VPN that keeps encrypted DNS active while the user has it enabled" />
|
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service
|
<service
|
||||||
|
|||||||
@@ -49,14 +49,18 @@ object AutoUpdate {
|
|||||||
class BlocklistUpdateJob : JobService() {
|
class BlocklistUpdateJob : JobService() {
|
||||||
override fun onStartJob(params: JobParameters): Boolean {
|
override fun onStartJob(params: JobParameters): Boolean {
|
||||||
Thread({
|
Thread({
|
||||||
val ok = try {
|
// A failed download is retried later with the system's back-off
|
||||||
Blocklist.updateAllNow(applicationContext)
|
val retry = try {
|
||||||
|
!Blocklist.updateAllNow(applicationContext)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.w("SparkleDNS", "Blocklist update failed", e)
|
Log.w("SparkleDNS", "Blocklist update failed", e)
|
||||||
|
true
|
||||||
|
} catch (e: OutOfMemoryError) {
|
||||||
|
// Must not take the VPN down with it; retrying would only run out of memory again
|
||||||
|
Log.e("SparkleDNS", "Blocklist update ran out of memory", e)
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
// A failed run is retried later with the system's back-off
|
jobFinished(params, retry)
|
||||||
jobFinished(params, !ok)
|
|
||||||
}, "blocklist-update").start()
|
}, "blocklist-update").start()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import kotlinx.coroutines.flow.StateFlow
|
|||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
|
import okio.BufferedSource
|
||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import java.io.BufferedOutputStream
|
import java.io.BufferedOutputStream
|
||||||
@@ -20,6 +21,7 @@ import java.io.File
|
|||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
import java.nio.LongBuffer
|
||||||
import java.nio.channels.FileChannel
|
import java.nio.channels.FileChannel
|
||||||
import java.security.MessageDigest
|
import java.security.MessageDigest
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
@@ -28,7 +30,8 @@ import java.util.concurrent.TimeUnit
|
|||||||
data class RemoteList(val url: String, val count: Int, val updated: Long, val enabled: Boolean = true)
|
data class RemoteList(val url: String, val count: Int, val updated: Long, val enabled: Boolean = true)
|
||||||
|
|
||||||
// Blocks a domain together with all its subdomains. Changes apply instantly, no reconnect needed.
|
// Blocks a domain together with all its subdomains. Changes apply instantly, no reconnect needed.
|
||||||
// Domains are kept as sorted 64-bit hashes: about 8 bytes per entry, so million-entry lists fit easily.
|
// Domains are kept as sorted 64-bit hashes in files that are memory-mapped, not read into the heap:
|
||||||
|
// lists with millions of entries cost page cache, not app memory, so low-end phones cope too.
|
||||||
object Blocklist {
|
object Blocklist {
|
||||||
const val ALL_LISTS = "*"
|
const val ALL_LISTS = "*"
|
||||||
|
|
||||||
@@ -60,7 +63,7 @@ object Blocklist {
|
|||||||
// Downloaded lists and own domains are kept apart, so editing a few own domains
|
// Downloaded lists and own domains are kept apart, so editing a few own domains
|
||||||
// does not rebuild a set that can hold millions of entries
|
// does not rebuild a set that can hold millions of entries
|
||||||
@Volatile
|
@Volatile
|
||||||
private var listHashes = LongArray(0)
|
private var listHashes: LongBuffer = EMPTY_SET
|
||||||
|
|
||||||
@Volatile
|
@Volatile
|
||||||
private var customHashes = LongArray(0)
|
private var customHashes = LongArray(0)
|
||||||
@@ -223,7 +226,12 @@ object Blocklist {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun reloadListHashes(store: BlocklistStore) {
|
private fun reloadListHashes(store: BlocklistStore) {
|
||||||
listHashes = mergeSorted(_lists.value.filter { it.enabled }.map { store.loadListHashes(it.url) })
|
try {
|
||||||
|
listHashes = store.mergedHashes(_lists.value.filter { it.enabled })
|
||||||
|
} catch (e: IOException) {
|
||||||
|
// Out of storage: the lists in use stay active until the next change
|
||||||
|
Log.w("SparkleDNS", "Cannot merge blocklists", e)
|
||||||
|
}
|
||||||
_total.value = unionSize(listHashes, customHashes)
|
_total.value = unionSize(listHashes, customHashes)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,13 +244,13 @@ object Blocklist {
|
|||||||
|
|
||||||
// True when the name or one of its parent domains is in either sorted hash set. Runs for every
|
// True when the name or one of its parent domains is in either sorted hash set. Runs for every
|
||||||
// query, so trailing dots are skipped by index rather than trimmed off a copy of the name.
|
// query, so trailing dots are skipped by index rather than trimmed off a copy of the name.
|
||||||
internal fun isBlockedIn(name: String, lists: LongArray, custom: LongArray): Boolean {
|
internal fun isBlockedIn(name: String, lists: LongBuffer, custom: LongArray): Boolean {
|
||||||
if (lists.isEmpty() && custom.isEmpty()) return false
|
if (lists.limit() == 0 && custom.isEmpty()) return false
|
||||||
val end = nameEnd(name)
|
val end = nameEnd(name)
|
||||||
var start = 0
|
var start = 0
|
||||||
while (true) {
|
while (true) {
|
||||||
val hash = DomainHash.of(name, start, end)
|
val hash = DomainHash.of(name, start, end)
|
||||||
if (lists.binarySearch(hash) >= 0 || custom.binarySearch(hash) >= 0) return true
|
if (lists.containsSorted(hash) || custom.binarySearch(hash) >= 0) return true
|
||||||
val dot = name.indexOf('.', start)
|
val dot = name.indexOf('.', start)
|
||||||
if (dot < 0 || dot >= end) return false
|
if (dot < 0 || dot >= end) return false
|
||||||
start = dot + 1
|
start = dot + 1
|
||||||
@@ -256,37 +264,59 @@ internal fun nameEnd(name: String): Int {
|
|||||||
return end
|
return end
|
||||||
}
|
}
|
||||||
|
|
||||||
// Number of distinct entries in both sorted sets; the custom set is small
|
internal val EMPTY_SET: LongBuffer = LongBuffer.wrap(LongArray(0))
|
||||||
internal fun unionSize(lists: LongArray, custom: LongArray): Int =
|
|
||||||
lists.size + custom.count { lists.binarySearch(it) < 0 }
|
|
||||||
|
|
||||||
// Merges sorted, duplicate-free arrays in linear time instead of sorting their concatenation
|
// Binary search by absolute index, so several threads can read the same buffer at once
|
||||||
internal fun mergeSorted(parts: List<LongArray>): LongArray {
|
internal fun LongBuffer.containsSorted(value: Long): Boolean {
|
||||||
var arrays = parts.filter { it.isNotEmpty() }.map { if (it.isSortedUnique()) it else it.copyOf().sortUnique() }
|
var low = 0
|
||||||
if (arrays.isEmpty()) return LongArray(0)
|
var high = limit() - 1
|
||||||
while (arrays.size > 1) {
|
while (low <= high) {
|
||||||
arrays = arrays.chunked(2).map { if (it.size == 2) mergeTwo(it[0], it[1]) else it[0] }
|
val mid = (low + high) ushr 1
|
||||||
}
|
val v = get(mid)
|
||||||
return arrays[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun mergeTwo(a: LongArray, b: LongArray): LongArray {
|
|
||||||
val out = LongArray(a.size + b.size)
|
|
||||||
var i = 0
|
|
||||||
var j = 0
|
|
||||||
var n = 0
|
|
||||||
while (i < a.size && j < b.size) {
|
|
||||||
val x = a[i]
|
|
||||||
val y = b[j]
|
|
||||||
when {
|
when {
|
||||||
x < y -> { out[n++] = x; i++ }
|
v < value -> low = mid + 1
|
||||||
x > y -> { out[n++] = y; j++ }
|
v > value -> high = mid - 1
|
||||||
else -> { out[n++] = x; i++; j++ }
|
else -> return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (i < a.size) out[n++] = a[i++]
|
return false
|
||||||
while (j < b.size) out[n++] = b[j++]
|
}
|
||||||
return if (n == out.size) out else out.copyOf(n)
|
|
||||||
|
// Number of distinct entries in both sorted sets; the custom set is small
|
||||||
|
internal fun unionSize(lists: LongBuffer, custom: LongArray): Int =
|
||||||
|
lists.limit() + custom.count { !lists.containsSorted(it) }
|
||||||
|
|
||||||
|
// Merges sorted, duplicate-free sets in one pass and hands each value to [emit] once, in order.
|
||||||
|
// Only the read positions are kept in memory, so inputs and output can be files of any size.
|
||||||
|
internal fun mergeSortedInto(parts: List<LongBuffer>, emit: (Long) -> Unit): Int {
|
||||||
|
val sets = parts.filter { it.limit() > 0 }
|
||||||
|
val pos = IntArray(sets.size)
|
||||||
|
var count = 0
|
||||||
|
while (true) {
|
||||||
|
var min = 0L
|
||||||
|
var found = false
|
||||||
|
for (i in sets.indices) {
|
||||||
|
if (pos[i] < sets[i].limit()) {
|
||||||
|
val v = sets[i].get(pos[i])
|
||||||
|
if (!found || v < min) {
|
||||||
|
min = v
|
||||||
|
found = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) return count
|
||||||
|
for (i in sets.indices) if (pos[i] < sets[i].limit() && sets[i].get(pos[i]) == min) pos[i]++
|
||||||
|
emit(min)
|
||||||
|
count++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// In-memory variant for small sets; inputs that are not sorted yet are sorted first
|
||||||
|
internal fun mergeSorted(parts: List<LongArray>): LongArray {
|
||||||
|
val sorted = parts.map { LongBuffer.wrap(if (it.isSortedUnique()) it else it.copyOf().sortUnique()) }
|
||||||
|
val out = LongList()
|
||||||
|
mergeSortedInto(sorted) { out.add(it) }
|
||||||
|
return out.toArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun LongArray.isSortedUnique(): Boolean {
|
private fun LongArray.isSortedUnique(): Boolean {
|
||||||
@@ -320,6 +350,20 @@ private class LongList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun toArray(): LongArray = data.copyOf(size)
|
fun toArray(): LongArray = data.copyOf(size)
|
||||||
|
|
||||||
|
// Sorts the filled part in place and drops duplicates, without copying; returns the new size
|
||||||
|
fun sortUnique(): Int {
|
||||||
|
if (size < 2) return size
|
||||||
|
java.util.Arrays.sort(data, 0, size)
|
||||||
|
var n = 1
|
||||||
|
for (i in 1 until size) if (data[i] != data[n - 1]) data[n++] = data[i]
|
||||||
|
size = n
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
fun writeTo(out: DataOutputStream) {
|
||||||
|
for (i in 0 until size) out.writeLong(data[i])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sorts in place and drops duplicates
|
// Sorts in place and drops duplicates
|
||||||
@@ -375,17 +419,42 @@ private class BlocklistStore(context: Context) {
|
|||||||
sp.edit().putString("lists", array.toString()).commit()
|
sp.edit().putString("lists", array.toString()).commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun loadListHashes(url: String): LongArray {
|
fun loadListHashes(url: String): LongBuffer = map(binFile(url)) ?: EMPTY_SET
|
||||||
val file = binFile(url)
|
|
||||||
if (!file.exists()) return LongArray(0)
|
// One list is used as it is; several are merged into one file, which is reused at the next
|
||||||
|
// start as long as the switched-on lists have not changed
|
||||||
|
fun mergedHashes(lists: List<RemoteList>): LongBuffer {
|
||||||
|
if (lists.size < 2) {
|
||||||
|
mergedFile.delete()
|
||||||
|
return lists.firstOrNull()?.let { loadListHashes(it.url) } ?: EMPTY_SET
|
||||||
|
}
|
||||||
|
val signature = hash(lists.sortedBy { it.url }.joinToString("\n") { "${it.url} ${it.count} ${it.updated}" })
|
||||||
|
if (sp.getString(MERGED_KEY, null) == signature) map(mergedFile)?.let { return it }
|
||||||
|
|
||||||
|
val parts = lists.map { loadListHashes(it.url) }
|
||||||
|
val tmp = File.createTempFile("merged_", ".tmp", dir)
|
||||||
|
try {
|
||||||
|
DataOutputStream(BufferedOutputStream(FileOutputStream(tmp), 64 * 1024)).use { out ->
|
||||||
|
mergeSortedInto(parts) { out.writeLong(it) }
|
||||||
|
}
|
||||||
|
if (!tmp.renameTo(mergedFile)) throw IOException("Cannot save lists")
|
||||||
|
} finally {
|
||||||
|
tmp.delete()
|
||||||
|
}
|
||||||
|
sp.edit().putString(MERGED_KEY, signature).commit()
|
||||||
|
return map(mergedFile) ?: EMPTY_SET
|
||||||
|
}
|
||||||
|
|
||||||
|
// The mapping stays valid after the file is replaced or deleted, so readers are never cut off
|
||||||
|
private fun map(file: File): LongBuffer? {
|
||||||
|
if (!file.exists()) return null
|
||||||
return runCatching {
|
return runCatching {
|
||||||
FileInputStream(file).use { stream ->
|
FileInputStream(file).use { stream ->
|
||||||
val channel = stream.channel
|
val channel = stream.channel
|
||||||
val result = LongArray((channel.size() / 8).toInt())
|
val bytes = channel.size() / 8 * 8
|
||||||
channel.map(FileChannel.MapMode.READ_ONLY, 0, result.size * 8L).asLongBuffer().get(result)
|
if (bytes == 0L) EMPTY_SET else channel.map(FileChannel.MapMode.READ_ONLY, 0, bytes).asLongBuffer()
|
||||||
result
|
|
||||||
}
|
}
|
||||||
}.getOrDefault(LongArray(0))
|
}.getOrNull()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deleteListFile(url: String) {
|
fun deleteListFile(url: String) {
|
||||||
@@ -407,30 +476,29 @@ private class BlocklistStore(context: Context) {
|
|||||||
if (!response.isSuccessful) throw IOException("HTTP ${response.code}")
|
if (!response.isSuccessful) throw IOException("HTTP ${response.code}")
|
||||||
val body = response.body ?: throw IOException("Empty response")
|
val body = response.body ?: throw IOException("Empty response")
|
||||||
val parsed = LongList()
|
val parsed = LongList()
|
||||||
body.charStream().buffered().useLines { lines ->
|
BlocklistParser.readLimitedLines(body.source()) { line ->
|
||||||
lines.forEach { line ->
|
val domain = BlocklistParser.parseLine(line) ?: return@readLimitedLines
|
||||||
val domain = BlocklistParser.parseLine(line) ?: return@forEach
|
|
||||||
// Far above the largest common lists; keeps a wrong URL from exhausting memory
|
// Far above the largest common lists; keeps a wrong URL from exhausting memory
|
||||||
if (parsed.size >= MAX_LIST_DOMAINS) throw IOException("List too large")
|
if (parsed.size >= MAX_LIST_DOMAINS) throw IOException("List too large")
|
||||||
parsed.add(DomainHash.of(domain))
|
parsed.add(DomainHash.of(domain))
|
||||||
}
|
}
|
||||||
}
|
// Sorted inside the download buffer: a list with millions of entries is never copied
|
||||||
val result = parsed.toArray().sortUnique()
|
val count = parsed.sortUnique()
|
||||||
if (result.isEmpty()) throw IOException("No domains found")
|
if (count == 0) throw IOException("No domains found")
|
||||||
write(url, result)
|
write(url, parsed)
|
||||||
sp.edit()
|
sp.edit()
|
||||||
.putOrRemove(etagKey(url), response.header("ETag"))
|
.putOrRemove(etagKey(url), response.header("ETag"))
|
||||||
.putOrRemove(modifiedKey(url), response.header("Last-Modified"))
|
.putOrRemove(modifiedKey(url), response.header("Last-Modified"))
|
||||||
.apply()
|
.apply()
|
||||||
return RemoteList(url, result.size, System.currentTimeMillis())
|
return RemoteList(url, count, System.currentTimeMillis())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun write(url: String, data: LongArray) {
|
private fun write(url: String, data: LongList) {
|
||||||
val tmp = File.createTempFile("list_", ".tmp", dir)
|
val tmp = File.createTempFile("list_", ".tmp", dir)
|
||||||
try {
|
try {
|
||||||
DataOutputStream(BufferedOutputStream(FileOutputStream(tmp), 64 * 1024)).use { out ->
|
DataOutputStream(BufferedOutputStream(FileOutputStream(tmp), 64 * 1024)).use { out ->
|
||||||
data.forEach { out.writeLong(it) }
|
data.writeTo(out)
|
||||||
}
|
}
|
||||||
if (!tmp.renameTo(binFile(url))) throw IOException("Cannot save list")
|
if (!tmp.renameTo(binFile(url))) throw IOException("Cannot save list")
|
||||||
} finally {
|
} finally {
|
||||||
@@ -445,6 +513,7 @@ private class BlocklistStore(context: Context) {
|
|||||||
if (value == null) remove(key) else putString(key, value)
|
if (value == null) remove(key) else putString(key, value)
|
||||||
|
|
||||||
private fun binFile(url: String) = File(dir, "list_${hash(url)}.bin")
|
private fun binFile(url: String) = File(dir, "list_${hash(url)}.bin")
|
||||||
|
private val mergedFile get() = File(dir, "merged.bin")
|
||||||
|
|
||||||
private fun hash(url: String) = MessageDigest.getInstance("SHA-256").digest(url.toByteArray())
|
private fun hash(url: String) = MessageDigest.getInstance("SHA-256").digest(url.toByteArray())
|
||||||
.take(8).joinToString("") { "%02x".format(it) }
|
.take(8).joinToString("") { "%02x".format(it) }
|
||||||
@@ -452,6 +521,8 @@ private class BlocklistStore(context: Context) {
|
|||||||
companion object {
|
companion object {
|
||||||
const val MAX_LIST_DOMAINS = 4_000_000
|
const val MAX_LIST_DOMAINS = 4_000_000
|
||||||
|
|
||||||
|
private const val MERGED_KEY = "merged"
|
||||||
|
|
||||||
val client: OkHttpClient by lazy {
|
val client: OkHttpClient by lazy {
|
||||||
Http.client.newBuilder()
|
Http.client.newBuilder()
|
||||||
.readTimeout(60, TimeUnit.SECONDS)
|
.readTimeout(60, TimeUnit.SECONDS)
|
||||||
@@ -462,6 +533,59 @@ private class BlocklistStore(context: Context) {
|
|||||||
|
|
||||||
// Understands hosts files, plain domain lists, AdBlock rules (||domain^) and dnsmasq / unbound syntax
|
// Understands hosts files, plain domain lists, AdBlock rules (||domain^) and dnsmasq / unbound syntax
|
||||||
object BlocklistParser {
|
object BlocklistParser {
|
||||||
|
/** A list larger than this is refused; the biggest common lists are well below it. */
|
||||||
|
const val MAX_LIST_BYTES = 256L * 1024 * 1024
|
||||||
|
|
||||||
|
/** Longer lines (no blocklist entry is that long) are skipped, not read into memory. */
|
||||||
|
const val MAX_LINE_BYTES = 4096L
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads [source] line by line within [MAX_LIST_BYTES] in total and [MAX_LINE_BYTES] per
|
||||||
|
* line, so a wrong URL (a binary file, a page with no line breaks) cannot fill the memory.
|
||||||
|
*/
|
||||||
|
fun readLimitedLines(source: BufferedSource, onLine: (String) -> Unit) {
|
||||||
|
var total = 0L
|
||||||
|
fun consumed(bytes: Long) {
|
||||||
|
total += bytes
|
||||||
|
if (total > MAX_LIST_BYTES) throw IOException("List too large")
|
||||||
|
}
|
||||||
|
while (true) {
|
||||||
|
val newline = source.indexOf('\n'.code.toByte(), 0, MAX_LINE_BYTES + 1)
|
||||||
|
when {
|
||||||
|
newline >= 0 -> {
|
||||||
|
onLine(source.readUtf8(newline))
|
||||||
|
source.skip(1)
|
||||||
|
consumed(newline + 1)
|
||||||
|
}
|
||||||
|
source.exhausted() -> return
|
||||||
|
source.request(MAX_LINE_BYTES + 1) -> {
|
||||||
|
// Overlong line: drop it piece by piece up to its end
|
||||||
|
while (true) {
|
||||||
|
// Only what is already buffered: the next line may start right after the break
|
||||||
|
val end = source.buffer.indexOf('\n'.code.toByte())
|
||||||
|
if (end >= 0) {
|
||||||
|
source.skip(end + 1)
|
||||||
|
consumed(end + 1)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
val chunk = source.buffer.size
|
||||||
|
if (chunk == 0L) return
|
||||||
|
source.skip(chunk)
|
||||||
|
consumed(chunk)
|
||||||
|
if (!source.request(1)) return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
// Last line without a line break
|
||||||
|
val rest = source.buffer.size
|
||||||
|
onLine(source.readUtf8())
|
||||||
|
consumed(rest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private val WHITESPACE = Regex("\\s+")
|
private val WHITESPACE = Regex("\\s+")
|
||||||
private val IGNORED = setOf(
|
private val IGNORED = setOf(
|
||||||
"localhost", "localhost.localdomain", "local", "broadcasthost",
|
"localhost", "localhost.localdomain", "local", "broadcasthost",
|
||||||
@@ -477,6 +601,8 @@ object BlocklistParser {
|
|||||||
// Fast path for AdBlock-style lists such as HaGeZi: ||domain^
|
// Fast path for AdBlock-style lists such as HaGeZi: ||domain^
|
||||||
if (line.startsWith("||")) {
|
if (line.startsWith("||")) {
|
||||||
val end = line.indexOfAny(charArrayOf('^', '$', '/'), 2)
|
val end = line.indexOfAny(charArrayOf('^', '$', '/'), 2)
|
||||||
|
// ||example.com/ads/ blocks one path in a browser; as DNS it would block the whole site
|
||||||
|
if (end >= 0 && line[end] == '/' && hasPath(line.substring(end))) return null
|
||||||
return normalize(if (end >= 0) line.substring(2, end) else line.substring(2))
|
return normalize(if (end >= 0) line.substring(2, end) else line.substring(2))
|
||||||
}
|
}
|
||||||
if (DNSMASQ.any { line.startsWith(it) }) return normalize(line.substringAfter("=/").substringBefore('/'))
|
if (DNSMASQ.any { line.startsWith(it) }) return normalize(line.substringAfter("=/").substringBefore('/'))
|
||||||
@@ -486,9 +612,17 @@ object BlocklistParser {
|
|||||||
val parts = line.substringBefore('#').trim().split(WHITESPACE)
|
val parts = line.substringBefore('#').trim().split(WHITESPACE)
|
||||||
val candidate = if (parts.size >= 2 && looksLikeIp(parts[0])) parts[1] else parts[0]
|
val candidate = if (parts.size >= 2 && looksLikeIp(parts[0])) parts[1] else parts[0]
|
||||||
if (candidate.lowercase() in IGNORED) return null
|
if (candidate.lowercase() in IGNORED) return null
|
||||||
|
// A URL with a path (|http://example.com/x|) stands for one page, not for the domain
|
||||||
|
val afterScheme = candidate.substringAfter("://")
|
||||||
|
val slash = afterScheme.indexOf('/')
|
||||||
|
if (slash >= 0 && hasPath(afterScheme.substring(slash))) return null
|
||||||
return normalize(candidate)
|
return normalize(candidate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// "/", "/^" or "/|" only end the host; anything longer is a path
|
||||||
|
private fun hasPath(fromSlash: String): Boolean =
|
||||||
|
fromSlash.trimEnd('^', '|').length > 1
|
||||||
|
|
||||||
fun normalize(input: String): String? {
|
fun normalize(input: String): String? {
|
||||||
var s = input.trim().lowercase()
|
var s = input.trim().lowercase()
|
||||||
s = s.substringAfter("://")
|
s = s.substringAfter("://")
|
||||||
|
|||||||
@@ -59,6 +59,15 @@ class DnsTileService : TileService() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Turning protection off needs an unlocked phone, like other security toggles
|
||||||
|
if (running && isLocked) {
|
||||||
|
unlockAndRun { toggle(running) }
|
||||||
|
return
|
||||||
|
}
|
||||||
|
toggle(running)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun toggle(running: Boolean) {
|
||||||
val action = if (running) DohVpnService.ACTION_STOP else DohVpnService.ACTION_START
|
val action = if (running) DohVpnService.ACTION_STOP else DohVpnService.ACTION_START
|
||||||
try {
|
try {
|
||||||
startService(Intent(this, DohVpnService::class.java).setAction(action))
|
startService(Intent(this, DohVpnService::class.java).setAction(action))
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import android.net.ConnectivityManager
|
|||||||
import android.net.Network
|
import android.net.Network
|
||||||
import android.net.http.HttpEngine
|
import android.net.http.HttpEngine
|
||||||
import android.net.http.HttpException
|
import android.net.http.HttpException
|
||||||
|
import android.net.http.NetworkException
|
||||||
import android.net.http.UploadDataProvider
|
import android.net.http.UploadDataProvider
|
||||||
import android.net.http.UploadDataSink
|
import android.net.http.UploadDataSink
|
||||||
import android.net.http.UrlRequest
|
import android.net.http.UrlRequest
|
||||||
@@ -74,7 +75,10 @@ class DohClient(context: Context, provider: DohProvider) {
|
|||||||
private fun createTransport(context: Context, provider: DohProvider): Transport {
|
private fun createTransport(context: Context, provider: DohProvider): Transport {
|
||||||
if (provider.http3 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
if (provider.http3 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||||
try {
|
try {
|
||||||
return Http3Transport(context, provider)
|
val http3 = Http3Transport(context, provider)
|
||||||
|
// HttpEngine resolves the host with system DNS and cannot use fixed addresses
|
||||||
|
return if (provider.bootstrap.isEmpty()) http3
|
||||||
|
else BootstrapFallbackTransport(http3) { OkHttpTransport(context, provider) }
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
Log.w(TAG, "HttpEngine unavailable, falling back to HTTP/2", e)
|
Log.w(TAG, "HttpEngine unavailable, falling back to HTTP/2", e)
|
||||||
}
|
}
|
||||||
@@ -89,6 +93,38 @@ private interface Transport {
|
|||||||
fun shutdown()
|
fun shutdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class UnresolvedHostException(cause: Throwable) : IOException("Host not resolved", cause)
|
||||||
|
|
||||||
|
// HTTP/3 first; once the network fails to resolve the server's name, the rest of the session
|
||||||
|
// goes over OkHttp, which connects to the bootstrap addresses instead
|
||||||
|
private class BootstrapFallbackTransport(
|
||||||
|
private val http3: Transport,
|
||||||
|
createFallback: () -> Transport,
|
||||||
|
) : Transport {
|
||||||
|
private val fallback = lazy(createFallback)
|
||||||
|
@Volatile private var useFallback = false
|
||||||
|
|
||||||
|
override val lastProtocol: String?
|
||||||
|
get() = if (useFallback) fallback.value.lastProtocol else http3.lastProtocol
|
||||||
|
|
||||||
|
override fun query(message: ByteArray): ByteArray {
|
||||||
|
if (!useFallback) {
|
||||||
|
try {
|
||||||
|
return http3.query(message)
|
||||||
|
} catch (e: UnresolvedHostException) {
|
||||||
|
Log.w(TAG, "Server name not resolved over HTTP/3, using bootstrap addresses")
|
||||||
|
useFallback = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fallback.value.query(message)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun shutdown() {
|
||||||
|
http3.shutdown()
|
||||||
|
if (fallback.isInitialized()) fallback.value.shutdown()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class OkHttpTransport(context: Context, private val provider: DohProvider) : Transport {
|
private class OkHttpTransport(context: Context, private val provider: DohProvider) : Transport {
|
||||||
|
|
||||||
private val url by lazy { provider.url.toHttpUrl() }
|
private val url by lazy { provider.url.toHttpUrl() }
|
||||||
@@ -140,7 +176,11 @@ private class OkHttpTransport(context: Context, private val provider: DohProvide
|
|||||||
if (!response.isSuccessful) throw IOException("HTTP ${response.code}")
|
if (!response.isSuccessful) throw IOException("HTTP ${response.code}")
|
||||||
val body = response.body ?: throw IOException("Empty response")
|
val body = response.body ?: throw IOException("Empty response")
|
||||||
if (body.contentLength() > MAX_DNS_SIZE) throw IOException("Response too large")
|
if (body.contentLength() > MAX_DNS_SIZE) throw IOException("Response too large")
|
||||||
return body.bytes()
|
// Without Content-Length the size is only known while reading: stop one byte past the limit
|
||||||
|
val source = body.source()
|
||||||
|
source.request(MAX_DNS_SIZE + 1L)
|
||||||
|
if (source.buffer.size > MAX_DNS_SIZE) throw IOException("Response too large")
|
||||||
|
return source.buffer.readByteArray()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,7 +260,11 @@ private class Http3Transport(context: Context, private val provider: DohProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onFailed(request: UrlRequest, info: UrlResponseInfo?, error: HttpException) {
|
override fun onFailed(request: UrlRequest, info: UrlResponseInfo?, error: HttpException) {
|
||||||
result.completeExceptionally(IOException(error.message, error))
|
val unresolved = error is NetworkException &&
|
||||||
|
error.errorCode == NetworkException.ERROR_HOSTNAME_NOT_RESOLVED
|
||||||
|
result.completeExceptionally(
|
||||||
|
if (unresolved) UnresolvedHostException(error) else IOException(error.message, error)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCanceled(request: UrlRequest, info: UrlResponseInfo?) {
|
override fun onCanceled(request: UrlRequest, info: UrlResponseInfo?) {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import android.system.StructPollfd
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
|
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
@@ -34,7 +35,11 @@ private const val WORKERS = 16
|
|||||||
private const val TAG = "SparkleDNS"
|
private const val TAG = "SparkleDNS"
|
||||||
private const val CHANNEL_ID = "vpn_status"
|
private const val CHANNEL_ID = "vpn_status"
|
||||||
private const val NOTIFICATION_ID = 1
|
private const val NOTIFICATION_ID = 1
|
||||||
|
// Separate channel with normal importance: losing protection must not go unnoticed
|
||||||
|
private const val ALERT_CHANNEL_ID = "vpn_alerts"
|
||||||
|
private const val ALERT_NOTIFICATION_ID = 2
|
||||||
private const val MAX_BAD_PACKETS = 100
|
private const val MAX_BAD_PACKETS = 100
|
||||||
|
private const val READER_JOIN_MS = 1000L
|
||||||
|
|
||||||
// Android's resolver retries after 5 s, so an older lookup no longer has anyone waiting for it
|
// Android's resolver retries after 5 s, so an older lookup no longer has anyone waiting for it
|
||||||
private const val QUEUE_TIMEOUT_MS = 5000L
|
private const val QUEUE_TIMEOUT_MS = 5000L
|
||||||
@@ -96,6 +101,19 @@ class DohVpnService : VpnService() {
|
|||||||
val provider = prefs.resolve()
|
val provider = prefs.resolve()
|
||||||
val excluded = prefs.excludedApps
|
val excluded = prefs.excludedApps
|
||||||
|
|
||||||
|
// The app checks the address before connecting, but always-on VPN and a restart by the
|
||||||
|
// system start the service directly. A tunnel with a broken URL would fail every lookup.
|
||||||
|
if (provider.url.toHttpUrlOrNull()?.isHttps != true) {
|
||||||
|
Log.e(TAG, "Server address is not a valid HTTPS URL, not starting")
|
||||||
|
stopSession()
|
||||||
|
showAlert(
|
||||||
|
R.string.alert_bad_url_title,
|
||||||
|
if (provider.id == Providers.DEFAULT_ID) R.string.alert_no_key_text else R.string.alert_bad_url_text,
|
||||||
|
)
|
||||||
|
stopSelf()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
val builder = Builder()
|
val builder = Builder()
|
||||||
.setSession(provider.displayName(this))
|
.setSession(provider.displayName(this))
|
||||||
.addAddress(TUN_ADDRESS, 32)
|
.addAddress(TUN_ADDRESS, 32)
|
||||||
@@ -138,6 +156,14 @@ class DohVpnService : VpnService() {
|
|||||||
_activeExcluded.value = excluded
|
_activeExcluded.value = excluded
|
||||||
showNotification(provider)
|
showNotification(provider)
|
||||||
DnsTileService.refresh(this)
|
DnsTileService.refresh(this)
|
||||||
|
getSystemService(NotificationManager::class.java)?.cancel(ALERT_NOTIFICATION_ID)
|
||||||
|
|
||||||
|
// With "Block connections without VPN" the app, excluded from its own tunnel, cannot reach
|
||||||
|
// the DoH server, so every lookup would fail
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && isLockdownEnabled) {
|
||||||
|
Log.w(TAG, "Lockdown mode is on, the DoH server is not reachable")
|
||||||
|
showAlert(R.string.alert_lockdown_title, R.string.alert_lockdown_text)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun stopSession() {
|
private fun stopSession() {
|
||||||
@@ -157,10 +183,34 @@ class DohVpnService : VpnService() {
|
|||||||
if (session !== failed) return@post
|
if (session !== failed) return@post
|
||||||
Log.e(TAG, "Tunnel stopped working, disconnecting")
|
Log.e(TAG, "Tunnel stopped working, disconnecting")
|
||||||
stopSession()
|
stopSession()
|
||||||
|
// DNS goes unencrypted from here on; the user has to know
|
||||||
|
showAlert(R.string.alert_stopped_title, R.string.alert_stopped_text)
|
||||||
stopSelf()
|
stopSelf()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun showAlert(titleRes: Int, textRes: Int) {
|
||||||
|
val manager = getSystemService(NotificationManager::class.java) ?: return
|
||||||
|
manager.createNotificationChannel(
|
||||||
|
NotificationChannel(ALERT_CHANNEL_ID, getString(R.string.alert_channel), NotificationManager.IMPORTANCE_DEFAULT)
|
||||||
|
)
|
||||||
|
val openApp = PendingIntent.getActivity(
|
||||||
|
this, 2,
|
||||||
|
Intent(this, MainActivity::class.java).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP),
|
||||||
|
PendingIntent.FLAG_IMMUTABLE,
|
||||||
|
)
|
||||||
|
val text = getString(textRes)
|
||||||
|
val notification = Notification.Builder(this, ALERT_CHANNEL_ID)
|
||||||
|
.setSmallIcon(R.drawable.ic_notification)
|
||||||
|
.setContentTitle(getString(titleRes))
|
||||||
|
.setContentText(text)
|
||||||
|
.setStyle(Notification.BigTextStyle().bigText(text))
|
||||||
|
.setContentIntent(openApp)
|
||||||
|
.setAutoCancel(true)
|
||||||
|
.build()
|
||||||
|
runCatching { manager.notify(ALERT_NOTIFICATION_ID, notification) }
|
||||||
|
}
|
||||||
|
|
||||||
private fun showNotification(provider: DohProvider) {
|
private fun showNotification(provider: DohProvider) {
|
||||||
val manager = getSystemService(NotificationManager::class.java) ?: return
|
val manager = getSystemService(NotificationManager::class.java) ?: return
|
||||||
manager.createNotificationChannel(
|
manager.createNotificationChannel(
|
||||||
@@ -196,7 +246,7 @@ class DohVpnService : VpnService() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||||
startForeground(NOTIFICATION_ID, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE)
|
startForeground(NOTIFICATION_ID, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_SYSTEM_EXEMPTED)
|
||||||
} else {
|
} else {
|
||||||
startForeground(NOTIFICATION_ID, notification)
|
startForeground(NOTIFICATION_ID, notification)
|
||||||
}
|
}
|
||||||
@@ -229,6 +279,9 @@ private class Session(
|
|||||||
if (!alive.getAndSet(false)) return
|
if (!alive.getAndSet(false)) return
|
||||||
pool.shutdownNow()
|
pool.shutdownNow()
|
||||||
runCatching { wakeup[1].close() }
|
runCatching { wakeup[1].close() }
|
||||||
|
// The pipe wakes the reader at once; let it leave before its descriptor is closed and
|
||||||
|
// possibly reused by something else
|
||||||
|
if (Thread.currentThread() !== reader) runCatching { reader.join(READER_JOIN_MS) }
|
||||||
runCatching { tun.close() }
|
runCatching { tun.close() }
|
||||||
closer.execute {
|
closer.execute {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -143,7 +143,8 @@ fun HomeScreen(
|
|||||||
|
|
||||||
// The server is picked in Settings; this screen is composed anew each time it is shown
|
// The server is picked in Settings; this screen is composed anew each time it is shown
|
||||||
val selected = remember { prefs.resolve() }
|
val selected = remember { prefs.resolve() }
|
||||||
val canConnect = selected.id != Providers.CUSTOM_ID || selected.url.toHttpUrlOrNull()?.isHttps == true
|
val canConnect = selected.url.toHttpUrlOrNull()?.isHttps == true
|
||||||
|
val needsKey = selected.id == Providers.DEFAULT_ID && !canConnect
|
||||||
val shown = active ?: selected
|
val shown = active ?: selected
|
||||||
val usesHttp3 = shown.http3 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE
|
val usesHttp3 = shown.http3 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE
|
||||||
|
|
||||||
@@ -223,6 +224,14 @@ fun HomeScreen(
|
|||||||
onToggle = ::toggle,
|
onToggle = ::toggle,
|
||||||
onOpenServers = onOpenServers,
|
onOpenServers = onOpenServers,
|
||||||
)
|
)
|
||||||
|
if (needsKey && !running) {
|
||||||
|
HintCard(
|
||||||
|
text = stringResource(R.string.key_needed),
|
||||||
|
icon = R.drawable.ic_alert,
|
||||||
|
tint = Palette.Accent,
|
||||||
|
action = { TextButton(onClick = onOpenServers) { Text(stringResource(R.string.key_add)) } },
|
||||||
|
)
|
||||||
|
}
|
||||||
PrivateDnsWarning(privateDnsHost, prefs)
|
PrivateDnsWarning(privateDnsHost, prefs)
|
||||||
}
|
}
|
||||||
val stats: @Composable () -> Unit = {
|
val stats: @Composable () -> Unit = {
|
||||||
|
|||||||
@@ -33,9 +33,12 @@ import androidx.compose.runtime.Composable
|
|||||||
import androidx.compose.runtime.CompositionLocalProvider
|
import androidx.compose.runtime.CompositionLocalProvider
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.MutableState
|
import androidx.compose.runtime.MutableState
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.saveable.Saver
|
import androidx.compose.runtime.saveable.Saver
|
||||||
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
@@ -60,7 +63,9 @@ class MainActivity : ComponentActivity() {
|
|||||||
// There is no Surface at the root, so text and icons without an explicit color
|
// There is no Surface at the root, so text and icons without an explicit color
|
||||||
// would fall back to black and disappear on the dark background
|
// would fall back to black and disappear on the dark background
|
||||||
CompositionLocalProvider(LocalContentColor provides MaterialTheme.colorScheme.onSurface) {
|
CompositionLocalProvider(LocalContentColor provides MaterialTheme.colorScheme.onSurface) {
|
||||||
AppShell()
|
// First launch: the guide explains the access key before the app opens
|
||||||
|
var onboarded by rememberSaveable { mutableStateOf(Prefs(this@MainActivity).onboardingDone) }
|
||||||
|
if (onboarded) AppShell() else OnboardingScreen(onDone = { onboarded = true })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,200 @@
|
|||||||
|
package cc.skysparkle.sparkledns
|
||||||
|
|
||||||
|
import androidx.activity.compose.BackHandler
|
||||||
|
import androidx.compose.animation.AnimatedContent
|
||||||
|
import androidx.compose.animation.fadeIn
|
||||||
|
import androidx.compose.animation.fadeOut
|
||||||
|
import androidx.compose.animation.slideInHorizontally
|
||||||
|
import androidx.compose.animation.slideOutHorizontally
|
||||||
|
import androidx.compose.animation.togetherWith
|
||||||
|
import androidx.compose.foundation.Image
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.Spacer
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.height
|
||||||
|
import androidx.compose.foundation.layout.imePadding
|
||||||
|
import androidx.compose.foundation.layout.navigationBarsPadding
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.foundation.layout.statusBarsPadding
|
||||||
|
import androidx.compose.foundation.layout.width
|
||||||
|
import androidx.compose.foundation.layout.widthIn
|
||||||
|
import androidx.compose.foundation.rememberScrollState
|
||||||
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.foundation.verticalScroll
|
||||||
|
import androidx.compose.material3.Button
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.material3.TextButton
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableIntStateOf
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.draw.clip
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
|
|
||||||
|
// Shown once on first launch: what the app does, then how to get the personal access key
|
||||||
|
// for the Skysparkle server. Skipping leaves the key empty; other servers stay available.
|
||||||
|
@Composable
|
||||||
|
fun OnboardingScreen(onDone: () -> Unit) {
|
||||||
|
val context = LocalContext.current
|
||||||
|
val prefs = remember { Prefs(context) }
|
||||||
|
var page by rememberSaveable { mutableIntStateOf(0) }
|
||||||
|
var keyInput by rememberSaveable { mutableStateOf(prefs.skysparkleKey) }
|
||||||
|
val keyValid = SkysparkleKey.parse(keyInput) != null
|
||||||
|
|
||||||
|
fun finish(useKey: Boolean) {
|
||||||
|
if (useKey) {
|
||||||
|
prefs.skysparkleKey = SkysparkleKey.parse(keyInput) ?: ""
|
||||||
|
prefs.providerId = Providers.DEFAULT_ID
|
||||||
|
}
|
||||||
|
prefs.onboardingDone = true
|
||||||
|
onDone()
|
||||||
|
}
|
||||||
|
|
||||||
|
BackHandler(enabled = page > 0) { page-- }
|
||||||
|
|
||||||
|
Box(
|
||||||
|
Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.background(Palette.Bg)
|
||||||
|
.statusBarsPadding()
|
||||||
|
.navigationBarsPadding()
|
||||||
|
.imePadding(),
|
||||||
|
contentAlignment = Alignment.TopCenter,
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
Modifier
|
||||||
|
.widthIn(max = 520.dp)
|
||||||
|
.fillMaxSize()
|
||||||
|
.padding(horizontal = 24.dp, vertical = 20.dp),
|
||||||
|
) {
|
||||||
|
Dots(count = 2, current = page)
|
||||||
|
AnimatedContent(
|
||||||
|
targetState = page,
|
||||||
|
transitionSpec = {
|
||||||
|
val forward = targetState > initialState
|
||||||
|
(fadeIn(Motion.enterFade) + slideInHorizontally(Motion.slide) { if (forward) it / 4 else -it / 4 }) togetherWith
|
||||||
|
(fadeOut(Motion.exitFade) + slideOutHorizontally(Motion.slide) { if (forward) -it / 4 else it / 4 })
|
||||||
|
},
|
||||||
|
modifier = Modifier.weight(1f),
|
||||||
|
label = "onboarding",
|
||||||
|
) { current ->
|
||||||
|
Column(
|
||||||
|
Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.verticalScroll(rememberScrollState())
|
||||||
|
.padding(top = 40.dp, bottom = 16.dp),
|
||||||
|
verticalArrangement = Arrangement.spacedBy(14.dp),
|
||||||
|
) {
|
||||||
|
if (current == 0) {
|
||||||
|
Image(
|
||||||
|
bitmap = AppLogo.get(context),
|
||||||
|
contentDescription = null,
|
||||||
|
modifier = Modifier
|
||||||
|
.size(72.dp)
|
||||||
|
.clip(RoundedCornerShape(20.dp)),
|
||||||
|
)
|
||||||
|
Spacer(Modifier.height(8.dp))
|
||||||
|
Title(stringResource(R.string.onb_welcome_title))
|
||||||
|
Body(stringResource(R.string.onb_welcome_text))
|
||||||
|
Spacer(Modifier.height(8.dp))
|
||||||
|
Step(1, stringResource(R.string.onb_point_encrypt))
|
||||||
|
Step(2, stringResource(R.string.onb_point_block))
|
||||||
|
Step(3, stringResource(R.string.onb_point_independent))
|
||||||
|
} else {
|
||||||
|
Title(stringResource(R.string.onb_key_title))
|
||||||
|
Body(stringResource(R.string.onb_key_text))
|
||||||
|
Spacer(Modifier.height(4.dp))
|
||||||
|
Step(1, stringResource(R.string.onb_key_step1))
|
||||||
|
Step(2, stringResource(R.string.onb_key_step2))
|
||||||
|
Step(3, stringResource(R.string.onb_key_step3))
|
||||||
|
Spacer(Modifier.height(4.dp))
|
||||||
|
Column(Modifier.fillMaxWidth().appCard().padding(top = 16.dp)) {
|
||||||
|
KeyField(
|
||||||
|
value = keyInput,
|
||||||
|
valid = keyValid,
|
||||||
|
onChange = { keyInput = it },
|
||||||
|
onGetKey = { openUrl(context, SkysparkleKey.SIGNUP_URL) },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (page == 0) {
|
||||||
|
Button(
|
||||||
|
onClick = { page = 1 },
|
||||||
|
shape = RoundedCornerShape(16.dp),
|
||||||
|
modifier = Modifier.fillMaxWidth().height(52.dp),
|
||||||
|
) { Text(stringResource(R.string.onb_next), fontWeight = FontWeight.Bold) }
|
||||||
|
} else {
|
||||||
|
Button(
|
||||||
|
onClick = { finish(useKey = true) },
|
||||||
|
enabled = keyValid,
|
||||||
|
shape = RoundedCornerShape(16.dp),
|
||||||
|
modifier = Modifier.fillMaxWidth().height(52.dp),
|
||||||
|
) { Text(stringResource(R.string.onb_done), fontWeight = FontWeight.Bold) }
|
||||||
|
TextButton(onClick = { finish(useKey = false) }, modifier = Modifier.fillMaxWidth()) {
|
||||||
|
Text(stringResource(R.string.onb_skip), color = Palette.Fg3)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun Title(text: String) {
|
||||||
|
Text(text, color = Palette.Fg, fontSize = 30.sp, lineHeight = 34.sp, fontWeight = FontWeight.ExtraBold, letterSpacing = (-0.5).sp)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun Body(text: String) {
|
||||||
|
Text(text, color = Palette.Fg2, fontSize = 16.sp, lineHeight = 23.sp)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun Step(number: Int, text: String) {
|
||||||
|
Row(verticalAlignment = Alignment.Top) {
|
||||||
|
Box(
|
||||||
|
Modifier
|
||||||
|
.size(26.dp)
|
||||||
|
.clip(CircleShape)
|
||||||
|
.background(Palette.AccentSoft),
|
||||||
|
contentAlignment = Alignment.Center,
|
||||||
|
) {
|
||||||
|
Text(number.toString(), color = Palette.Accent, fontSize = 13.sp, fontWeight = FontWeight.Bold)
|
||||||
|
}
|
||||||
|
Spacer(Modifier.width(12.dp))
|
||||||
|
Text(text, color = Palette.Fg, fontSize = 15.sp, lineHeight = 21.sp, modifier = Modifier.padding(top = 2.dp))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun Dots(count: Int, current: Int) {
|
||||||
|
Row(horizontalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||||
|
repeat(count) { i ->
|
||||||
|
Box(
|
||||||
|
Modifier
|
||||||
|
.height(4.dp)
|
||||||
|
.width(if (i == current) 22.dp else 10.dp)
|
||||||
|
.clip(CircleShape)
|
||||||
|
.background(if (i == current) Palette.Accent else Palette.Track),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,6 +21,16 @@ class Prefs(context: Context) {
|
|||||||
get() = sp.getBoolean(KEY_HTTP3, false)
|
get() = sp.getBoolean(KEY_HTTP3, false)
|
||||||
set(value) = sp.edit().putBoolean(KEY_HTTP3, value).apply()
|
set(value) = sp.edit().putBoolean(KEY_HTTP3, value).apply()
|
||||||
|
|
||||||
|
// Access key for the Skysparkle server, created in the account at skysparkle.cc
|
||||||
|
var skysparkleKey: String
|
||||||
|
get() = sp.getString(KEY_SKYSPARKLE, null) ?: ""
|
||||||
|
set(value) = sp.edit().putString(KEY_SKYSPARKLE, value).apply()
|
||||||
|
|
||||||
|
// The first-launch guide was finished or skipped
|
||||||
|
var onboardingDone: Boolean
|
||||||
|
get() = sp.getBoolean(KEY_ONBOARDING, false)
|
||||||
|
set(value) = sp.edit().putBoolean(KEY_ONBOARDING, value).apply()
|
||||||
|
|
||||||
var excludedApps: Set<String>
|
var excludedApps: Set<String>
|
||||||
get() = sp.getStringSet(KEY_EXCLUDED, null)?.toSet() ?: emptySet()
|
get() = sp.getStringSet(KEY_EXCLUDED, null)?.toSet() ?: emptySet()
|
||||||
set(value) = sp.edit().putStringSet(KEY_EXCLUDED, value).apply()
|
set(value) = sp.edit().putStringSet(KEY_EXCLUDED, value).apply()
|
||||||
@@ -48,11 +58,13 @@ class Prefs(context: Context) {
|
|||||||
get() = sp.getString(KEY_PRIVATE_DNS, null) ?: ""
|
get() = sp.getString(KEY_PRIVATE_DNS, null) ?: ""
|
||||||
set(value) = sp.edit().putString(KEY_PRIVATE_DNS, value).apply()
|
set(value) = sp.edit().putString(KEY_PRIVATE_DNS, value).apply()
|
||||||
|
|
||||||
fun resolve(): DohProvider =
|
// Without a key the Skysparkle entry has an empty address, so it cannot connect
|
||||||
if (providerId == Providers.CUSTOM_ID) {
|
fun resolve(): DohProvider = when (providerId) {
|
||||||
|
Providers.CUSTOM_ID ->
|
||||||
DohProvider(Providers.CUSTOM_ID, "Custom", customUrl.trim(), parseIps(customBootstrap), customHttp3)
|
DohProvider(Providers.CUSTOM_ID, "Custom", customUrl.trim(), parseIps(customBootstrap), customHttp3)
|
||||||
} else {
|
else -> Providers.byId(providerId).let {
|
||||||
Providers.byId(providerId)
|
if (it.id == Providers.DEFAULT_ID) it.copy(url = SkysparkleKey.url(skysparkleKey)) else it
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object {
|
private companion object {
|
||||||
@@ -61,6 +73,8 @@ class Prefs(context: Context) {
|
|||||||
const val KEY_BOOTSTRAP = "custom_bootstrap"
|
const val KEY_BOOTSTRAP = "custom_bootstrap"
|
||||||
const val KEY_HTTP3 = "custom_http3"
|
const val KEY_HTTP3 = "custom_http3"
|
||||||
const val KEY_EXCLUDED = "excluded_apps"
|
const val KEY_EXCLUDED = "excluded_apps"
|
||||||
|
const val KEY_SKYSPARKLE = "skysparkle_key"
|
||||||
|
const val KEY_ONBOARDING = "onboarding_done"
|
||||||
const val KEY_HINTS = "dismissed_hints"
|
const val KEY_HINTS = "dismissed_hints"
|
||||||
const val KEY_PRIVATE_DNS = "dismissed_private_dns"
|
const val KEY_PRIVATE_DNS = "dismissed_private_dns"
|
||||||
const val KEY_UPDATE_INTERVAL = "update_interval"
|
const val KEY_UPDATE_INTERVAL = "update_interval"
|
||||||
|
|||||||
@@ -18,8 +18,9 @@ object Providers {
|
|||||||
|
|
||||||
// Servers ship with the app; new ones arrive with app updates
|
// Servers ship with the app; new ones arrive with app updates
|
||||||
val builtIn = listOf(
|
val builtIn = listOf(
|
||||||
|
// The address is personal: Prefs.resolve() adds the access key from skysparkle.cc
|
||||||
DohProvider(
|
DohProvider(
|
||||||
"skysparkle", "SkySparkle", "https://blog.skysparkle.cc/dns-query",
|
"skysparkle", "SkySparkle", SkysparkleKey.BASE_URL,
|
||||||
http3 = true, policy = "https://skysparkle.cc/privacy?lang=en",
|
http3 = true, policy = "https://skysparkle.cc/privacy?lang=en",
|
||||||
),
|
),
|
||||||
DohProvider(
|
DohProvider(
|
||||||
@@ -44,6 +45,12 @@ object Providers {
|
|||||||
policy = "https://ffmuc.net/dns-privacy/",
|
policy = "https://ffmuc.net/dns-privacy/",
|
||||||
donate = "https://spende.ffmuc.net/",
|
donate = "https://spende.ffmuc.net/",
|
||||||
),
|
),
|
||||||
|
DohProvider(
|
||||||
|
"dnsforge", "dnsforge.de", "https://blank.dnsforge.de/dns-query",
|
||||||
|
listOf("78.47.71.194", "138.199.149.249"),
|
||||||
|
policy = "https://adminforge.de/datenschutz/",
|
||||||
|
donate = "https://adminforge.de/unterstuetzen/",
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
// The project's own server stays the default whatever order the list uses
|
// The project's own server stays the default whatever order the list uses
|
||||||
@@ -52,6 +59,24 @@ object Providers {
|
|||||||
fun byId(id: String): DohProvider = builtIn.firstOrNull { it.id == id } ?: default
|
fun byId(id: String): DohProvider = builtIn.firstOrNull { it.id == id } ?: default
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Personal access keys for the Skysparkle server. Each account at skysparkle.cc creates its own
|
||||||
|
// keys; the server answers only /dns/<key>, there is no shared public address.
|
||||||
|
object SkysparkleKey {
|
||||||
|
const val BASE_URL = "https://skysparkle.cc/dns/"
|
||||||
|
const val SIGNUP_URL = "https://skysparkle.cc/login#register"
|
||||||
|
private val KEY = Regex("^[A-Za-z0-9_-]{24}$")
|
||||||
|
private val IN_URL = Regex("/dns/([A-Za-z0-9_-]{24})(?:[/?#].*)?$")
|
||||||
|
|
||||||
|
// Accepts the key itself or the whole address copied from the account page
|
||||||
|
fun parse(input: String): String? {
|
||||||
|
val text = input.trim()
|
||||||
|
if (KEY.matches(text)) return text
|
||||||
|
return IN_URL.find(text)?.groupValues?.get(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun url(key: String): String = parse(key)?.let { BASE_URL + it } ?: ""
|
||||||
|
}
|
||||||
|
|
||||||
fun parseIps(raw: String): List<String> =
|
fun parseIps(raw: String): List<String> =
|
||||||
raw.split(',', ';', ' ').map { it.trim() }.filter { it.isNotEmpty() }
|
raw.split(',', ';', ' ').map { it.trim() }.filter { it.isNotEmpty() }
|
||||||
|
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ fun SettingsScreen(
|
|||||||
var customUrl by remember { mutableStateOf(prefs.customUrl) }
|
var customUrl by remember { mutableStateOf(prefs.customUrl) }
|
||||||
var customBootstrap by remember { mutableStateOf(prefs.customBootstrap) }
|
var customBootstrap by remember { mutableStateOf(prefs.customBootstrap) }
|
||||||
var customHttp3 by remember { mutableStateOf(prefs.customHttp3) }
|
var customHttp3 by remember { mutableStateOf(prefs.customHttp3) }
|
||||||
|
var keyInput by remember { mutableStateOf(prefs.skysparkleKey) }
|
||||||
var testResult by rememberSaveable(stateSaver = TestResultSaver) { mutableStateOf<TestResult?>(null) }
|
var testResult by rememberSaveable(stateSaver = TestResultSaver) { mutableStateOf<TestResult?>(null) }
|
||||||
var shownResult by rememberSaveable(stateSaver = TestResultSaver) { mutableStateOf<TestResult?>(null) } // kept while the card animates out
|
var shownResult by rememberSaveable(stateSaver = TestResultSaver) { mutableStateOf<TestResult?>(null) } // kept while the card animates out
|
||||||
var testing by remember { mutableStateOf(false) }
|
var testing by remember { mutableStateOf(false) }
|
||||||
@@ -78,8 +79,9 @@ fun SettingsScreen(
|
|||||||
|
|
||||||
val isCustom = selected == Providers.CUSTOM_ID
|
val isCustom = selected == Providers.CUSTOM_ID
|
||||||
val customValid = remember(customUrl) { customUrl.trim().toHttpUrlOrNull()?.isHttps == true }
|
val customValid = remember(customUrl) { customUrl.trim().toHttpUrlOrNull()?.isHttps == true }
|
||||||
val canConnect = !isCustom || customValid
|
val keyValid = remember(keyInput) { SkysparkleKey.parse(keyInput) != null }
|
||||||
val selectedProvider = remember(selected, customUrl, customBootstrap, customHttp3) { prefs.resolve() }
|
val selectedProvider = remember(selected, customUrl, customBootstrap, customHttp3, keyInput) { prefs.resolve() }
|
||||||
|
val canConnect = selectedProvider.url.toHttpUrlOrNull()?.isHttps == true
|
||||||
|
|
||||||
// Picking a server never touches a live connection; switching is an explicit action
|
// Picking a server never touches a live connection; switching is an explicit action
|
||||||
val pendingSwitch = active?.let { it != selectedProvider && canConnect } == true
|
val pendingSwitch = active?.let { it != selectedProvider && canConnect } == true
|
||||||
@@ -123,6 +125,21 @@ fun SettingsScreen(
|
|||||||
onDonate = provider.donate?.let { url -> { openUrl(context, url) } },
|
onDonate = provider.donate?.let { url -> { openUrl(context, url) } },
|
||||||
onClick = { select(provider.id) },
|
onClick = { select(provider.id) },
|
||||||
)
|
)
|
||||||
|
if (provider.id == Providers.DEFAULT_ID) {
|
||||||
|
AnimatedVisibility(visible = selected == Providers.DEFAULT_ID, enter = Motion.expandIn, exit = Motion.collapseOut) {
|
||||||
|
KeyField(
|
||||||
|
value = keyInput,
|
||||||
|
valid = keyValid,
|
||||||
|
onChange = {
|
||||||
|
keyInput = it
|
||||||
|
// Saved as the bare key, also when the whole address was pasted
|
||||||
|
prefs.skysparkleKey = SkysparkleKey.parse(it) ?: it.trim()
|
||||||
|
testResult = null
|
||||||
|
},
|
||||||
|
onGetKey = { openUrl(context, SkysparkleKey.SIGNUP_URL) },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ListDivider()
|
ListDivider()
|
||||||
ServerRow(
|
ServerRow(
|
||||||
@@ -252,6 +269,35 @@ fun SettingsScreen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Access key for the Skysparkle server, with a link to the account page where keys are made
|
||||||
|
@Composable
|
||||||
|
internal fun KeyField(value: String, valid: Boolean, onChange: (String) -> Unit, onGetKey: () -> Unit, modifier: Modifier = Modifier) {
|
||||||
|
val showError = value.isNotBlank() && !valid
|
||||||
|
Column(
|
||||||
|
modifier.padding(start = 16.dp, end = 16.dp, bottom = 16.dp),
|
||||||
|
verticalArrangement = Arrangement.spacedBy(6.dp),
|
||||||
|
) {
|
||||||
|
OutlinedTextField(
|
||||||
|
value = value,
|
||||||
|
onValueChange = onChange,
|
||||||
|
label = { Text(stringResource(R.string.key_label)) },
|
||||||
|
singleLine = true,
|
||||||
|
isError = showError,
|
||||||
|
shape = RoundedCornerShape(14.dp),
|
||||||
|
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Uri, imeAction = ImeAction.Done),
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
stringResource(if (showError) R.string.key_invalid else R.string.key_hint),
|
||||||
|
color = if (showError) Palette.Blocked else Palette.Fg3,
|
||||||
|
fontSize = 12.sp,
|
||||||
|
)
|
||||||
|
OutlinedButton(onClick = onGetKey, shape = RoundedCornerShape(14.dp)) {
|
||||||
|
Text(stringResource(R.string.key_get))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun ServerRow(
|
private fun ServerRow(
|
||||||
title: String,
|
title: String,
|
||||||
|
|||||||
@@ -131,4 +131,31 @@
|
|||||||
<string name="turn_on">Einschalten</string>
|
<string name="turn_on">Einschalten</string>
|
||||||
<string name="downloading">Wird geladen…</string>
|
<string name="downloading">Wird geladen…</string>
|
||||||
<string name="change_server">Server wechseln</string>
|
<string name="change_server">Server wechseln</string>
|
||||||
|
<string name="alert_channel">Schutzwarnungen</string>
|
||||||
|
<string name="alert_stopped_title">DNS-Schutz beendet</string>
|
||||||
|
<string name="alert_stopped_text">Der Tunnel funktioniert nicht mehr, DNS ist nicht mehr verschlüsselt. Öffne SparkleDNS, um dich erneut zu verbinden.</string>
|
||||||
|
<string name="alert_bad_url_title">DNS-Schutz nicht gestartet</string>
|
||||||
|
<string name="alert_bad_url_text">Die Serveradresse ist keine gültige HTTPS-URL. Öffne SparkleDNS und prüfe den Server.</string>
|
||||||
|
<string name="alert_lockdown_title">DNS-Server nicht erreichbar</string>
|
||||||
|
<string name="alert_lockdown_text">„Verbindungen ohne VPN blockieren“ ist aktiv, daher erreicht SparkleDNS den DNS-Server nicht und Anfragen schlagen fehl. Schalte es in den VPN-Einstellungen von Android aus.</string>
|
||||||
|
<string name="key_label">Zugangsschlüssel</string>
|
||||||
|
<string name="key_hint">Füge den Schlüssel oder die ganze Adresse aus deinem Konto auf skysparkle.cc ein</string>
|
||||||
|
<string name="key_invalid">Das sieht nicht wie ein Schlüssel aus. Kopiere ihn erneut auf der Seite „Schlüssel“.</string>
|
||||||
|
<string name="key_get">Kostenlosen Schlüssel holen</string>
|
||||||
|
<string name="key_needed">Der SkySparkle-Server braucht einen persönlichen Zugangsschlüssel. Er ist kostenlos: Erstelle ein Konto auf skysparkle.cc und füge den Schlüssel hinzu.</string>
|
||||||
|
<string name="key_add">Schlüssel hinzufügen</string>
|
||||||
|
<string name="alert_no_key_text">Der SkySparkle-Server braucht einen Zugangsschlüssel. Öffne SparkleDNS und füge deinen Schlüssel unter Einstellungen hinzu.</string>
|
||||||
|
<string name="onb_welcome_title">Willkommen bei SparkleDNS</string>
|
||||||
|
<string name="onb_welcome_text">Privates DNS für dein ganzes Handy, ohne Server der großen Tech-Konzerne.</string>
|
||||||
|
<string name="onb_point_encrypt">Verschlüsselt jede DNS-Anfrage mit DNS-over-HTTPS</string>
|
||||||
|
<string name="onb_point_block">Blockiert Werbung und Tracker in allen Apps</string>
|
||||||
|
<string name="onb_point_independent">Nur unabhängige Server, nie Google oder Cloudflare</string>
|
||||||
|
<string name="onb_key_title">Hol dir deinen Zugangsschlüssel</string>
|
||||||
|
<string name="onb_key_text">Der SkySparkle-Server arbeitet mit einem persönlichen Schlüssel. Der kostenlose Tarif hat Grenzen, die bezahlten nicht.</string>
|
||||||
|
<string name="onb_key_step1">Erstelle ein kostenloses Konto auf skysparkle.cc</string>
|
||||||
|
<string name="onb_key_step2">Öffne „Schlüssel“ und erstelle einen Schlüssel für dieses Handy</string>
|
||||||
|
<string name="onb_key_step3">Kopiere den Schlüssel oder die Adresse und füge sie unten ein</string>
|
||||||
|
<string name="onb_next">Weiter</string>
|
||||||
|
<string name="onb_done">Starten</string>
|
||||||
|
<string name="onb_skip">Überspringen, ich wähle einen anderen Server</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -131,4 +131,31 @@
|
|||||||
<string name="turn_on">オンにする</string>
|
<string name="turn_on">オンにする</string>
|
||||||
<string name="downloading">ダウンロード中…</string>
|
<string name="downloading">ダウンロード中…</string>
|
||||||
<string name="change_server">サーバーを変更</string>
|
<string name="change_server">サーバーを変更</string>
|
||||||
|
<string name="alert_channel">保護に関する警告</string>
|
||||||
|
<string name="alert_stopped_title">DNS 保護が停止しました</string>
|
||||||
|
<string name="alert_stopped_text">トンネルが動作しなくなったため、DNS は暗号化されていません。SparkleDNS を開いて再接続してください。</string>
|
||||||
|
<string name="alert_bad_url_title">DNS 保護を開始できません</string>
|
||||||
|
<string name="alert_bad_url_text">サーバーのアドレスが有効な HTTPS URL ではありません。SparkleDNS を開いてサーバーを確認してください。</string>
|
||||||
|
<string name="alert_lockdown_title">DNS サーバーに接続できません</string>
|
||||||
|
<string name="alert_lockdown_text">「VPN なしの接続をブロック」がオンのため、SparkleDNS は DNS サーバーに接続できず、名前解決に失敗します。Android の VPN 設定でオフにしてください。</string>
|
||||||
|
<string name="key_label">アクセスキー</string>
|
||||||
|
<string name="key_hint">skysparkle.cc のアカウントからキーまたはアドレス全体を貼り付けてください</string>
|
||||||
|
<string name="key_invalid">キーの形式ではありません。「キー」ページからもう一度コピーしてください。</string>
|
||||||
|
<string name="key_get">無料のキーを取得</string>
|
||||||
|
<string name="key_needed">SkySparkle サーバーには個人用のアクセスキーが必要です。無料です:skysparkle.cc でアカウントを作成してキーを追加してください。</string>
|
||||||
|
<string name="key_add">キーを追加</string>
|
||||||
|
<string name="alert_no_key_text">SkySparkle サーバーにはアクセスキーが必要です。SparkleDNS を開いて「設定」でキーを追加してください。</string>
|
||||||
|
<string name="onb_welcome_title">SparkleDNS へようこそ</string>
|
||||||
|
<string name="onb_welcome_text">大手 IT 企業のサーバーを使わない、スマホ全体のプライベート DNS。</string>
|
||||||
|
<string name="onb_point_encrypt">DNS-over-HTTPS ですべての DNS 問い合わせを暗号化</string>
|
||||||
|
<string name="onb_point_block">すべてのアプリで広告とトラッカーをブロック</string>
|
||||||
|
<string name="onb_point_independent">独立系サーバーのみ。Google や Cloudflare は使いません</string>
|
||||||
|
<string name="onb_key_title">アクセスキーを取得</string>
|
||||||
|
<string name="onb_key_text">SkySparkle サーバーは個人用キーで動作します。無料プランには制限があり、有料プランにはありません。</string>
|
||||||
|
<string name="onb_key_step1">skysparkle.cc で無料アカウントを作成</string>
|
||||||
|
<string name="onb_key_step2">「キー」を開き、このスマホ用のキーを作成</string>
|
||||||
|
<string name="onb_key_step3">キーまたはアドレスをコピーして下に貼り付け</string>
|
||||||
|
<string name="onb_next">次へ</string>
|
||||||
|
<string name="onb_done">開始</string>
|
||||||
|
<string name="onb_skip">スキップして別のサーバーを選ぶ</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -131,4 +131,31 @@
|
|||||||
<string name="turn_on">Įjungti</string>
|
<string name="turn_on">Įjungti</string>
|
||||||
<string name="downloading">Atsisiunčiama…</string>
|
<string name="downloading">Atsisiunčiama…</string>
|
||||||
<string name="change_server">Keisti serverį</string>
|
<string name="change_server">Keisti serverį</string>
|
||||||
|
<string name="alert_channel">Apsaugos įspėjimai</string>
|
||||||
|
<string name="alert_stopped_title">DNS apsauga išjungta</string>
|
||||||
|
<string name="alert_stopped_text">Tunelis nustojo veikti, DNS nebešifruojamas. Atidarykite SparkleDNS, kad prisijungtumėte iš naujo.</string>
|
||||||
|
<string name="alert_bad_url_title">DNS apsauga nepaleista</string>
|
||||||
|
<string name="alert_bad_url_text">Serverio adresas nėra tinkamas HTTPS adresas. Atidarykite SparkleDNS ir patikrinkite serverį.</string>
|
||||||
|
<string name="alert_lockdown_title">DNS serveris nepasiekiamas</string>
|
||||||
|
<string name="alert_lockdown_text">Įjungta „Blokuoti ryšius be VPN“, todėl SparkleDNS negali pasiekti DNS serverio ir užklausos nepavyksta. Išjunkite tai Android VPN nustatymuose.</string>
|
||||||
|
<string name="key_label">Prieigos raktas</string>
|
||||||
|
<string name="key_hint">Įklijuokite raktą arba visą adresą iš savo paskyros skysparkle.cc</string>
|
||||||
|
<string name="key_invalid">Tai nepanašu į raktą. Nukopijuokite jį dar kartą puslapyje „Raktai“.</string>
|
||||||
|
<string name="key_get">Gauti nemokamą raktą</string>
|
||||||
|
<string name="key_needed">SkySparkle serveriui reikia asmeninio prieigos rakto. Tai nemokama: susikurkite paskyrą skysparkle.cc ir pridėkite raktą.</string>
|
||||||
|
<string name="key_add">Pridėti raktą</string>
|
||||||
|
<string name="alert_no_key_text">SkySparkle serveriui reikia prieigos rakto. Atidarykite SparkleDNS ir pridėkite raktą skiltyje „Nustatymai“.</string>
|
||||||
|
<string name="onb_welcome_title">Sveiki atvykę į SparkleDNS</string>
|
||||||
|
<string name="onb_welcome_text">Privatus DNS visam telefonui, be didžiųjų technologijų įmonių serverių.</string>
|
||||||
|
<string name="onb_point_encrypt">Šifruoja kiekvieną DNS užklausą per DNS-over-HTTPS</string>
|
||||||
|
<string name="onb_point_block">Blokuoja reklamas ir sekiklius visose programėlėse</string>
|
||||||
|
<string name="onb_point_independent">Tik nepriklausomi serveriai, jokio Google ar Cloudflare</string>
|
||||||
|
<string name="onb_key_title">Gaukite prieigos raktą</string>
|
||||||
|
<string name="onb_key_text">SkySparkle serveris veikia su asmeniniu raktu. Nemokamas planas turi apribojimų, mokami – ne.</string>
|
||||||
|
<string name="onb_key_step1">Susikurkite nemokamą paskyrą skysparkle.cc</string>
|
||||||
|
<string name="onb_key_step2">Atidarykite „Raktai“ ir sukurkite raktą šiam telefonui</string>
|
||||||
|
<string name="onb_key_step3">Nukopijuokite raktą arba adresą ir įklijuokite žemiau</string>
|
||||||
|
<string name="onb_next">Toliau</string>
|
||||||
|
<string name="onb_done">Pradėti</string>
|
||||||
|
<string name="onb_skip">Praleisti, pasirinksiu kitą serverį</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -131,4 +131,31 @@
|
|||||||
<string name="turn_on">Включить</string>
|
<string name="turn_on">Включить</string>
|
||||||
<string name="downloading">Загрузка…</string>
|
<string name="downloading">Загрузка…</string>
|
||||||
<string name="change_server">Сменить сервер</string>
|
<string name="change_server">Сменить сервер</string>
|
||||||
|
<string name="alert_channel">Предупреждения о защите</string>
|
||||||
|
<string name="alert_stopped_title">Защита DNS отключена</string>
|
||||||
|
<string name="alert_stopped_text">Туннель перестал работать, DNS больше не шифруется. Откройте SparkleDNS, чтобы подключиться снова.</string>
|
||||||
|
<string name="alert_bad_url_title">Защита DNS не запущена</string>
|
||||||
|
<string name="alert_bad_url_text">Адрес сервера не является корректным HTTPS-адресом. Откройте SparkleDNS и проверьте сервер.</string>
|
||||||
|
<string name="alert_lockdown_title">DNS-сервер недоступен</string>
|
||||||
|
<string name="alert_lockdown_text">Включено «Блокировать соединения без VPN», поэтому SparkleDNS не может связаться с DNS-сервером и запросы не проходят. Отключите это в настройках VPN Android.</string>
|
||||||
|
<string name="key_label">Ключ доступа</string>
|
||||||
|
<string name="key_hint">Вставьте ключ или весь адрес из аккаунта на skysparkle.cc</string>
|
||||||
|
<string name="key_invalid">Это не похоже на ключ. Скопируйте его ещё раз на странице «Ключи».</string>
|
||||||
|
<string name="key_get">Получить бесплатный ключ</string>
|
||||||
|
<string name="key_needed">Серверу SkySparkle нужен личный ключ доступа. Это бесплатно: создайте аккаунт на skysparkle.cc и добавьте ключ.</string>
|
||||||
|
<string name="key_add">Добавить ключ</string>
|
||||||
|
<string name="alert_no_key_text">Серверу SkySparkle нужен ключ доступа. Откройте SparkleDNS и добавьте ключ в разделе «Настройки».</string>
|
||||||
|
<string name="onb_welcome_title">Добро пожаловать в SparkleDNS</string>
|
||||||
|
<string name="onb_welcome_text">Приватный DNS для всего телефона, без серверов крупных корпораций.</string>
|
||||||
|
<string name="onb_point_encrypt">Шифрует каждый DNS-запрос через DNS-over-HTTPS</string>
|
||||||
|
<string name="onb_point_block">Блокирует рекламу и трекеры во всех приложениях</string>
|
||||||
|
<string name="onb_point_independent">Только независимые серверы, без Google и Cloudflare</string>
|
||||||
|
<string name="onb_key_title">Получите ключ доступа</string>
|
||||||
|
<string name="onb_key_text">Сервер SkySparkle работает по личному ключу. У бесплатного тарифа есть ограничения, у платных — нет.</string>
|
||||||
|
<string name="onb_key_step1">Создайте бесплатный аккаунт на skysparkle.cc</string>
|
||||||
|
<string name="onb_key_step2">Откройте «Ключи» и создайте ключ для этого телефона</string>
|
||||||
|
<string name="onb_key_step3">Скопируйте ключ или адрес и вставьте ниже</string>
|
||||||
|
<string name="onb_next">Далее</string>
|
||||||
|
<string name="onb_done">Начать</string>
|
||||||
|
<string name="onb_skip">Пропустить, выберу другой сервер</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -131,4 +131,31 @@
|
|||||||
<string name="turn_on">开启</string>
|
<string name="turn_on">开启</string>
|
||||||
<string name="downloading">正在下载…</string>
|
<string name="downloading">正在下载…</string>
|
||||||
<string name="change_server">更换服务器</string>
|
<string name="change_server">更换服务器</string>
|
||||||
|
<string name="alert_channel">保护警告</string>
|
||||||
|
<string name="alert_stopped_title">DNS 保护已停止</string>
|
||||||
|
<string name="alert_stopped_text">隧道已停止工作,DNS 不再加密。请打开 SparkleDNS 重新连接。</string>
|
||||||
|
<string name="alert_bad_url_title">DNS 保护未启动</string>
|
||||||
|
<string name="alert_bad_url_text">服务器地址不是有效的 HTTPS 网址。请打开 SparkleDNS 检查服务器。</string>
|
||||||
|
<string name="alert_lockdown_title">无法连接 DNS 服务器</string>
|
||||||
|
<string name="alert_lockdown_text">已开启“屏蔽未使用 VPN 的连接”,SparkleDNS 无法连接 DNS 服务器,解析会失败。请在 Android 的 VPN 设置中关闭该选项。</string>
|
||||||
|
<string name="key_label">访问密钥</string>
|
||||||
|
<string name="key_hint">粘贴 skysparkle.cc 账户中的密钥或完整地址</string>
|
||||||
|
<string name="key_invalid">这看起来不像密钥。请在“密钥”页面重新复制。</string>
|
||||||
|
<string name="key_get">获取免费密钥</string>
|
||||||
|
<string name="key_needed">SkySparkle 服务器需要个人访问密钥。完全免费:在 skysparkle.cc 创建账户并添加密钥。</string>
|
||||||
|
<string name="key_add">添加密钥</string>
|
||||||
|
<string name="alert_no_key_text">SkySparkle 服务器需要访问密钥。请打开 SparkleDNS,在“设置”中添加密钥。</string>
|
||||||
|
<string name="onb_welcome_title">欢迎使用 SparkleDNS</string>
|
||||||
|
<string name="onb_welcome_text">为整部手机提供私密 DNS,不使用大型科技公司的服务器。</string>
|
||||||
|
<string name="onb_point_encrypt">通过 DNS-over-HTTPS 加密每一次 DNS 查询</string>
|
||||||
|
<string name="onb_point_block">在所有应用中拦截广告和跟踪器</string>
|
||||||
|
<string name="onb_point_independent">只使用独立服务器,不用 Google 或 Cloudflare</string>
|
||||||
|
<string name="onb_key_title">获取访问密钥</string>
|
||||||
|
<string name="onb_key_text">SkySparkle 服务器使用个人密钥。免费套餐有限制,付费套餐没有。</string>
|
||||||
|
<string name="onb_key_step1">在 skysparkle.cc 创建免费账户</string>
|
||||||
|
<string name="onb_key_step2">打开“密钥”,为这部手机创建密钥</string>
|
||||||
|
<string name="onb_key_step3">复制密钥或地址,粘贴到下方</string>
|
||||||
|
<string name="onb_next">下一步</string>
|
||||||
|
<string name="onb_done">开始</string>
|
||||||
|
<string name="onb_skip">跳过,我选择其他服务器</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -132,4 +132,31 @@
|
|||||||
<string name="turn_on">Turn on</string>
|
<string name="turn_on">Turn on</string>
|
||||||
<string name="downloading">Downloading…</string>
|
<string name="downloading">Downloading…</string>
|
||||||
<string name="change_server">Change server</string>
|
<string name="change_server">Change server</string>
|
||||||
|
<string name="alert_channel">Protection alerts</string>
|
||||||
|
<string name="alert_stopped_title">DNS protection stopped</string>
|
||||||
|
<string name="alert_stopped_text">The tunnel stopped working, so DNS is no longer encrypted. Open SparkleDNS to connect again.</string>
|
||||||
|
<string name="alert_bad_url_title">DNS protection not started</string>
|
||||||
|
<string name="alert_bad_url_text">The server address is not a valid HTTPS URL. Open SparkleDNS and check the server.</string>
|
||||||
|
<string name="alert_lockdown_title">DNS server unreachable</string>
|
||||||
|
<string name="alert_lockdown_text">\"Block connections without VPN\" is on, so SparkleDNS cannot reach the DNS server and lookups fail. Turn it off in Android VPN settings.</string>
|
||||||
|
<string name="key_label">Access key</string>
|
||||||
|
<string name="key_hint">Paste the key or the whole address from your account at skysparkle.cc</string>
|
||||||
|
<string name="key_invalid">This doesn\'t look like a key. Copy it again from the Keys page.</string>
|
||||||
|
<string name="key_get">Get a free key</string>
|
||||||
|
<string name="key_needed">The SkySparkle server needs a personal access key. It is free: create an account at skysparkle.cc and add the key.</string>
|
||||||
|
<string name="key_add">Add key</string>
|
||||||
|
<string name="alert_no_key_text">The SkySparkle server needs an access key. Open SparkleDNS and add your key in Settings.</string>
|
||||||
|
<string name="onb_welcome_title">Welcome to SparkleDNS</string>
|
||||||
|
<string name="onb_welcome_text">Private DNS for your whole phone, without big-tech servers.</string>
|
||||||
|
<string name="onb_point_encrypt">Encrypts every DNS lookup with DNS-over-HTTPS</string>
|
||||||
|
<string name="onb_point_block">Blocks ads and trackers in all apps</string>
|
||||||
|
<string name="onb_point_independent">Uses only independent servers, never Google or Cloudflare</string>
|
||||||
|
<string name="onb_key_title">Get your access key</string>
|
||||||
|
<string name="onb_key_text">The SkySparkle server works with a personal key. The free plan has limits; paid plans have none.</string>
|
||||||
|
<string name="onb_key_step1">Create a free account at skysparkle.cc</string>
|
||||||
|
<string name="onb_key_step2">Open Keys and create a key for this phone</string>
|
||||||
|
<string name="onb_key_step3">Copy the key or the address and paste it below</string>
|
||||||
|
<string name="onb_next">Next</string>
|
||||||
|
<string name="onb_done">Start</string>
|
||||||
|
<string name="onb_skip">Skip, I\'ll choose another server</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<data-extraction-rules>
|
||||||
|
<cloud-backup>
|
||||||
|
<exclude domain="root" />
|
||||||
|
<exclude domain="database" />
|
||||||
|
<exclude domain="sharedpref" />
|
||||||
|
<exclude domain="file" />
|
||||||
|
</cloud-backup>
|
||||||
|
<device-transfer>
|
||||||
|
<exclude domain="root" />
|
||||||
|
<exclude domain="database" />
|
||||||
|
<exclude domain="sharedpref" />
|
||||||
|
<exclude domain="file" />
|
||||||
|
</device-transfer>
|
||||||
|
</data-extraction-rules>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<locale-config xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<locale android:name="en" />
|
||||||
|
<locale android:name="de" />
|
||||||
|
<locale android:name="ja" />
|
||||||
|
<locale android:name="lt" />
|
||||||
|
<locale android:name="ru" />
|
||||||
|
<locale android:name="zh" />
|
||||||
|
</locale-config>
|
||||||
@@ -5,14 +5,17 @@ import org.junit.Assert.assertEquals
|
|||||||
import org.junit.Assert.assertFalse
|
import org.junit.Assert.assertFalse
|
||||||
import org.junit.Assert.assertTrue
|
import org.junit.Assert.assertTrue
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
import java.nio.LongBuffer
|
||||||
|
|
||||||
class BlocklistMatchTest {
|
class BlocklistMatchTest {
|
||||||
|
|
||||||
private fun set(vararg domains: String) = domains.map { DomainHash.of(it) }.sorted().toLongArray()
|
private fun set(vararg domains: String) = domains.map { DomainHash.of(it) }.sorted().toLongArray()
|
||||||
|
private fun buf(vararg domains: String) = LongBuffer.wrap(set(*domains))
|
||||||
|
private fun buf(values: LongArray) = LongBuffer.wrap(values)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun blocksDomainsAndTheirSubdomains() {
|
fun blocksDomainsAndTheirSubdomains() {
|
||||||
val lists = set("ads.example.com")
|
val lists = buf("ads.example.com")
|
||||||
val custom = set("tracker.net")
|
val custom = set("tracker.net")
|
||||||
|
|
||||||
assertTrue(isBlockedIn("ads.example.com", lists, custom))
|
assertTrue(isBlockedIn("ads.example.com", lists, custom))
|
||||||
@@ -21,12 +24,12 @@ class BlocklistMatchTest {
|
|||||||
assertFalse(isBlockedIn("example.com", lists, custom))
|
assertFalse(isBlockedIn("example.com", lists, custom))
|
||||||
assertFalse(isBlockedIn("badads.example.com", lists, custom))
|
assertFalse(isBlockedIn("badads.example.com", lists, custom))
|
||||||
assertFalse(isBlockedIn("tracker.network", lists, custom))
|
assertFalse(isBlockedIn("tracker.network", lists, custom))
|
||||||
assertFalse(isBlockedIn("ads.example.com", LongArray(0), LongArray(0)))
|
assertFalse(isBlockedIn("ads.example.com", EMPTY_SET, LongArray(0)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun skipsTrailingDots() {
|
fun skipsTrailingDots() {
|
||||||
val lists = set("example.com")
|
val lists = buf("example.com")
|
||||||
|
|
||||||
assertTrue(isBlockedIn("www.example.com..", lists, LongArray(0)))
|
assertTrue(isBlockedIn("www.example.com..", lists, LongArray(0)))
|
||||||
assertFalse(isBlockedIn("example.org.", lists, LongArray(0)))
|
assertFalse(isBlockedIn("example.org.", lists, LongArray(0)))
|
||||||
@@ -51,8 +54,28 @@ class BlocklistMatchTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun countsEntriesInBothSetsOnce() {
|
fun countsEntriesInBothSetsOnce() {
|
||||||
assertEquals(5, unionSize(longArrayOf(1, 2, 3, 4), longArrayOf(2, 5)))
|
assertEquals(5, unionSize(buf(longArrayOf(1, 2, 3, 4)), longArrayOf(2, 5)))
|
||||||
assertEquals(2, unionSize(LongArray(0), longArrayOf(2, 5)))
|
assertEquals(2, unionSize(EMPTY_SET, longArrayOf(2, 5)))
|
||||||
assertEquals(4, unionSize(longArrayOf(1, 2, 3, 4), LongArray(0)))
|
assertEquals(4, unionSize(buf(longArrayOf(1, 2, 3, 4)), LongArray(0)))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun streamsMergedValuesInOrderOnce() {
|
||||||
|
val out = ArrayList<Long>()
|
||||||
|
val count = mergeSortedInto(
|
||||||
|
listOf(buf(longArrayOf(-5, 1, 4, 9)), buf(longArrayOf(1, 2, 9, 12)), EMPTY_SET, buf(longArrayOf(12, 40)))
|
||||||
|
) { out.add(it) }
|
||||||
|
|
||||||
|
assertEquals(listOf(-5L, 1, 2, 4, 9, 12, 40), out)
|
||||||
|
assertEquals(7, count)
|
||||||
|
assertEquals(0, mergeSortedInto(emptyList()) { out.add(it) })
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun findsValuesInSortedBuffer() {
|
||||||
|
val values = buf(longArrayOf(Long.MIN_VALUE, -3, 0, 7, Long.MAX_VALUE))
|
||||||
|
listOf(Long.MIN_VALUE, -3L, 0L, 7L, Long.MAX_VALUE).forEach { assertTrue(values.containsSorted(it)) }
|
||||||
|
listOf(-4L, 1L, 8L).forEach { assertFalse(values.containsSorted(it)) }
|
||||||
|
assertFalse(EMPTY_SET.containsSorted(0))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package cc.skysparkle.sparkledns
|
package cc.skysparkle.sparkledns
|
||||||
|
|
||||||
|
import okio.Buffer
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Assert.assertNull
|
import org.junit.Assert.assertNull
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
@@ -51,4 +52,22 @@ class BlocklistParserTest {
|
|||||||
assertEquals(DomainHash.of(name), DomainHash.of(name, 0))
|
assertEquals(DomainHash.of(name), DomainHash.of(name, 0))
|
||||||
assertEquals(DomainHash.of("b.example"), DomainHash.of(name, 2, name.indexOf(".com")))
|
assertEquals(DomainHash.of("b.example"), DomainHash.of(name, 2, name.indexOf(".com")))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun rulesWithAPathAreSkippedNotTurnedIntoTheWholeDomain() {
|
||||||
|
assertNull(BlocklistParser.parseLine("||example.com/ads/"))
|
||||||
|
assertNull(BlocklistParser.parseLine("|http://example.com/x|"))
|
||||||
|
assertNull(BlocklistParser.parseLine("https://example.com/banner.js"))
|
||||||
|
assertEquals("example.com", BlocklistParser.parseLine("||example.com/^"))
|
||||||
|
assertEquals("example.com", BlocklistParser.parseLine("https://example.com/"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun overlongLinesAreSkippedAndTheRestIsRead() {
|
||||||
|
val long = "x".repeat(BlocklistParser.MAX_LINE_BYTES.toInt() * 3)
|
||||||
|
val source = Buffer().writeUtf8("a.example\r\n$long\nb.example\nc.example")
|
||||||
|
val lines = mutableListOf<String>()
|
||||||
|
BlocklistParser.readLimitedLines(source) { lines += it.trim() }
|
||||||
|
assertEquals(listOf("a.example", "b.example", "c.example"), lines)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 519 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 391 KiB |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect width="100" height="100" rx="22" fill="#09090a"/><g transform="translate(7 7) scale(.86)" fill="#ededea"><path d="M51.70 6.81 L64.50 35.50 L93.19 48.30 L59.30 48.30 L51.70 40.70 Z"/><path transform="rotate(90 50 50)" d="M51.70 6.81 L64.50 35.50 L93.19 48.30 L59.30 48.30 L51.70 40.70 Z"/><path transform="rotate(180 50 50)" d="M51.70 6.81 L64.50 35.50 L93.19 48.30 L59.30 48.30 L51.70 40.70 Z"/><path transform="rotate(270 50 50)" d="M51.70 6.81 L64.50 35.50 L93.19 48.30 L59.30 48.30 L51.70 40.70 Z"/></g></svg>
|
||||||
|
After Width: | Height: | Size: 581 B |
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("com.android.application") version "9.2.1" apply false
|
alias(libs.plugins.android.application) apply false
|
||||||
// Not applied to modules: only pins the Kotlin version used by AGP's built-in Kotlin
|
// Not applied to modules: only pins the Kotlin version used by AGP's built-in Kotlin
|
||||||
id("org.jetbrains.kotlin.android") version "2.4.0" apply false
|
alias(libs.plugins.kotlin.android) apply false
|
||||||
id("org.jetbrains.kotlin.plugin.compose") version "2.4.0" apply false
|
alias(libs.plugins.kotlin.compose) apply false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
• Eine Benachrichtigung meldet, wenn der Schutz endet, die Serveradresse ungültig ist oder „Verbindungen ohne VPN blockieren“ den Server unerreichbar macht
|
||||||
|
• Bootstrap-Adressen funktionieren jetzt auch über HTTP/3
|
||||||
|
• Blocklistenregeln mit Pfad sperren nicht mehr ganze Websites
|
||||||
|
• Ausschalten über die Schnelleinstellung nur bei entsperrtem Handy
|
||||||
|
• App-Sprache in den Android-Einstellungen wählbar
|
||||||
|
• Aktualisierte Bibliotheken
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
• Der SkySparkle-Server nutzt jetzt die Adresse skysparkle.cc/dns-query
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
• A notification tells you when protection stops, when the server address is invalid or when "Block connections without VPN" keeps the server unreachable
|
||||||
|
• Bootstrap addresses now also work over HTTP/3
|
||||||
|
• Blocklist rules with a path no longer block whole sites
|
||||||
|
• Turning protection off from the quick settings tile needs an unlocked phone
|
||||||
|
• App language can be set in Android settings
|
||||||
|
• Updated libraries
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
• The SkySparkle server now uses the address skysparkle.cc/dns-query
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 519 KiB After Width: | Height: | Size: 391 KiB |
@@ -0,0 +1,6 @@
|
|||||||
|
• 保護が停止したとき、サーバーのアドレスが無効なとき、「VPN なしの接続をブロック」でサーバーに届かないときに通知
|
||||||
|
• Bootstrap アドレスが HTTP/3 でも使えるように
|
||||||
|
• パス付きのブロックリストのルールでサイト全体がブロックされなくなりました
|
||||||
|
• クイック設定タイルから保護をオフにするにはロック解除が必要に
|
||||||
|
• Android の設定でアプリの言語を選択可能に
|
||||||
|
• ライブラリを更新
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
• SkySparkle サーバーのアドレスが skysparkle.cc/dns-query に変わりました
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
• Pranešimas, kai apsauga išsijungia, serverio adresas netinkamas arba „Blokuoti ryšius be VPN“ neleidžia pasiekti serverio
|
||||||
|
• Bootstrap adresai dabar veikia ir per HTTP/3
|
||||||
|
• Blokavimo sąrašų taisyklės su keliu nebeblokuoja visų svetainių
|
||||||
|
• Išjungti apsaugą iš sparčiųjų nustatymų galima tik atrakinus telefoną
|
||||||
|
• Programėlės kalbą galima pasirinkti Android nustatymuose
|
||||||
|
• Atnaujintos bibliotekos
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
• SkySparkle serveris dabar naudoja adresą skysparkle.cc/dns-query
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
• Уведомление, если защита отключилась, адрес сервера неверный или «Блокировать соединения без VPN» не пускает к серверу
|
||||||
|
• Bootstrap-адреса теперь работают и по HTTP/3
|
||||||
|
• Правила блоклистов с путём больше не блокируют сайты целиком
|
||||||
|
• Выключить защиту с плитки можно только на разблокированном телефоне
|
||||||
|
• Язык приложения можно выбрать в настройках Android
|
||||||
|
• Обновлены библиотеки
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
• Сервер SkySparkle теперь работает по адресу skysparkle.cc/dns-query
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
• 保护停止、服务器地址无效或“屏蔽未使用 VPN 的连接”导致无法连接服务器时会发出通知
|
||||||
|
• Bootstrap 地址现在也适用于 HTTP/3
|
||||||
|
• 带路径的拦截列表规则不再拦截整个网站
|
||||||
|
• 从快捷设置磁贴关闭保护需要先解锁手机
|
||||||
|
• 可在 Android 设置中选择应用语言
|
||||||
|
• 更新了依赖库
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
• SkySparkle 服务器地址已更改为 skysparkle.cc/dns-query
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
[versions]
|
||||||
|
agp = "9.2.1"
|
||||||
|
kotlin = "2.4.20"
|
||||||
|
composeBom = "2026.09.00"
|
||||||
|
activityCompose = "1.13.0"
|
||||||
|
lifecycleRuntimeCompose = "2.11.0"
|
||||||
|
kotlinxCoroutines = "1.11.0"
|
||||||
|
okhttp = "5.4.0"
|
||||||
|
leakcanary = "2.14"
|
||||||
|
junit = "4.13.2"
|
||||||
|
|
||||||
|
[libraries]
|
||||||
|
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
|
||||||
|
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
|
||||||
|
androidx-compose-ui = { group = "androidx.compose.ui", name = "ui" }
|
||||||
|
androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3" }
|
||||||
|
androidx-lifecycle-runtime-compose = { group = "androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "lifecycleRuntimeCompose" }
|
||||||
|
kotlinx-coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "kotlinxCoroutines" }
|
||||||
|
okhttp = { group = "com.squareup.okhttp3", name = "okhttp", version.ref = "okhttp" }
|
||||||
|
leakcanary-android = { group = "com.squareup.leakcanary", name = "leakcanary-android", version.ref = "leakcanary" }
|
||||||
|
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
||||||
|
|
||||||
|
[plugins]
|
||||||
|
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||||
|
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||||
|
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
|
||||||
Reference in New Issue
Block a user