Experimental option to set own DNS server
This commit is contained in:
parent
7d3fb6c4b9
commit
4d802a0572
6 changed files with 45 additions and 4 deletions
|
@ -10,6 +10,8 @@
|
|||
*/
|
||||
package org.minidns;
|
||||
|
||||
import static org.webrtc.ApplicationContextProvider.getApplicationContext;
|
||||
|
||||
import org.minidns.MiniDnsException.ErrorResponseException;
|
||||
import org.minidns.MiniDnsException.NoQueryPossibleException;
|
||||
import org.minidns.dnsmessage.DnsMessage;
|
||||
|
@ -40,6 +42,8 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import eu.siacs.conversations.R;
|
||||
|
||||
/**
|
||||
* A minimal DNS client for SRV/A/AAAA/NS and CNAME lookups, with IDN support.
|
||||
* This circumvents the missing javax.naming package on android.
|
||||
|
@ -57,14 +61,14 @@ public class DnsClient extends AbstractDnsClient {
|
|||
addDnsServerLookupMechanism(UnixUsingEtcResolvConf.INSTANCE);
|
||||
|
||||
try {
|
||||
Inet4Address dnsforgeV4Dns = InetAddressUtil.ipv4From("176.9.93.198");
|
||||
Inet4Address dnsforgeV4Dns = InetAddressUtil.ipv4From(eu.siacs.conversations.Conversations.getContext().getString(R.string.default_dns_server_ipv4));
|
||||
STATIC_IPV4_DNS_SERVERS.add(dnsforgeV4Dns);
|
||||
} catch (IllegalArgumentException e) {
|
||||
LOGGER.log(Level.WARNING, "Could not add static IPv4 DNS Server", e);
|
||||
}
|
||||
|
||||
try {
|
||||
Inet6Address dnsforgeV6Dns = InetAddressUtil.ipv6From("[2a01:4f8:151:34aa::198]");
|
||||
Inet6Address dnsforgeV6Dns = InetAddressUtil.ipv6From(eu.siacs.conversations.Conversations.getContext().getString(R.string.default_dns_server_ipv6));
|
||||
STATIC_IPV6_DNS_SERVERS.add(dnsforgeV6Dns);
|
||||
} catch (IllegalArgumentException e) {
|
||||
LOGGER.log(Level.WARNING, "Could not add static IPv6 DNS Server", e);
|
||||
|
|
|
@ -10,6 +10,10 @@
|
|||
*/
|
||||
package org.minidns.constants;
|
||||
|
||||
import static org.webrtc.ApplicationContextProvider.getApplicationContext;
|
||||
|
||||
import android.content.res.Resources;
|
||||
|
||||
import java.net.Inet4Address;
|
||||
import java.net.Inet6Address;
|
||||
import java.net.InetAddress;
|
||||
|
@ -18,6 +22,8 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import eu.siacs.conversations.R;
|
||||
|
||||
public class DnsRootServer {
|
||||
|
||||
private static final Map<Character, Inet4Address> IPV4_ROOT_SERVER_MAP = new HashMap<>();
|
||||
|
@ -89,11 +95,19 @@ public class DnsRootServer {
|
|||
}
|
||||
|
||||
public static Inet4Address getRandomIpv4RootServer(Random random) {
|
||||
return IPV4_ROOT_SERVERS[random.nextInt(IPV4_ROOT_SERVERS.length)];
|
||||
if (getApplicationContext().getString(R.string.default_dns_server_ipv4).equals("176.9.93.198")) {
|
||||
return IPV4_ROOT_SERVERS[random.nextInt(IPV4_ROOT_SERVERS.length)];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Inet6Address getRandomIpv6RootServer(Random random) {
|
||||
return IPV6_ROOT_SERVERS[random.nextInt(IPV6_ROOT_SERVERS.length)];
|
||||
if (getApplicationContext().getString(R.string.default_dns_server_ipv6).equals("2a01:4f8:151:34aa::198")) {
|
||||
return IPV6_ROOT_SERVERS[random.nextInt(IPV6_ROOT_SERVERS.length)];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Inet4Address getIpv4RootServerById(char id) {
|
||||
|
|
5
src/main/res/drawable/outline_dns_24.xml
Normal file
5
src/main/res/drawable/outline_dns_24.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="?colorControlNormal" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">
|
||||
|
||||
<path android:fillColor="@android:color/white" android:pathData="M300,240Q275,240 257.5,257.5Q240,275 240,300Q240,325 257.5,342.5Q275,360 300,360Q325,360 342.5,342.5Q360,325 360,300Q360,275 342.5,257.5Q325,240 300,240ZM300,640Q275,640 257.5,657.5Q240,675 240,700Q240,725 257.5,742.5Q275,760 300,760Q325,760 342.5,742.5Q360,725 360,700Q360,675 342.5,657.5Q325,640 300,640ZM160,120L800,120Q817,120 828.5,131.5Q840,143 840,160L840,440Q840,457 828.5,468.5Q817,480 800,480L160,480Q143,480 131.5,468.5Q120,457 120,440L120,160Q120,143 131.5,131.5Q143,120 160,120ZM200,200L200,400L760,400L760,200L200,200ZM160,520L800,520Q817,520 828.5,531.5Q840,543 840,560L840,840Q840,857 828.5,868.5Q817,880 800,880L160,880Q143,880 131.5,868.5Q120,857 120,840L120,560Q120,543 131.5,531.5Q143,520 160,520ZM200,600L200,800L760,800L760,600L200,600ZM200,200L200,200L200,400L200,400L200,200ZM200,600L200,600L200,800L200,800L200,600Z"/>
|
||||
|
||||
</vector>
|
|
@ -59,4 +59,6 @@
|
|||
<bool name="show_nav_bar">true</bool>
|
||||
<bool name="enforce_dane">false</bool>
|
||||
<string name="default_chat_requests">spam</string>
|
||||
<string name="default_dns_server_ipv4">176.9.93.198</string>
|
||||
<string name="default_dns_server_ipv6">[2a01:4f8:151:34aa::198]</string>
|
||||
</resources>
|
||||
|
|
|
@ -1308,4 +1308,8 @@
|
|||
<string name="pref_showtextformatting_sum">Show text formatting toolbar in chat while keyboard is shown</string>
|
||||
<string name="pref_showtextformatting">Text formatting toolbar</string>
|
||||
<string name="pref_chat_requests">Hide chats in Chat Requests area</string>
|
||||
<string name="pref_dns_server_ipv4_summary">Change the IPv4 DNS server used by monocles chat</string>
|
||||
<string name="pref_dns_server_ipv4_title">IPv4 DNS server</string>
|
||||
<string name="pref_dns_server_ipv6_title">IPv6 DNS server</string>
|
||||
<string name="pref_dns_server_ipv6_summary">Change the default IPv6 DNS server</string>
|
||||
</resources>
|
|
@ -14,6 +14,18 @@
|
|||
android:key="use_tor"
|
||||
android:summary="@string/pref_use_tor_summary"
|
||||
android:title="@string/pref_use_tor" />
|
||||
<EditTextPreference
|
||||
android:defaultValue="@string/default_dns_server_ipv4"
|
||||
android:icon="@drawable/outline_dns_24"
|
||||
android:key="dns_server_ipv4"
|
||||
android:summary="@string/pref_dns_server_ipv4_summary"
|
||||
android:title="@string/pref_dns_server_ipv4_title" />
|
||||
<EditTextPreference
|
||||
android:defaultValue="@string/default_dns_server_ipv6"
|
||||
android:icon="@drawable/outline_dns_24"
|
||||
android:key="dns_server_ipv6"
|
||||
android:summary="@string/pref_dns_server_ipv6_summary"
|
||||
android:title="@string/pref_dns_server_ipv6_title" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
|
|
Loading…
Add table
Reference in a new issue