DivestOS/Patches/LineageOS-18.1/android_frameworks_base/0012-Private_DNS.patch

105 lines
4.0 KiB
Diff
Raw Normal View History

From f62f32f8dc9940f7da0c1f527035367de2ae5fc5 Mon Sep 17 00:00:00 2001
From: Tad <tad@spotco.us>
Date: Thu, 21 Oct 2021 20:54:37 -0400
Subject: [PATCH] Add more 'Private DNS' options
This adds: Quad9, Cloudflare, and AdGuard
Credit: CalyxOS
- Chirayu Desai <chirayudesai1@gmail.com>
https://review.calyxos.org/c/CalyxOS/platform_frameworks_base/+/446
- Oliver Scott <olivercscott@gmail.com>
https://review.calyxos.org/c/CalyxOS/platform_frameworks_base/+/2327
- Pavel Shirshov <pshirshov@eml.cc>
https://review.calyxos.org/c/CalyxOS/platform_frameworks_base/+/5356
Signed-off-by: Tad <tad@spotco.us>
Change-Id: Id75a774ce1ed109a83c6a5bf512536c643165d71
---
.../java/android/net/ConnectivityManager.java | 24 +++++++++++++++++++
.../server/connectivity/DnsManager.java | 18 ++++++++++++++
2 files changed, 42 insertions(+)
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index ed03f5198d6f..754ee2583002 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -796,6 +796,18 @@ public class ConnectivityManager {
* @hide
*/
public static final String PRIVATE_DNS_MODE_OFF = "off";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_QUADNINE = "quadnine";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_CLOUDFLARE = "cloudflare";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_ADGUARD = "adguard";
/**
* @hide
*/
@@ -804,6 +816,18 @@ public class ConnectivityManager {
* @hide
*/
public static final String PRIVATE_DNS_MODE_PROVIDER_HOSTNAME = "hostname";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_SPECIFIER_QUADNINE = "dns.quad9.net";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_SPECIFIER_CLOUDFLARE = "one.one.one.one";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_SPECIFIER_ADGUARD = "dns.adguard.com";
/**
* The default Private DNS mode.
*
diff --git a/services/core/java/com/android/server/connectivity/DnsManager.java b/services/core/java/com/android/server/connectivity/DnsManager.java
index cf6a7f6e8d70..0410d54ac8a7 100644
--- a/services/core/java/com/android/server/connectivity/DnsManager.java
+++ b/services/core/java/com/android/server/connectivity/DnsManager.java
@@ -18,7 +18,13 @@ package com.android.server.connectivity;
import static android.net.ConnectivityManager.PRIVATE_DNS_DEFAULT_MODE_FALLBACK;
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OFF;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_QUADNINE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CLOUDFLARE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_ADGUARD;
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_QUADNINE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_CLOUDFLARE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_ADGUARD;
import static android.provider.Settings.Global.DNS_RESOLVER_MAX_SAMPLES;
import static android.provider.Settings.Global.DNS_RESOLVER_MIN_SAMPLES;
import static android.provider.Settings.Global.DNS_RESOLVER_SAMPLE_VALIDITY_SECONDS;
@@ -136,6 +142,18 @@ public class DnsManager {
return new PrivateDnsConfig(specifier, null);
}
+ if (PRIVATE_DNS_MODE_QUADNINE.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_QUADNINE, null);
+ }
+
+ if (PRIVATE_DNS_MODE_CLOUDFLARE.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_CLOUDFLARE, null);
+ }
+
+ if (PRIVATE_DNS_MODE_ADGUARD.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_ADGUARD, null);
+ }
+
return new PrivateDnsConfig(useTls);
}
--
2.31.1