Release v1.9.0 & Improved DNSTest
This commit is contained in:
parent
0afb7553a9
commit
1a3eb4a376
@ -10,8 +10,8 @@ android {
|
||||
applicationId "org.itxtech.daedalus"
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 25
|
||||
versionCode 8
|
||||
versionName "1.8.0"
|
||||
versionCode 9
|
||||
versionName "1.9.0"
|
||||
|
||||
buildConfigField "String", "BUILD_TIME", "\"${System.currentTimeMillis()}\""
|
||||
buildConfigField "String", "GIT_COMMIT", "\"${gitCommit}\""
|
||||
|
@ -22,7 +22,6 @@ import org.itxtech.daedalus.util.server.DNSServerHelper;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
@ -110,16 +109,29 @@ public class DnsTestFragment extends ToolbarFragment {
|
||||
testDomain = Daedalus.DEFAULT_TEST_DOMAINS[0];
|
||||
}
|
||||
StringBuilder testText = new StringBuilder();
|
||||
ArrayList<String> dnsServers = new ArrayList<String>() {{
|
||||
add(((AbstractDNSServer) spinnerServerChoice.getSelectedItem()).getAddress());
|
||||
ArrayList<AbstractDNSServer> dnsServers = new ArrayList<AbstractDNSServer>() {{
|
||||
add(((AbstractDNSServer) spinnerServerChoice.getSelectedItem()));
|
||||
String servers = Daedalus.getPrefs().getString("dns_test_servers", "");
|
||||
if (!servers.equals("")) {
|
||||
addAll(Arrays.asList(servers.split(",")));
|
||||
for (String server : servers.split(",")) {
|
||||
if (server.contains(":")) {
|
||||
String[] pieces = servers.split(":");
|
||||
int port = AbstractDNSServer.DNS_SERVER_DEFAULT_PORT;
|
||||
try {
|
||||
port = Integer.parseInt(pieces[1]);
|
||||
} catch (Exception e) {
|
||||
Logger.logException(e);
|
||||
}
|
||||
add(new AbstractDNSServer(pieces[0], port));
|
||||
} else {
|
||||
add(new AbstractDNSServer(server, AbstractDNSServer.DNS_SERVER_DEFAULT_PORT));
|
||||
}
|
||||
}
|
||||
}
|
||||
}};
|
||||
DNSQuery dnsQuery = new DNSQuery();
|
||||
Record.TYPE type = ((Type) spinnerType.getSelectedItem()).getType();
|
||||
for (String dnsServer : dnsServers) {
|
||||
for (AbstractDNSServer dnsServer : dnsServers) {
|
||||
testText = testServer(dnsQuery, type, dnsServer, testDomain, testText);
|
||||
}
|
||||
mHandler.obtainMessage(DnsTestHandler.MSG_TEST_DONE).sendToTarget();
|
||||
@ -129,9 +141,9 @@ public class DnsTestFragment extends ToolbarFragment {
|
||||
}
|
||||
|
||||
|
||||
private StringBuilder testServer(DNSQuery dnsQuery, Record.TYPE type, String server, String domain, StringBuilder testText) {
|
||||
private StringBuilder testServer(DNSQuery dnsQuery, Record.TYPE type, AbstractDNSServer server, String domain, StringBuilder testText) {
|
||||
Logger.debug("Testing DNS server " + server);
|
||||
testText.append(getString(R.string.test_domain)).append(" ").append(domain).append("\n").append(getString(R.string.test_dns_server)).append(" ").append(server);
|
||||
testText.append(getString(R.string.test_domain)).append(" ").append(domain).append("\n").append(getString(R.string.test_dns_server)).append(" ").append(server.getAddress()).append(":").append(server.getPort());
|
||||
|
||||
mHandler.obtainMessage(DnsTestHandler.MSG_DISPLAY_STATUS, testText.toString()).sendToTarget();
|
||||
|
||||
@ -143,7 +155,7 @@ public class DnsTestFragment extends ToolbarFragment {
|
||||
message.getEdnsBuilder().setUdpPayloadSize(1024).setDnssecOk(false);
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
DNSMessage response = dnsQuery.query(message.build(), InetAddress.getByName(server), 53);
|
||||
DNSMessage response = dnsQuery.query(message.build(), InetAddress.getByName(server.getAddress()), server.getPort());
|
||||
long endTime = System.currentTimeMillis();
|
||||
|
||||
if (response.answerSection.size() > 0) {
|
||||
|
@ -11,7 +11,7 @@ package org.itxtech.daedalus.util.server;
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*/
|
||||
abstract public class AbstractDNSServer {
|
||||
public class AbstractDNSServer {
|
||||
public static final int DNS_SERVER_DEFAULT_PORT = 53;
|
||||
|
||||
protected String address;
|
||||
@ -38,7 +38,9 @@ abstract public class AbstractDNSServer {
|
||||
return port;
|
||||
}
|
||||
|
||||
public abstract String getName();
|
||||
public String getName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
Loading…
Reference in New Issue
Block a user