Fixed cannot use the last build-in DNS server

This commit is contained in:
PeratX 2017-06-05 18:49:11 +08:00
parent e40e93b9bf
commit 9b7bd3687d
3 changed files with 5 additions and 19 deletions

View File

@ -148,7 +148,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
activateCounter++;
Daedalus.configurations.setActivateCounter(activateCounter);
if (activateCounter % 20 == 0) {
if (activateCounter % 10 == 0) {
new AlertDialog.Builder(this)
.setTitle("觉得还不错?")
.setMessage("您的支持是我动力来源!\n请考虑为我买杯咖啡醒醒脑甚至其他…… ;)")

View File

@ -144,11 +144,11 @@ public class DnsTestFragment extends ToolbarFragment {
message.getEdnsBuilder().setUdpPayloadSize(1024).setDnssecOk(false);
long startTime = System.currentTimeMillis();
DNSMessage responseAMessage = dnsQuery.query(message.build(), InetAddress.getByName(server), 53);
DNSMessage response = dnsQuery.query(message.build(), InetAddress.getByName(server), 53);
long endTime = System.currentTimeMillis();
if (responseAMessage.answerSection.size() > 0) {
for (Record record : responseAMessage.answerSection) {
if (response.answerSection.size() > 0) {
for (Record record : response.answerSection) {
if (record.getPayload().getType() == type) {
testText.append("\n").append(getString(R.string.test_result_resolved)).append(" ").append(record.getPayload().toString());
}

View File

@ -70,7 +70,7 @@ public class DNSServerHelper {
}
private static int checkServerId(int id) {
if (id < (Daedalus.DNS_SERVERS.size() - 1)) {
if (id < Daedalus.DNS_SERVERS.size()) {
return id;
}
for (CustomDNSServer server : Daedalus.configurations.getCustomDNSServers()) {
@ -95,20 +95,6 @@ public class DNSServerHelper {
return Daedalus.DNS_SERVERS.get(0).getAddress();
}
public static String getAddressByDescription(Context context, String description) {
for (DNSServer server : Daedalus.DNS_SERVERS) {
if (server.getStringDescription(context).equals(description)) {
return server.getAddress();
}
}
for (CustomDNSServer customDNSServer : Daedalus.configurations.getCustomDNSServers()) {
if (customDNSServer.getName().equals(description)) {
return customDNSServer.getAddress();
}
}
return Daedalus.DNS_SERVERS.get(0).getAddress();
}
public static String[] getIds() {
ArrayList<String> servers = new ArrayList<>(Daedalus.DNS_SERVERS.size());
for (DNSServer server : Daedalus.DNS_SERVERS) {