mirror of
https://github.com/kalarina-bit/Sparkledns.git
synced 2026-11-22 15:46:09 +00:00
Compare commits
7
Commits
v1.1.2
...
180a9a65fd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
180a9a65fd | ||
|
|
845e975c05 | ||
|
|
0ceeb84e98 | ||
|
|
5ddff1b257 | ||
|
|
bc9d855997 | ||
|
|
8f4355a624 | ||
|
|
359bd09b9e |
@@ -0,0 +1,28 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Something doesn't work as expected
|
||||
title: "[Bug] "
|
||||
---
|
||||
|
||||
**What happened**
|
||||
|
||||
|
||||
**Steps to reproduce**
|
||||
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
|
||||
**What you expected**
|
||||
|
||||
|
||||
**Environment**
|
||||
|
||||
- App version:
|
||||
- Installed from: Gitea / GitHub / F-Droid / Google Play
|
||||
- Device and Android version:
|
||||
- DoH server in use:
|
||||
- Network: Wi-Fi / mobile data
|
||||
|
||||
**Screenshots or logs** (optional — please remove domains you don't want to share)
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
blank_issues_enabled: true
|
||||
contact_links:
|
||||
- name: Main repository on git.skysparkle.cc
|
||||
url: https://git.skysparkle.cc/kalarina/Sparkledns
|
||||
about: This GitHub repository is a mirror. Issues are welcome here and on Gitea.
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
name: DoH server or blocklist
|
||||
about: Suggest a DoH server or blocklist preset
|
||||
title: "[Preset] "
|
||||
---
|
||||
|
||||
- Type: DoH server / blocklist
|
||||
- Name:
|
||||
- URL:
|
||||
- Homepage or documentation:
|
||||
- Privacy policy (DoH servers) or license (blocklists):
|
||||
- Donation page (DoH servers, optional):
|
||||
|
||||
- [ ] DoH server: public and supports RFC 8484
|
||||
- [ ] Blocklist: public and actively maintained
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea that fits the app
|
||||
title: "[Feature] "
|
||||
---
|
||||
|
||||
<!-- Please check the "Out of scope" list in CONTRIBUTING.md before opening this. -->
|
||||
|
||||
**What problem does this solve**
|
||||
|
||||
|
||||
**Proposed solution**
|
||||
|
||||
|
||||
**Alternatives you considered**
|
||||
|
||||
|
||||
- [ ] I'd like to implement this myself
|
||||
@@ -0,0 +1,12 @@
|
||||
---
|
||||
name: Translation fix
|
||||
about: Report a wrong or awkward translation
|
||||
title: "[Translation] "
|
||||
---
|
||||
|
||||
<!-- Currently supported: English, Russian. For a new language, open a feature request first. -->
|
||||
|
||||
- Language:
|
||||
- Screen or place in the app:
|
||||
- Current text:
|
||||
- Suggested text:
|
||||
@@ -0,0 +1,17 @@
|
||||
## What does this change
|
||||
|
||||
|
||||
## Related issue
|
||||
|
||||
Closes #
|
||||
|
||||
## Checklist
|
||||
|
||||
- [ ] Discussed in an issue first (not needed for small fixes)
|
||||
- [ ] `./gradlew assembleDebug` builds
|
||||
- [ ] Tested on a device or emulator (Android version: )
|
||||
- [ ] DNS queries only go to the selected DoH server
|
||||
- [ ] No ads, analytics, trackers or Google Play Services / Firebase dependencies
|
||||
- [ ] New strings added to `values/strings.xml` (missing translations noted below)
|
||||
- [ ] Screenshots added for UI changes
|
||||
- [ ] I agree that my contribution is licensed under GPL-3.0-or-later
|
||||
@@ -9,6 +9,9 @@
|
||||
A local VPN that captures only DNS traffic and sends every query to the DoH server you choose (RFC 8484). Everything else goes through your normal connection.
|
||||
</p>
|
||||
|
||||
> [!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).
|
||||
|
||||
<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>
|
||||
</p>
|
||||
|
||||
@@ -13,8 +13,8 @@ android {
|
||||
targetSdk = 36
|
||||
// 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.
|
||||
versionCode = 10102
|
||||
versionName = "1.1.2"
|
||||
versionCode = 10103
|
||||
versionName = "1.1.3"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
|
||||
@@ -81,6 +81,28 @@ private val OtherColor = Palette.Track
|
||||
|
||||
private class Slice(val label: String, val share: Float, val color: Color)
|
||||
|
||||
// One row of the log: every query for a domain, shown by its newest one. A data class, so a
|
||||
// rebuilt list with the same groups counts as unchanged.
|
||||
private data class DomainGroup(val latest: QueryEntry, val types: List<Int>, val count: Int)
|
||||
|
||||
// The log is newest first, so the first entry of a domain is its newest one and the groups come
|
||||
// out in the order their domains were last asked for. Names differ only in letter case when a
|
||||
// resolver randomizes it, so they are compared in lower case.
|
||||
private fun groupByDomain(entries: List<QueryEntry>): List<DomainGroup> {
|
||||
class Builder(val latest: QueryEntry) {
|
||||
val types = LinkedHashSet<Int>()
|
||||
var count = 0
|
||||
}
|
||||
val groups = LinkedHashMap<String, Builder>()
|
||||
for (entry in entries) {
|
||||
val group = groups.getOrPut(entry.domain.lowercase(Locale.ROOT)) { Builder(entry) }
|
||||
group.types += entry.type
|
||||
group.count++
|
||||
}
|
||||
// Types in numeric order: A, then AAAA, then HTTPS
|
||||
return groups.values.map { DomainGroup(it.latest, it.types.sorted(), it.count) }
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun ActivityScreen(bottomPadding: Dp, modifier: Modifier = Modifier) {
|
||||
val context = LocalContext.current
|
||||
@@ -101,12 +123,13 @@ fun ActivityScreen(bottomPadding: Dp, modifier: Modifier = Modifier) {
|
||||
val statsVersion by StatsStore.version.collectAsStateWithLifecycle()
|
||||
LaunchedEffect(period, statsVersion) { summary = StatsStore.summary(period.hours) }
|
||||
|
||||
// Filtered again only when the log, the filter or the search changes, and the list below is
|
||||
// updated only when the result differs: new entries that the filter hides change nothing
|
||||
// Filtered and grouped by domain again only when the log, the filter or the search changes,
|
||||
// and the list below is updated only when the result differs: new entries that the filter
|
||||
// hides change nothing
|
||||
val visible by remember {
|
||||
derivedStateOf(structuralEqualityPolicy()) {
|
||||
val term = search.trim()
|
||||
entries.filter { e ->
|
||||
val matching = entries.filter { e ->
|
||||
val matchesFilter = when (filter) {
|
||||
ActivityFilter.ALL -> true
|
||||
ActivityFilter.BLOCKED -> e.status == QueryStatus.BLOCKED
|
||||
@@ -115,6 +138,7 @@ fun ActivityScreen(bottomPadding: Dp, modifier: Modifier = Modifier) {
|
||||
}
|
||||
matchesFilter && (term.isEmpty() || e.domain.contains(term, ignoreCase = true))
|
||||
}
|
||||
groupByDomain(matching)
|
||||
}
|
||||
}
|
||||
val canClear by remember { derivedStateOf { entries.isNotEmpty() } }
|
||||
@@ -178,11 +202,19 @@ fun ActivityScreen(bottomPadding: Dp, modifier: Modifier = Modifier) {
|
||||
)
|
||||
}
|
||||
}
|
||||
itemsIndexed(visible, key = { _, entry -> entry.id }, contentType = { _, _ -> "query" }) { index, entry ->
|
||||
// Keyed by domain, so a new query for a domain moves its row to the top instead of adding one
|
||||
itemsIndexed(
|
||||
visible,
|
||||
key = { _, group -> "domain:" + group.latest.domain.lowercase(Locale.ROOT) },
|
||||
contentType = { _, _ -> "query" },
|
||||
) { index, group ->
|
||||
val entry = group.latest
|
||||
val blockedByMe = entry.domain in customSet
|
||||
QueryRow(
|
||||
modifier = Modifier.animateItem(),
|
||||
entry = entry,
|
||||
types = group.types,
|
||||
count = group.count,
|
||||
first = index == 0,
|
||||
blockedByMe = blockedByMe,
|
||||
onBlock = { toggleBlock(entry.domain, unblock = false) },
|
||||
@@ -206,7 +238,7 @@ fun ActivityScreen(bottomPadding: Dp, modifier: Modifier = Modifier) {
|
||||
) {
|
||||
ActivityHeader(period) { period = it }
|
||||
ActivityStats(summary, Modifier.padding(top = 20.dp))
|
||||
CompanyCard(summary, Modifier.padding(top = 20.dp))
|
||||
CompanyCard(summary, entries, Modifier.padding(top = 20.dp))
|
||||
}
|
||||
LazyColumn(
|
||||
modifier = Modifier
|
||||
@@ -223,7 +255,7 @@ fun ActivityScreen(bottomPadding: Dp, modifier: Modifier = Modifier) {
|
||||
) {
|
||||
item(key = "header") { ActivityHeader(period) { period = it } }
|
||||
item(key = "stats") { ActivityStats(summary, Modifier.padding(top = 20.dp)) }
|
||||
item(key = "companies") { CompanyCard(summary, Modifier.padding(top = 20.dp)) }
|
||||
item(key = "companies") { CompanyCard(summary, entries, Modifier.padding(top = 20.dp)) }
|
||||
log()
|
||||
}
|
||||
}
|
||||
@@ -334,9 +366,9 @@ private fun LogSearch(
|
||||
private const val MIN_COMPANY_REQUESTS = 50L
|
||||
|
||||
@Composable
|
||||
private fun CompanyCard(summary: StatsSummary, modifier: Modifier = Modifier) {
|
||||
private fun CompanyCard(summary: StatsSummary, recent: List<QueryEntry>, modifier: Modifier = Modifier) {
|
||||
val other = stringResource(R.string.companies_other)
|
||||
val slices = remember(summary, other) { companySlices(summary, other) }
|
||||
val slices = remember(summary, recent, other) { companySlices(summary, recent, other) }
|
||||
Column(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
@@ -398,17 +430,32 @@ private fun percentLabel(share: Float): String {
|
||||
return if (percent < 1f) "<1%" else "${Math.round(percent)}%"
|
||||
}
|
||||
|
||||
// The four companies with most requests, then everything else; empty slices are left out
|
||||
private fun companySlices(summary: StatsSummary, otherLabel: String): List<Slice> {
|
||||
// Shares of the known companies over the period. The statistics keep no domains, so the share
|
||||
// left over is split by the names of the recent queries to other domains, from the log in memory.
|
||||
// Then the four largest slices and everything else; empty slices are left out.
|
||||
private fun companySlices(summary: StatsSummary, recent: List<QueryEntry>, otherLabel: String): List<Slice> {
|
||||
if (summary.total == 0L) return emptyList()
|
||||
val top = Company.entries
|
||||
.map { it to summary.companies[it.ordinal] }
|
||||
.filter { it.second > 0 }
|
||||
.sortedByDescending { it.second }
|
||||
.take(SliceColors.size)
|
||||
val slices = top.mapIndexed { index, (company, count) ->
|
||||
Slice(company.label, count.toFloat() / summary.total, SliceColors[index])
|
||||
val shares = HashMap<String, Float>()
|
||||
for (company in Company.entries) {
|
||||
val count = summary.companies[company.ordinal]
|
||||
if (count > 0) shares[company.label] = count.toFloat() / summary.total
|
||||
}
|
||||
val unknownShare = (1f - shares.values.sum()).coerceAtLeast(0f)
|
||||
val names = HashMap<String, Int>()
|
||||
var unknownCount = 0
|
||||
for (entry in recent) {
|
||||
if (Companies.of(entry.domain) != null) continue
|
||||
unknownCount++
|
||||
Companies.nameOf(entry.domain)?.let { names.merge(it, 1, Int::plus) }
|
||||
}
|
||||
// Queries without a name (local names, reverse lookups) stay in the rest
|
||||
if (unknownCount > 0) {
|
||||
for ((name, count) in names) shares.merge(name, unknownShare * count / unknownCount, Float::plus)
|
||||
}
|
||||
val slices = shares.entries
|
||||
.sortedByDescending { it.value }
|
||||
.take(SliceColors.size)
|
||||
.mapIndexed { index, (label, share) -> Slice(label, share, SliceColors[index]) }
|
||||
val rest = (1f - slices.sumOf { it.share.toDouble() }.toFloat()).coerceAtLeast(0f)
|
||||
return if (rest >= 0.005f) slices + Slice(otherLabel, rest, OtherColor) else slices
|
||||
}
|
||||
@@ -442,6 +489,8 @@ private fun Donut(slices: List<Slice>, modifier: Modifier = Modifier) {
|
||||
private fun QueryRow(
|
||||
modifier: Modifier,
|
||||
entry: QueryEntry,
|
||||
types: List<Int>,
|
||||
count: Int,
|
||||
first: Boolean,
|
||||
blockedByMe: Boolean,
|
||||
onBlock: () -> Unit,
|
||||
@@ -461,6 +510,9 @@ private fun QueryRow(
|
||||
QueryStatus.BLOCKED -> stringResource(if (blockedByMe) R.string.bl_my else R.string.tab_blocklist)
|
||||
QueryStatus.FAILED -> stringResource(R.string.status_failed)
|
||||
}
|
||||
// "A, AAAA, HTTPS · ×3 · 256 ms"; the status and time are those of the newest query
|
||||
val typeNames = types.joinToString(", ") { DnsMessage.typeName(it) }
|
||||
val summary = if (count > 1) "$typeNames · ×$count · $detail" else "$typeNames · $detail"
|
||||
|
||||
Box(modifier.fillMaxWidth()) {
|
||||
Column {
|
||||
@@ -492,7 +544,7 @@ private fun QueryRow(
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
Text(
|
||||
"${DnsMessage.typeName(entry.type)} · $detail",
|
||||
summary,
|
||||
color = Palette.Fg3,
|
||||
fontSize = 12.sp,
|
||||
maxLines = 1,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package cc.skysparkle.sparkledns
|
||||
|
||||
import java.util.Locale
|
||||
import java.util.TreeMap
|
||||
|
||||
// The position of each company is saved in StatsStore: add new ones at the end only
|
||||
@@ -21,6 +22,12 @@ enum class Company(val label: String) {
|
||||
object Companies {
|
||||
private const val GOOGLE_PREFIX = "google."
|
||||
|
||||
// Second-level labels that belong to a country's suffix: example.co.uk, example.com.br
|
||||
private val COUNTRY_SECOND_LEVELS = setOf("co", "com", "net", "org", "gov", "edu", "ac", "or", "ne", "go")
|
||||
|
||||
// Names that are not public sites: reverse lookups and local networks
|
||||
private val PRIVATE_TLDS = setOf("arpa", "local", "lan", "home", "internal", "localhost")
|
||||
|
||||
// Hashes of the domains, sorted, with the company of each at the same index: this runs for
|
||||
// every query, and parent domains are looked up by hash without copying the name
|
||||
private val hashes: LongArray
|
||||
@@ -93,4 +100,16 @@ object Companies {
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
// A readable name for a domain of no known company, taken from its main label:
|
||||
// "cdn.example.co.uk" gives "Example". Null for IP addresses, local names and bare labels.
|
||||
fun nameOf(name: String): String? {
|
||||
val labels = name.lowercase(Locale.ROOT).split('.').filter { it.isNotEmpty() }
|
||||
if (labels.size < 2) return null
|
||||
val tld = labels.last()
|
||||
if (tld in PRIVATE_TLDS || tld.all { it.isDigit() }) return null
|
||||
var index = labels.size - 2
|
||||
if (tld.length == 2 && labels.size >= 3 && labels[index] in COUNTRY_SECOND_LEVELS) index--
|
||||
return labels[index].replaceFirstChar { it.titlecase(Locale.ROOT) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,10 +25,12 @@ import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.LocalContentColor
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
@@ -54,7 +56,13 @@ class MainActivity : ComponentActivity() {
|
||||
AppLogo.preload(this)
|
||||
enableEdgeToEdge()
|
||||
setContent {
|
||||
MaterialTheme(colorScheme = AppColors) { AppShell() }
|
||||
MaterialTheme(colorScheme = AppColors) {
|
||||
// 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
|
||||
CompositionLocalProvider(LocalContentColor provides MaterialTheme.colorScheme.onSurface) {
|
||||
AppShell()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
<string name="tab_activity">Aktivität</string>
|
||||
<string name="tab_settings">Einstellungen</string>
|
||||
<string name="companies_title">Anteil der Konzerne</string>
|
||||
<string name="companies_desc">Welcher Anteil deiner Anfragen an die größten Konzerne geht.</string>
|
||||
<string name="companies_desc">Welcher Anteil deiner Anfragen an die größten Konzerne und andere Websites geht.</string>
|
||||
<string name="companies_other">Andere</string>
|
||||
<string name="recent_title">Letzte Anfragen</string>
|
||||
<string name="filter">Filter</string>
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
<string name="tab_activity">アクティビティ</string>
|
||||
<string name="tab_settings">設定</string>
|
||||
<string name="companies_title">企業の占有率</string>
|
||||
<string name="companies_desc">リクエストのうち大手企業に送られる割合です。</string>
|
||||
<string name="companies_desc">リクエストのうち大手企業やその他のサイトに送られる割合です。</string>
|
||||
<string name="companies_other">その他</string>
|
||||
<string name="recent_title">最近のアクティビティ</string>
|
||||
<string name="filter">フィルター</string>
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
<string name="tab_activity">Veikla</string>
|
||||
<string name="tab_settings">Nustatymai</string>
|
||||
<string name="companies_title">Įmonių dalis</string>
|
||||
<string name="companies_desc">Kokia jūsų užklausų dalis tenka didžiausioms įmonėms.</string>
|
||||
<string name="companies_desc">Kokia jūsų užklausų dalis tenka didžiausioms įmonėms ir kitoms svetainėms.</string>
|
||||
<string name="companies_other">Kitos</string>
|
||||
<string name="recent_title">Naujausios užklausos</string>
|
||||
<string name="filter">Filtras</string>
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
<string name="tab_activity">Активность</string>
|
||||
<string name="tab_settings">Настройки</string>
|
||||
<string name="companies_title">Доля компаний</string>
|
||||
<string name="companies_desc">Какая часть ваших запросов уходит крупнейшим компаниям.</string>
|
||||
<string name="companies_desc">Какая часть ваших запросов уходит крупнейшим компаниям и другим сайтам.</string>
|
||||
<string name="companies_other">Другие</string>
|
||||
<string name="recent_title">Последние запросы</string>
|
||||
<string name="filter">Фильтр</string>
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
<string name="tab_activity">活动</string>
|
||||
<string name="tab_settings">设置</string>
|
||||
<string name="companies_title">公司占比</string>
|
||||
<string name="companies_desc">你的请求中发往大公司的比例。</string>
|
||||
<string name="companies_desc">你的请求中发往大公司和其他网站的比例。</string>
|
||||
<string name="companies_other">其他</string>
|
||||
<string name="recent_title">最近活动</string>
|
||||
<string name="filter">筛选</string>
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
<string name="tab_activity">Activity</string>
|
||||
<string name="tab_settings">Settings</string>
|
||||
<string name="companies_title">Company dominance</string>
|
||||
<string name="companies_desc">Share of your requests that go to the biggest companies.</string>
|
||||
<string name="companies_desc">Share of your requests that go to the biggest companies and other sites.</string>
|
||||
<string name="companies_other">Other</string>
|
||||
<string name="recent_title">Recent activity</string>
|
||||
<string name="filter">Filter</string>
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
• Die letzte Aktivität zeigt eine Zeile pro Domain mit allen abgefragten Typen (A, AAAA, HTTPS) und der Anzahl der Anfragen
|
||||
• Der Anteil der Konzerne nennt jetzt auch andere Websites, statt alle unter Andere zusammenzufassen
|
||||
@@ -0,0 +1,2 @@
|
||||
• Recent activity shows one row per domain with all requested types (A, AAAA, HTTPS) and the number of queries
|
||||
• Company dominance names other sites instead of grouping them all as Other
|
||||
@@ -0,0 +1,2 @@
|
||||
• 最近のアクティビティはドメインごとに 1 行で表示し、要求されたすべての種類(A、AAAA、HTTPS)とクエリ数を表示
|
||||
• 企業の占有率で、その他のサイトもまとめずに名前で表示
|
||||
@@ -0,0 +1,2 @@
|
||||
• Naujausia veikla rodo vieną eilutę kiekvienam domenui su visais užklaustais tipais (A, AAAA, HTTPS) ir užklausų skaičiumi
|
||||
• Įmonių dalyje kitos svetainės dabar rodomos pavadinimais, o ne sujungiamos į „Kitos“
|
||||
@@ -0,0 +1,2 @@
|
||||
• Последняя активность показывает одну строку на домен со всеми запрошенными типами (A, AAAA, HTTPS) и числом запросов
|
||||
• В «Доле компаний» остальные сайты показываются по названиям, а не объединяются в «Другие»
|
||||
@@ -0,0 +1,2 @@
|
||||
• 最近活动按域名每行显示一条,包含所有请求类型(A、AAAA、HTTPS)及查询次数
|
||||
• 公司占比中的其他网站现在按名称显示,不再全部归入“其他”
|
||||
Reference in New Issue
Block a user