mirror of
https://github.com/kalarina-bit/Sparkledns.git
synced 2026-11-22 07:36:09 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e039ab0d46 | ||
|
|
032a49f1f8 | ||
|
|
9ca55a4d40 | ||
|
|
00e30cb858 | ||
|
|
41a8f94f65 | ||
|
|
6bd72d3583 | ||
|
|
59194a7914 | ||
|
|
0f8bb8dc9d | ||
|
|
8bccbe597c | ||
|
|
73959b16b2 |
+35
-5
@@ -9,7 +9,8 @@ Issues and pull requests go to the repository on [Gitea](https://git.skysparkle.
|
|||||||
## Ways to help
|
## Ways to help
|
||||||
|
|
||||||
- **Report a bug** — use the *Bug report* template.
|
- **Report a bug** — use the *Bug report* template.
|
||||||
- **Suggest a DoH server or blocklist** — use the *DoH server or blocklist* template.
|
- **Add a DoH server** — add one line to [`servers/servers.txt`](servers/servers.txt), see [Adding a DoH server](#adding-a-doh-server).
|
||||||
|
- **Suggest a blocklist** — use the *DoH server or blocklist* template.
|
||||||
- **Suggest a feature** — use the *Feature request* template; check [Out of scope](#out-of-scope) first.
|
- **Suggest a feature** — use the *Feature request* template; check [Out of scope](#out-of-scope) first.
|
||||||
- **Fix a translation** — use the *Translation fix* template or send a pull request.
|
- **Fix a translation** — use the *Translation fix* template or send a pull request.
|
||||||
- **Write code** — see [Pull requests](#pull-requests).
|
- **Write code** — see [Pull requests](#pull-requests).
|
||||||
@@ -35,12 +36,41 @@ These will not be accepted:
|
|||||||
- Logging, uploading or sharing users' DNS queries.
|
- Logging, uploading or sharing users' DNS queries.
|
||||||
- Features that require Google Play Services or a proprietary SDK.
|
- Features that require Google Play Services or a proprietary SDK.
|
||||||
|
|
||||||
## DoH servers and blocklists
|
## Adding a DoH server
|
||||||
|
|
||||||
- **DoH servers** must be public, support RFC 8484 and publish a privacy policy.
|
The server list lives in [`servers/servers.txt`](servers/servers.txt). The app downloads it when the user taps **Update server list**, so a new server reaches users without a new release.
|
||||||
- **Blocklists** must be public, actively maintained and licensed for this kind of use.
|
|
||||||
|
|
||||||
Include links to the server's documentation or the list's homepage in the request.
|
To add a server, open the file on Gitea, click **Edit**, add one line at the end and send it as a pull request:
|
||||||
|
|
||||||
|
```
|
||||||
|
Name | DoH URL | Privacy policy | h3
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Name** — how the server appears in the app, up to 40 characters.
|
||||||
|
- **DoH URL** — the full `https://` address of the DoH endpoint.
|
||||||
|
- **Privacy policy** — an `https://` link to the operator's privacy policy. Lines without one are ignored.
|
||||||
|
- **h3** — optional. Add it only if the server supports HTTP/3.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```
|
||||||
|
Example DNS | https://dns.example.org/dns-query | https://example.org/privacy | h3
|
||||||
|
```
|
||||||
|
|
||||||
|
The server must:
|
||||||
|
|
||||||
|
- be public and free, without an account;
|
||||||
|
- support RFC 8484;
|
||||||
|
- publish what it logs, and not sell or share query data;
|
||||||
|
- be run by a non-profit, a community or an individual rather than a large company.
|
||||||
|
|
||||||
|
Before sending, check that it works: in the app choose **Custom server**, enter the URL and tap **Test server**.
|
||||||
|
|
||||||
|
Please don't change the lines of the servers that ship with the app (SkySparkle, Quad9, Digitale Gesellschaft, UncensoredDNS, Freifunk München): the app always keeps their built-in addresses. If you are unsure whether a server fits, open an issue with the *DoH server or blocklist* template instead.
|
||||||
|
|
||||||
|
## Blocklists
|
||||||
|
|
||||||
|
Blocklist presets must be public, actively maintained and licensed for this kind of use. Use the *DoH server or blocklist* template and include a link to the list's homepage.
|
||||||
|
|
||||||
## Translations
|
## Translations
|
||||||
|
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ private fun InfoRow(label: String, value: String) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun openUrl(context: Context, url: String) {
|
internal fun openUrl(context: Context, url: String) {
|
||||||
runCatching {
|
runCatching {
|
||||||
context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
|
context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,9 @@ import androidx.compose.material3.Button
|
|||||||
import androidx.compose.material3.Card
|
import androidx.compose.material3.Card
|
||||||
import androidx.compose.material3.CardDefaults
|
import androidx.compose.material3.CardDefaults
|
||||||
import androidx.compose.material3.HorizontalDivider
|
import androidx.compose.material3.HorizontalDivider
|
||||||
|
import androidx.compose.material3.CircularProgressIndicator
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.OutlinedButton
|
import androidx.compose.material3.OutlinedButton
|
||||||
import androidx.compose.material3.OutlinedTextField
|
import androidx.compose.material3.OutlinedTextField
|
||||||
@@ -63,6 +65,7 @@ import androidx.compose.material3.Text
|
|||||||
import androidx.compose.material3.TextButton
|
import androidx.compose.material3.TextButton
|
||||||
import androidx.compose.material3.darkColorScheme
|
import androidx.compose.material3.darkColorScheme
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
@@ -121,6 +124,10 @@ fun HomeScreen(modifier: Modifier = Modifier) {
|
|||||||
val stats = rememberLiveStats()
|
val stats = rememberLiveStats()
|
||||||
|
|
||||||
var selected by remember { mutableStateOf(prefs.providerId) }
|
var selected by remember { mutableStateOf(prefs.providerId) }
|
||||||
|
val servers by ServerList.servers.collectAsState()
|
||||||
|
var syncing by remember { mutableStateOf(false) }
|
||||||
|
var syncResult by remember { mutableStateOf<TestResult?>(null) }
|
||||||
|
var shownSync by remember { mutableStateOf<TestResult?>(null) }
|
||||||
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) }
|
||||||
@@ -140,7 +147,7 @@ fun HomeScreen(modifier: Modifier = Modifier) {
|
|||||||
val isCustom = selected == Providers.CUSTOM_ID
|
val isCustom = selected == Providers.CUSTOM_ID
|
||||||
val customValid = customUrl.trim().toHttpUrlOrNull()?.isHttps == true
|
val customValid = customUrl.trim().toHttpUrlOrNull()?.isHttps == true
|
||||||
val canConnect = !isCustom || customValid
|
val canConnect = !isCustom || customValid
|
||||||
val selectedProvider = remember(selected, customUrl, customBootstrap, customHttp3) { prefs.resolve() }
|
val selectedProvider = remember(selected, customUrl, customBootstrap, customHttp3, servers) { prefs.resolve() }
|
||||||
val customName = stringResource(R.string.custom)
|
val customName = stringResource(R.string.custom)
|
||||||
fun nameOf(p: DohProvider) = if (p.id == Providers.CUSTOM_ID) customName else p.name
|
fun nameOf(p: DohProvider) = if (p.id == Providers.CUSTOM_ID) customName else p.name
|
||||||
val shownProvider = active ?: selectedProvider
|
val shownProvider = active ?: selectedProvider
|
||||||
@@ -181,6 +188,30 @@ fun HomeScreen(modifier: Modifier = Modifier) {
|
|||||||
testResult = null
|
testResult = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A server removed from the list falls back to the default one
|
||||||
|
LaunchedEffect(servers) {
|
||||||
|
if (selected != Providers.CUSTOM_ID && servers.none { it.id == selected }) select(Providers.default.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
val syncOk = stringResource(R.string.servers_updated)
|
||||||
|
val syncFail = stringResource(R.string.servers_update_failed)
|
||||||
|
fun syncServers() {
|
||||||
|
syncing = true
|
||||||
|
syncResult = null
|
||||||
|
scope.launch {
|
||||||
|
val result = withContext(Dispatchers.IO) {
|
||||||
|
runCatching { ServerList.sync(context) }
|
||||||
|
.fold(
|
||||||
|
onSuccess = { TestResult(true, syncOk) },
|
||||||
|
onFailure = { TestResult(false, syncFail.format(it.message ?: it.javaClass.simpleName)) },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
shownSync = result
|
||||||
|
syncResult = result
|
||||||
|
syncing = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun runTest() {
|
fun runTest() {
|
||||||
val provider = prefs.resolve()
|
val provider = prefs.resolve()
|
||||||
testing = true
|
testing = true
|
||||||
@@ -223,19 +254,48 @@ fun HomeScreen(modifier: Modifier = Modifier) {
|
|||||||
onSwitch = { sendAction(context, DohVpnService.ACTION_START) },
|
onSwitch = { sendAction(context, DohVpnService.ACTION_START) },
|
||||||
)
|
)
|
||||||
|
|
||||||
SectionHeader(stringResource(R.string.servers))
|
SectionHeader(stringResource(R.string.servers)) {
|
||||||
|
if (syncing) {
|
||||||
|
Box(Modifier.size(48.dp), contentAlignment = Alignment.Center) {
|
||||||
|
CircularProgressIndicator(Modifier.size(20.dp), strokeWidth = 2.dp)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
IconButton(onClick = ::syncServers) {
|
||||||
|
Icon(
|
||||||
|
painterResource(R.drawable.ic_refresh),
|
||||||
|
contentDescription = stringResource(R.string.servers_update),
|
||||||
|
modifier = Modifier.size(20.dp),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AnimatedVisibility(visible = syncResult != null, enter = Motion.expandIn, exit = Motion.collapseOut) {
|
||||||
|
shownSync?.let { result ->
|
||||||
|
HintCard(
|
||||||
|
text = result.text,
|
||||||
|
icon = if (result.ok) R.drawable.ic_check else R.drawable.ic_alert,
|
||||||
|
tint = if (result.ok) CachedColor else MaterialTheme.colorScheme.error,
|
||||||
|
onDismiss = { syncResult = null },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Card(Modifier.fillMaxWidth()) {
|
Card(Modifier.fillMaxWidth()) {
|
||||||
Column(Modifier.padding(vertical = 6.dp)) {
|
Column(Modifier.padding(vertical = 6.dp)) {
|
||||||
Providers.list.forEachIndexed { index, p ->
|
servers.forEachIndexed { index, p ->
|
||||||
if (index > 0) RowDivider()
|
if (index > 0) RowDivider()
|
||||||
ProviderRow(p.name, hostOf(p.url), p.http3, selected == p.id) { select(p.id) }
|
ProviderRow(
|
||||||
|
title = p.name,
|
||||||
|
subtitle = hostOf(p.url),
|
||||||
|
selected = selected == p.id,
|
||||||
|
onPolicy = p.policy?.let { url -> { openUrl(context, url) } },
|
||||||
|
) { select(p.id) }
|
||||||
}
|
}
|
||||||
RowDivider()
|
RowDivider()
|
||||||
ProviderRow(
|
ProviderRow(
|
||||||
title = stringResource(R.string.custom),
|
title = stringResource(R.string.custom),
|
||||||
subtitle = hostOf(customUrl),
|
subtitle = hostOf(customUrl),
|
||||||
http3 = customHttp3,
|
|
||||||
selected = isCustom,
|
selected = isCustom,
|
||||||
) { select(Providers.CUSTOM_ID) }
|
) { select(Providers.CUSTOM_ID) }
|
||||||
}
|
}
|
||||||
@@ -506,7 +566,13 @@ private fun CrashCard(report: String, onCopy: () -> Unit, onDismiss: () -> Unit)
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun ProviderRow(title: String, subtitle: String, http3: Boolean, selected: Boolean, onClick: () -> Unit) {
|
private fun ProviderRow(
|
||||||
|
title: String,
|
||||||
|
subtitle: String,
|
||||||
|
selected: Boolean,
|
||||||
|
onPolicy: (() -> Unit)? = null,
|
||||||
|
onClick: () -> Unit,
|
||||||
|
) {
|
||||||
val highlight by animateColorAsState(
|
val highlight by animateColorAsState(
|
||||||
if (selected) MaterialTheme.colorScheme.primary.copy(alpha = 0.08f) else Color.Transparent,
|
if (selected) MaterialTheme.colorScheme.primary.copy(alpha = 0.08f) else Color.Transparent,
|
||||||
animationSpec = Motion.color,
|
animationSpec = Motion.color,
|
||||||
@@ -532,9 +598,15 @@ private fun ProviderRow(title: String, subtitle: String, http3: Boolean, selecte
|
|||||||
overflow = TextOverflow.Ellipsis,
|
overflow = TextOverflow.Ellipsis,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (http3) {
|
if (onPolicy != null) {
|
||||||
Spacer(Modifier.width(8.dp))
|
IconButton(onClick = onPolicy, modifier = Modifier.size(40.dp)) {
|
||||||
Pill("HTTP/3", MaterialTheme.colorScheme.primary)
|
Icon(
|
||||||
|
painterResource(R.drawable.ic_policy),
|
||||||
|
contentDescription = stringResource(R.string.about_privacy_policy),
|
||||||
|
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
|
modifier = Modifier.size(18.dp),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ import android.content.Context
|
|||||||
class Prefs(context: Context) {
|
class Prefs(context: Context) {
|
||||||
private val sp = context.applicationContext.getSharedPreferences("doh", Context.MODE_PRIVATE)
|
private val sp = context.applicationContext.getSharedPreferences("doh", Context.MODE_PRIVATE)
|
||||||
|
|
||||||
|
init {
|
||||||
|
ServerList.ensureLoaded(context.applicationContext)
|
||||||
|
}
|
||||||
|
|
||||||
var providerId: String
|
var providerId: String
|
||||||
get() = sp.getString(KEY_PROVIDER, null) ?: Providers.default.id
|
get() = sp.getString(KEY_PROVIDER, null) ?: Providers.default.id
|
||||||
set(value) = sp.edit().putString(KEY_PROVIDER, value).apply()
|
set(value) = sp.edit().putString(KEY_PROVIDER, value).apply()
|
||||||
|
|||||||
@@ -1,6 +1,14 @@
|
|||||||
package cc.skysparkle.sparkledns
|
package cc.skysparkle.sparkledns
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
|
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||||
|
import okhttp3.OkHttpClient
|
||||||
|
import okhttp3.Request
|
||||||
|
import java.io.File
|
||||||
|
import java.io.IOException
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
data class DohProvider(
|
data class DohProvider(
|
||||||
val id: String,
|
val id: String,
|
||||||
@@ -8,25 +16,141 @@ data class DohProvider(
|
|||||||
val url: String,
|
val url: String,
|
||||||
val bootstrap: List<String> = emptyList(),
|
val bootstrap: List<String> = emptyList(),
|
||||||
val http3: Boolean = false,
|
val http3: Boolean = false,
|
||||||
|
val policy: String? = null,
|
||||||
)
|
)
|
||||||
|
|
||||||
object Providers {
|
object Providers {
|
||||||
const val CUSTOM_ID = "custom"
|
const val CUSTOM_ID = "custom"
|
||||||
|
const val DEFAULT_ID = "skysparkle"
|
||||||
|
|
||||||
val list = listOf(
|
// Shipped with the app and used until the list from the repository is downloaded
|
||||||
DohProvider("skysparkle", "SkySparkle", "https://blog.skysparkle.cc/dns-query", http3 = true),
|
val builtIn = listOf(
|
||||||
DohProvider("cloudflare", "Cloudflare", "https://cloudflare-dns.com/dns-query", listOf("1.1.1.1", "1.0.0.1")),
|
DohProvider(
|
||||||
DohProvider("google", "Google", "https://dns.google/dns-query", listOf("8.8.8.8", "8.8.4.4")),
|
"skysparkle", "SkySparkle", "https://blog.skysparkle.cc/dns-query",
|
||||||
DohProvider("quad9", "Quad9", "https://dns.quad9.net/dns-query", listOf("9.9.9.9", "149.112.112.112")),
|
http3 = true, policy = "https://skysparkle.cc/privacy?lang=en",
|
||||||
DohProvider("adguard", "AdGuard", "https://dns.adguard-dns.com/dns-query", listOf("94.140.14.14", "94.140.15.15")),
|
),
|
||||||
DohProvider("mullvad", "Mullvad", "https://dns.mullvad.net/dns-query", listOf("194.242.2.2")),
|
DohProvider(
|
||||||
|
"quad9", "Quad9", "https://dns.quad9.net/dns-query", listOf("9.9.9.9", "149.112.112.112"),
|
||||||
|
policy = "https://quad9.net/service/privacy/",
|
||||||
|
),
|
||||||
|
DohProvider(
|
||||||
|
"digitale-gesellschaft", "Digitale Gesellschaft", "https://dns.digitale-gesellschaft.ch/dns-query",
|
||||||
|
listOf("185.95.218.42", "185.95.218.43"), http3 = true,
|
||||||
|
policy = "https://www.digitale-gesellschaft.ch/dns/",
|
||||||
|
),
|
||||||
|
DohProvider(
|
||||||
|
"uncensoreddns", "UncensoredDNS", "https://anycast.uncensoreddns.org/dns-query", listOf("91.239.100.100"),
|
||||||
|
policy = "https://blog.uncensoreddns.org/faq/",
|
||||||
|
),
|
||||||
|
DohProvider(
|
||||||
|
"ffmuc", "Freifunk München", "https://doh.ffmuc.net/dns-query",
|
||||||
|
listOf("5.1.66.255", "185.150.99.255"), http3 = true,
|
||||||
|
policy = "https://ffmuc.net/dns-privacy/",
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
val default: DohProvider get() = list.first()
|
val list: List<DohProvider> get() = ServerList.servers.value
|
||||||
|
|
||||||
|
// The project's own server stays the default whatever order the list uses
|
||||||
|
val default: DohProvider get() = list.firstOrNull { it.id == DEFAULT_ID } ?: list.first()
|
||||||
|
|
||||||
fun byId(id: String): DohProvider = list.firstOrNull { it.id == id } ?: default
|
fun byId(id: String): DohProvider = list.firstOrNull { it.id == id } ?: default
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The server list kept in the project repository, so servers can change without an app update
|
||||||
|
object ServerList {
|
||||||
|
const val SOURCE = "https://git.skysparkle.cc/kalarina/Sparkledns/raw/branch/main/servers/servers.txt"
|
||||||
|
private const val FILE = "servers.txt"
|
||||||
|
private const val MAX_BYTES = 64 * 1024
|
||||||
|
private const val MAX_SERVERS = 50
|
||||||
|
|
||||||
|
private val _servers = MutableStateFlow(Providers.builtIn)
|
||||||
|
val servers: StateFlow<List<DohProvider>> = _servers
|
||||||
|
|
||||||
|
@Volatile private var loaded = false
|
||||||
|
|
||||||
|
private val client by lazy {
|
||||||
|
OkHttpClient.Builder()
|
||||||
|
.connectTimeout(15, TimeUnit.SECONDS)
|
||||||
|
.readTimeout(30, TimeUnit.SECONDS)
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun ensureLoaded(context: Context) {
|
||||||
|
if (loaded) return
|
||||||
|
synchronized(this) {
|
||||||
|
if (loaded) return
|
||||||
|
val cached = runCatching { File(context.filesDir, FILE).readText() }.getOrNull()
|
||||||
|
cached?.let(::parse)?.takeIf { it.isNotEmpty() }?.let { _servers.value = it }
|
||||||
|
loaded = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Blocking: call off the main thread. Returns the number of servers in the new list.
|
||||||
|
fun sync(context: Context): Int {
|
||||||
|
val request = Request.Builder().url(SOURCE).build()
|
||||||
|
val text = client.newCall(request).execute().use { response ->
|
||||||
|
if (!response.isSuccessful) throw IOException("HTTP ${response.code}")
|
||||||
|
val body = response.body ?: throw IOException("Empty response")
|
||||||
|
if (body.contentLength() > MAX_BYTES) throw IOException("List too large")
|
||||||
|
val bytes = body.byteStream().readNBytesCompat(MAX_BYTES + 1)
|
||||||
|
if (bytes.size > MAX_BYTES) throw IOException("List too large")
|
||||||
|
String(bytes, Charsets.UTF_8)
|
||||||
|
}
|
||||||
|
val parsed = parse(text)
|
||||||
|
if (parsed.isEmpty()) throw IOException("No servers found")
|
||||||
|
val file = File(context.filesDir, FILE)
|
||||||
|
val tmp = File(context.filesDir, "$FILE.tmp")
|
||||||
|
tmp.writeText(text)
|
||||||
|
if (!tmp.renameTo(file)) {
|
||||||
|
tmp.delete()
|
||||||
|
throw IOException("Cannot save list")
|
||||||
|
}
|
||||||
|
_servers.value = parsed
|
||||||
|
loaded = true
|
||||||
|
return parsed.size
|
||||||
|
}
|
||||||
|
|
||||||
|
// Format per line: Name | DoH URL | privacy policy URL | h3 (optional). See CONTRIBUTING.md.
|
||||||
|
fun parse(text: String): List<DohProvider> {
|
||||||
|
val builtInByHost = Providers.builtIn.associateBy { it.url.toHttpUrlOrNull()?.host }
|
||||||
|
val seen = HashSet<String>()
|
||||||
|
val result = ArrayList<DohProvider>()
|
||||||
|
for (raw in text.lineSequence()) {
|
||||||
|
val line = raw.trim()
|
||||||
|
if (line.isEmpty() || line.startsWith("#")) continue
|
||||||
|
val cols = line.split('|').map { it.trim() }
|
||||||
|
if (cols.size < 3) continue
|
||||||
|
val name = cols[0].take(40)
|
||||||
|
val url = cols[1].toHttpUrlOrNull()
|
||||||
|
val policy = cols[2].takeIf { it.toHttpUrlOrNull()?.isHttps == true }
|
||||||
|
if (name.isEmpty() || url == null || !url.isHttps) continue
|
||||||
|
// Shipped servers keep their address and id, so an edited list cannot redirect them
|
||||||
|
val pinned = builtInByHost[url.host]
|
||||||
|
val server = pinned
|
||||||
|
?: if (policy == null) continue
|
||||||
|
else DohProvider(url.host, name, cols[1], http3 = cols.getOrElse(3) { "" }.equals("h3", ignoreCase = true), policy = policy)
|
||||||
|
if (!seen.add(server.id)) continue
|
||||||
|
result += server
|
||||||
|
if (result.size >= MAX_SERVERS) break
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun java.io.InputStream.readNBytesCompat(limit: Int): ByteArray {
|
||||||
|
val out = java.io.ByteArrayOutputStream()
|
||||||
|
val buffer = ByteArray(8192)
|
||||||
|
var total = 0
|
||||||
|
while (total < limit) {
|
||||||
|
val read = read(buffer, 0, minOf(buffer.size, limit - total))
|
||||||
|
if (read < 0) break
|
||||||
|
out.write(buffer, 0, read)
|
||||||
|
total += read
|
||||||
|
}
|
||||||
|
return out.toByteArray()
|
||||||
|
}
|
||||||
|
|
||||||
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() }
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="256"
|
||||||
|
android:viewportHeight="256">
|
||||||
|
<path
|
||||||
|
android:pathData="M128,38 L58,67 L58,120 C58,165 90,200 128,217 C166,200 198,165 198,120 L198,67 Z"
|
||||||
|
android:strokeColor="#FFFFFFFF"
|
||||||
|
android:strokeWidth="11"
|
||||||
|
android:strokeLineJoin="round" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFFFF"
|
||||||
|
android:pathData="M127.5,86.0 L135.8,111.6 L162.7,111.6 L140.9,127.4 L149.2,152.9 L127.5,137.1 L105.8,152.9 L114.1,127.4 L92.3,111.6 L119.2,111.6 Z" />
|
||||||
|
</vector>
|
||||||
@@ -67,7 +67,7 @@
|
|||||||
<string name="bl_list_info">%1$s Domains · %2$s</string>
|
<string name="bl_list_info">%1$s Domains · %2$s</string>
|
||||||
<string name="bl_presets">Beliebte Listen</string>
|
<string name="bl_presets">Beliebte Listen</string>
|
||||||
<string name="bl_download_failed">Download fehlgeschlagen: %1$s</string>
|
<string name="bl_download_failed">Download fehlgeschlagen: %1$s</string>
|
||||||
<string name="about_desc">Verschlüsseltes DNS über HTTPS und HTTP/3 für das ganze Gerät. Nur DNS läuft über das lokale VPN, der übrige Verkehr bleibt unberührt.</string>
|
<string name="about_desc">DNS-Anfragen verschlüsseln, ohne den gesamten Verkehr über ein VPN zu leiten.</string>
|
||||||
<string name="about_version">Version</string>
|
<string name="about_version">Version</string>
|
||||||
<string name="about_protocol">Protokoll</string>
|
<string name="about_protocol">Protokoll</string>
|
||||||
<string name="about_http3_yes">Auf diesem Gerät unterstützt</string>
|
<string name="about_http3_yes">Auf diesem Gerät unterstützt</string>
|
||||||
@@ -94,4 +94,7 @@
|
|||||||
<string name="open_settings">Einstellungen</string>
|
<string name="open_settings">Einstellungen</string>
|
||||||
<string name="mon_no_match">Nichts passt zum Filter</string>
|
<string name="mon_no_match">Nichts passt zum Filter</string>
|
||||||
<string name="bl_title">Blockierung</string>
|
<string name="bl_title">Blockierung</string>
|
||||||
|
<string name="servers_update">Serverliste aktualisieren</string>
|
||||||
|
<string name="servers_updated">Serverliste aktualisiert</string>
|
||||||
|
<string name="servers_update_failed">Serverliste konnte nicht aktualisiert werden: %1$s</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -67,7 +67,7 @@
|
|||||||
<string name="bl_list_info">%1$s ドメイン · %2$s</string>
|
<string name="bl_list_info">%1$s ドメイン · %2$s</string>
|
||||||
<string name="bl_presets">人気のリスト</string>
|
<string name="bl_presets">人気のリスト</string>
|
||||||
<string name="bl_download_failed">ダウンロードに失敗しました: %1$s</string>
|
<string name="bl_download_failed">ダウンロードに失敗しました: %1$s</string>
|
||||||
<string name="about_desc">端末全体で DNS over HTTPS と HTTP/3 による暗号化 DNS を利用できます。ローカル VPN を通るのは DNS だけで、その他の通信はそのままです。</string>
|
<string name="about_desc">すべての通信をVPNに通さずに、DNSリクエストを暗号化します。</string>
|
||||||
<string name="about_version">バージョン</string>
|
<string name="about_version">バージョン</string>
|
||||||
<string name="about_protocol">プロトコル</string>
|
<string name="about_protocol">プロトコル</string>
|
||||||
<string name="about_http3_yes">この端末で対応しています</string>
|
<string name="about_http3_yes">この端末で対応しています</string>
|
||||||
@@ -94,4 +94,7 @@
|
|||||||
<string name="open_settings">設定</string>
|
<string name="open_settings">設定</string>
|
||||||
<string name="mon_no_match">フィルターに一致するものはありません</string>
|
<string name="mon_no_match">フィルターに一致するものはありません</string>
|
||||||
<string name="bl_title">ブロック</string>
|
<string name="bl_title">ブロック</string>
|
||||||
|
<string name="servers_update">サーバーリストを更新</string>
|
||||||
|
<string name="servers_updated">サーバーリストを更新しました</string>
|
||||||
|
<string name="servers_update_failed">サーバーリストを更新できませんでした: %1$s</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -67,7 +67,7 @@
|
|||||||
<string name="bl_list_info">%1$s domenų · %2$s</string>
|
<string name="bl_list_info">%1$s domenų · %2$s</string>
|
||||||
<string name="bl_presets">Populiarūs sąrašai</string>
|
<string name="bl_presets">Populiarūs sąrašai</string>
|
||||||
<string name="bl_download_failed">Atsisiųsti nepavyko: %1$s</string>
|
<string name="bl_download_failed">Atsisiųsti nepavyko: %1$s</string>
|
||||||
<string name="about_desc">Šifruotas DNS per HTTPS ir HTTP/3 visam įrenginiui. Per vietinį VPN eina tik DNS, kitas srautas lieka nepaliestas.</string>
|
<string name="about_desc">Šifruokite DNS užklausas, nenukreipdami viso srauto per VPN.</string>
|
||||||
<string name="about_version">Versija</string>
|
<string name="about_version">Versija</string>
|
||||||
<string name="about_protocol">Protokolas</string>
|
<string name="about_protocol">Protokolas</string>
|
||||||
<string name="about_http3_yes">Palaikoma šiame įrenginyje</string>
|
<string name="about_http3_yes">Palaikoma šiame įrenginyje</string>
|
||||||
@@ -94,4 +94,7 @@
|
|||||||
<string name="open_settings">Nustatymai</string>
|
<string name="open_settings">Nustatymai</string>
|
||||||
<string name="mon_no_match">Filtro neatitinka niekas</string>
|
<string name="mon_no_match">Filtro neatitinka niekas</string>
|
||||||
<string name="bl_title">Blokavimas</string>
|
<string name="bl_title">Blokavimas</string>
|
||||||
|
<string name="servers_update">Atnaujinti serverių sąrašą</string>
|
||||||
|
<string name="servers_updated">Serverių sąrašas atnaujintas</string>
|
||||||
|
<string name="servers_update_failed">Nepavyko atnaujinti serverių sąrašo: %1$s</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -67,7 +67,7 @@
|
|||||||
<string name="bl_list_info">%1$s доменов · %2$s</string>
|
<string name="bl_list_info">%1$s доменов · %2$s</string>
|
||||||
<string name="bl_presets">Популярные списки</string>
|
<string name="bl_presets">Популярные списки</string>
|
||||||
<string name="bl_download_failed">Ошибка загрузки: %1$s</string>
|
<string name="bl_download_failed">Ошибка загрузки: %1$s</string>
|
||||||
<string name="about_desc">Шифрованный DNS через HTTPS и HTTP/3 для всего устройства. Через локальный VPN идёт только DNS, остальной трафик не затрагивается.</string>
|
<string name="about_desc">Шифруйте DNS-запросы, не пропуская весь трафик через VPN.</string>
|
||||||
<string name="about_version">Версия</string>
|
<string name="about_version">Версия</string>
|
||||||
<string name="about_protocol">Протокол</string>
|
<string name="about_protocol">Протокол</string>
|
||||||
<string name="about_http3_yes">Поддерживается на этом устройстве</string>
|
<string name="about_http3_yes">Поддерживается на этом устройстве</string>
|
||||||
@@ -94,4 +94,7 @@
|
|||||||
<string name="open_settings">Настройки</string>
|
<string name="open_settings">Настройки</string>
|
||||||
<string name="mon_no_match">Ничего не найдено</string>
|
<string name="mon_no_match">Ничего не найдено</string>
|
||||||
<string name="bl_title">Блокировка</string>
|
<string name="bl_title">Блокировка</string>
|
||||||
|
<string name="servers_update">Обновить список серверов</string>
|
||||||
|
<string name="servers_updated">Список серверов обновлён</string>
|
||||||
|
<string name="servers_update_failed">Не удалось обновить список серверов: %1$s</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -67,7 +67,7 @@
|
|||||||
<string name="bl_list_info">%1$s 个域名 · %2$s</string>
|
<string name="bl_list_info">%1$s 个域名 · %2$s</string>
|
||||||
<string name="bl_presets">热门列表</string>
|
<string name="bl_presets">热门列表</string>
|
||||||
<string name="bl_download_failed">下载失败:%1$s</string>
|
<string name="bl_download_failed">下载失败:%1$s</string>
|
||||||
<string name="about_desc">为整台设备提供通过 HTTPS 和 HTTP/3 加密的 DNS。只有 DNS 经过本地 VPN,其他流量保持不变。</string>
|
<string name="about_desc">加密 DNS 请求,无需让全部流量经过 VPN。</string>
|
||||||
<string name="about_version">版本</string>
|
<string name="about_version">版本</string>
|
||||||
<string name="about_protocol">协议</string>
|
<string name="about_protocol">协议</string>
|
||||||
<string name="about_http3_yes">此设备支持</string>
|
<string name="about_http3_yes">此设备支持</string>
|
||||||
@@ -94,4 +94,7 @@
|
|||||||
<string name="open_settings">设置</string>
|
<string name="open_settings">设置</string>
|
||||||
<string name="mon_no_match">没有符合筛选条件的内容</string>
|
<string name="mon_no_match">没有符合筛选条件的内容</string>
|
||||||
<string name="bl_title">屏蔽</string>
|
<string name="bl_title">屏蔽</string>
|
||||||
|
<string name="servers_update">更新服务器列表</string>
|
||||||
|
<string name="servers_updated">服务器列表已更新</string>
|
||||||
|
<string name="servers_update_failed">无法更新服务器列表:%1$s</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
<string name="bl_list_info">%1$s domains · %2$s</string>
|
<string name="bl_list_info">%1$s domains · %2$s</string>
|
||||||
<string name="bl_presets">Popular lists</string>
|
<string name="bl_presets">Popular lists</string>
|
||||||
<string name="bl_download_failed">Download failed: %1$s</string>
|
<string name="bl_download_failed">Download failed: %1$s</string>
|
||||||
<string name="about_desc">Encrypted DNS over HTTPS and HTTP/3 for the whole device. Only DNS goes through the local VPN, all other traffic is untouched.</string>
|
<string name="about_desc">Encrypt DNS requests without routing all your traffic through a VPN.</string>
|
||||||
<string name="about_version">Version</string>
|
<string name="about_version">Version</string>
|
||||||
<string name="about_protocol">Protocol</string>
|
<string name="about_protocol">Protocol</string>
|
||||||
<string name="about_http3_yes">Supported on this device</string>
|
<string name="about_http3_yes">Supported on this device</string>
|
||||||
@@ -95,4 +95,7 @@
|
|||||||
<string name="open_settings">Settings</string>
|
<string name="open_settings">Settings</string>
|
||||||
<string name="mon_no_match">Nothing matches the filter</string>
|
<string name="mon_no_match">Nothing matches the filter</string>
|
||||||
<string name="bl_title">Blocking</string>
|
<string name="bl_title">Blocking</string>
|
||||||
|
<string name="servers_update">Update server list</string>
|
||||||
|
<string name="servers_updated">Server list updated</string>
|
||||||
|
<string name="servers_update_failed">Couldn\'t update the server list: %1$s</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
• Jetzt auch auf Deutsch, Japanisch, Litauisch und Chinesisch
|
• Jetzt auch auf Deutsch, Japanisch, Litauisch und Chinesisch
|
||||||
|
• Unabhängige Server: Digitale Gesellschaft, UncensoredDNS, Freifunk München. Cloudflare, Google, AdGuard und Mullvad entfernt
|
||||||
|
• Serverliste lässt sich aus dem Projekt-Repository aktualisieren, jeder Server verlinkt seine Datenschutzerklärung
|
||||||
• Hinweise und Warnungen lassen sich mit ✕ schließen
|
• Hinweise und Warnungen lassen sich mit ✕ schließen
|
||||||
• Aufgeräumter Info-Bildschirm
|
• Aufgeräumter Info-Bildschirm
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
• Now in German, Japanese, Lithuanian and Chinese
|
• Now in German, Japanese, Lithuanian and Chinese
|
||||||
|
• Independent servers: Digitale Gesellschaft, UncensoredDNS, Freifunk München. Cloudflare, Google, AdGuard and Mullvad removed
|
||||||
|
• Update the server list from the project repository; each server links to its privacy policy
|
||||||
• Hints and warnings can be closed with ✕
|
• Hints and warnings can be closed with ✕
|
||||||
• Cleaner About screen
|
• Cleaner About screen
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
• ドイツ語・日本語・リトアニア語・中国語に対応
|
• ドイツ語・日本語・リトアニア語・中国語に対応
|
||||||
|
• 独立系サーバー:Digitale Gesellschaft、UncensoredDNS、Freifunk München。Cloudflare、Google、AdGuard、Mullvad を削除
|
||||||
|
• サーバーリストをプロジェクトのリポジトリから更新できるように。各サーバーにプライバシーポリシーのリンク
|
||||||
• ヒントと警告を ✕ で閉じられるように
|
• ヒントと警告を ✕ で閉じられるように
|
||||||
• 「情報」画面を整理
|
• 「情報」画面を整理
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
• Dabar ir vokiečių, japonų, lietuvių bei kinų kalbomis
|
• Dabar ir vokiečių, japonų, lietuvių bei kinų kalbomis
|
||||||
|
• Nepriklausomi serveriai: Digitale Gesellschaft, UncensoredDNS, Freifunk München. Cloudflare, Google, AdGuard ir Mullvad pašalinti
|
||||||
|
• Serverių sąrašą galima atnaujinti iš projekto saugyklos, prie kiekvieno serverio – nuoroda į privatumo politiką
|
||||||
• Patarimus ir įspėjimus galima uždaryti ✕
|
• Patarimus ir įspėjimus galima uždaryti ✕
|
||||||
• Tvarkingesnis ekranas „Apie“
|
• Tvarkingesnis ekranas „Apie“
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
• Теперь на немецком, японском, литовском и китайском
|
• Теперь на немецком, японском, литовском и китайском
|
||||||
|
• Независимые серверы: Digitale Gesellschaft, UncensoredDNS, Freifunk München. Cloudflare, Google, AdGuard и Mullvad убраны
|
||||||
|
• Список серверов обновляется из репозитория проекта, у каждого сервера есть ссылка на политику конфиденциальности
|
||||||
• Подсказки и предупреждения закрываются крестиком
|
• Подсказки и предупреждения закрываются крестиком
|
||||||
• Обновлён экран «О приложении»
|
• Обновлён экран «О приложении»
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
• 新增德语、日语、立陶宛语和中文
|
• 新增德语、日语、立陶宛语和中文
|
||||||
|
• 独立服务器:Digitale Gesellschaft、UncensoredDNS、Freifunk München;移除 Cloudflare、Google、AdGuard 和 Mullvad
|
||||||
|
• 可从项目仓库更新服务器列表,每个服务器都附有隐私政策链接
|
||||||
• 提示和警告可点 ✕ 关闭
|
• 提示和警告可点 ✕ 关闭
|
||||||
• “关于”页面更简洁
|
• “关于”页面更简洁
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# SparkleDNS server list. How to add a server: see CONTRIBUTING.md
|
||||||
|
# Name | DoH URL | Privacy policy | h3 (optional)
|
||||||
|
|
||||||
|
SkySparkle | https://blog.skysparkle.cc/dns-query | https://skysparkle.cc/privacy?lang=en | h3
|
||||||
|
Quad9 | https://dns.quad9.net/dns-query | https://quad9.net/service/privacy/
|
||||||
|
Digitale Gesellschaft | https://dns.digitale-gesellschaft.ch/dns-query | https://www.digitale-gesellschaft.ch/dns/ | h3
|
||||||
|
UncensoredDNS | https://anycast.uncensoreddns.org/dns-query | https://blog.uncensoreddns.org/faq/
|
||||||
|
Freifunk München | https://doh.ffmuc.net/dns-query | https://ffmuc.net/dns-privacy/ | h3
|
||||||
Reference in New Issue
Block a user