From 97475e681d2b805ca3972490537ab61f87591cc0 Mon Sep 17 00:00:00 2001
From: PeratX <1215714524@qq.com>
Date: Sat, 3 Jun 2017 18:28:43 +0800
Subject: [PATCH] Initial IPv6 support
---
README.md | 4 ++--
.../org/itxtech/daedalus/fragment/DnsTestFragment.java | 10 +++++-----
.../org/itxtech/daedalus/provider/UdpDnsProvider.java | 4 ++--
.../itxtech/daedalus/service/DaedalusVpnService.java | 7 +++----
4 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/README.md b/README.md
index 376431b..ab4ba9c 100644
--- a/README.md
+++ b/README.md
@@ -30,13 +30,13 @@ Features:
__Users must comply with local laws and regulations.__
-DNS server providers
+DNS Server Providers
-------------
* __CuteDNS__ - *Restart service recently.*
* __[Pure DNS](http://puredns.cn/)__ - *I DO NOT KNOW HOW TO DESCRIBE~~~*
* __[AIXYZ DNS](https://aixyz.com/)__ - __*For academic purposes only.*__
-Rule providers
+Rule Providers
-------------
* __[hosts](https://github.com/racaljk/hosts)__ by *[Cthulhu](https://github.com/racaljk)* - [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh)
* __[google-hosts](https://github.com/fengixng/google-hosts)__ by *[fengixng](https://github.com/fengixng)* - None
diff --git a/app/src/main/java/org/itxtech/daedalus/fragment/DnsTestFragment.java b/app/src/main/java/org/itxtech/daedalus/fragment/DnsTestFragment.java
index 3373c42..e0d551a 100644
--- a/app/src/main/java/org/itxtech/daedalus/fragment/DnsTestFragment.java
+++ b/app/src/main/java/org/itxtech/daedalus/fragment/DnsTestFragment.java
@@ -15,8 +15,8 @@ import de.measite.minidns.DNSMessage;
import de.measite.minidns.Question;
import de.measite.minidns.Record;
import de.measite.minidns.record.A;
+import de.measite.minidns.record.InternetAddressRR;
import de.measite.minidns.source.NetworkDataSource;
-import de.measite.minidns.util.InetAddressUtil;
import org.itxtech.daedalus.Daedalus;
import org.itxtech.daedalus.R;
import org.itxtech.daedalus.util.DnsServerHelper;
@@ -103,13 +103,13 @@ public class DnsTestFragment extends ToolbarFragment {
try {
long startTime = System.currentTimeMillis();
- DNSMessage responseMessage = dnsQuery.query(message.build(), InetAddressUtil.ipv4From(dnsServer), 53);//Auto forward ports
+ DNSMessage responseMessage = dnsQuery.query(message.build(), InetAddress.getByName(dnsServer), 53);//Auto forward ports
long endTime = System.currentTimeMillis();
- Set answers = responseMessage.getAnswersFor(question);
+ Set answers = responseMessage.getAnswersFor(question);
if (answers != null && answers.size() > 0) {
- for (A a : answers) {
- InetAddress inetAddress = a.getInetAddress();
+ for (InternetAddressRR answer : answers) {
+ InetAddress inetAddress = answer.getInetAddress();
testText.append("\n").append(getResources().getString(R.string.test_result_resolved)).append(" ").append(inetAddress.getHostAddress());
}
testText.append("\n").append(getResources().getString(R.string.test_time_used)).append(" ").
diff --git a/app/src/main/java/org/itxtech/daedalus/provider/UdpDnsProvider.java b/app/src/main/java/org/itxtech/daedalus/provider/UdpDnsProvider.java
index 996041c..7af8331 100644
--- a/app/src/main/java/org/itxtech/daedalus/provider/UdpDnsProvider.java
+++ b/app/src/main/java/org/itxtech/daedalus/provider/UdpDnsProvider.java
@@ -345,8 +345,8 @@ public class UdpDnsProvider extends DnsProvider {
String dnsQueryName = dnsMsg.getQuestion().name.toString();
try {
- String response;
- if ((response = RulesResolver.resolve(dnsQueryName)) != null) {
+ String response = RulesResolver.resolve(dnsQueryName);
+ if (response != null) {
Logger.info("DnsProvider: Resolved " + dnsQueryName + " Local resolver response: " + response);
DNSMessage.Builder builder = dnsMsg.asBuilder();
int[] ip = new int[4];
diff --git a/app/src/main/java/org/itxtech/daedalus/service/DaedalusVpnService.java b/app/src/main/java/org/itxtech/daedalus/service/DaedalusVpnService.java
index 8d246a6..1c1327b 100644
--- a/app/src/main/java/org/itxtech/daedalus/service/DaedalusVpnService.java
+++ b/app/src/main/java/org/itxtech/daedalus/service/DaedalusVpnService.java
@@ -11,7 +11,6 @@ import android.os.Build;
import android.os.ParcelFileDescriptor;
import android.support.v7.app.NotificationCompat;
import android.util.Log;
-import de.measite.minidns.util.InetAddressUtil;
import org.itxtech.daedalus.Daedalus;
import org.itxtech.daedalus.R;
import org.itxtech.daedalus.activity.MainActivity;
@@ -23,7 +22,7 @@ import org.itxtech.daedalus.util.DnsServerHelper;
import org.itxtech.daedalus.util.Logger;
import org.itxtech.daedalus.util.RulesResolver;
-import java.net.Inet4Address;
+import java.net.InetAddress;
import java.util.HashMap;
/**
@@ -210,8 +209,8 @@ public class DaedalusVpnService extends VpnService implements Runnable {
aliasSecondary = secondaryServer;
}
- Inet4Address primaryDNSServer = InetAddressUtil.ipv4From(aliasPrimary);
- Inet4Address secondaryDNSServer = InetAddressUtil.ipv4From(aliasSecondary);
+ InetAddress primaryDNSServer = InetAddress.getByName(aliasPrimary);
+ InetAddress secondaryDNSServer = InetAddress.getByName(aliasSecondary);
Logger.info("Daedalus VPN service is listening on " + primaryDNSServer.getHostAddress() + " and " + secondaryDNSServer.getHostAddress());
builder.setSession("Daedalus")
.addDnsServer(primaryDNSServer)