Skip to content

Commit

Permalink
Release v1.9.0 & Improved DNSTest
Browse files Browse the repository at this point in the history
  • Loading branch information
PeratX committed Jun 12, 2017
1 parent 0afb755 commit 1a3eb4a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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}\""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.io.IOException;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;

/**
Expand Down Expand Up @@ -110,16 +109,29 @@ public void run() {
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();
Expand All @@ -129,9 +141,9 @@ public void run() {
}


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();

Expand All @@ -143,7 +155,7 @@ private StringBuilder testServer(DNSQuery dnsQuery, Record.TYPE type, String ser
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* 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;
Expand All @@ -38,7 +38,9 @@ public int getPort() {
return port;
}

public abstract String getName();
public String getName() {
return "";
}

@Override
public String toString() {
Expand Down

0 comments on commit 1a3eb4a

Please sign in to comment.