aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/measite/minidns/Client.java (renamed from src/de/measite/minidns/Client.java)42
-rw-r--r--src/main/java/de/measite/minidns/DNSMessage.java (renamed from src/de/measite/minidns/DNSMessage.java)0
-rw-r--r--src/main/java/de/measite/minidns/Question.java (renamed from src/de/measite/minidns/Question.java)0
-rw-r--r--src/main/java/de/measite/minidns/Record.java (renamed from src/de/measite/minidns/Record.java)0
-rw-r--r--src/main/java/de/measite/minidns/record/A.java (renamed from src/de/measite/minidns/record/A.java)0
-rw-r--r--src/main/java/de/measite/minidns/record/AAAA.java (renamed from src/de/measite/minidns/record/AAAA.java)0
-rw-r--r--src/main/java/de/measite/minidns/record/CNAME.java (renamed from src/de/measite/minidns/record/CNAME.java)0
-rw-r--r--src/main/java/de/measite/minidns/record/Data.java (renamed from src/de/measite/minidns/record/Data.java)0
-rw-r--r--src/main/java/de/measite/minidns/record/NS.java (renamed from src/de/measite/minidns/record/NS.java)0
-rw-r--r--src/main/java/de/measite/minidns/record/SRV.java (renamed from src/de/measite/minidns/record/SRV.java)0
-rw-r--r--src/main/java/de/measite/minidns/util/NameUtil.java (renamed from src/de/measite/minidns/util/NameUtil.java)0
11 files changed, 22 insertions, 20 deletions
diff --git a/src/de/measite/minidns/Client.java b/src/main/java/de/measite/minidns/Client.java
index 8bc75d01..cad3902a 100644
--- a/src/de/measite/minidns/Client.java
+++ b/src/main/java/de/measite/minidns/Client.java
@@ -14,8 +14,9 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Random;
+import java.util.logging.Level;
+import java.util.logging.Logger;
-import android.util.Log;
import de.measite.minidns.Record.CLASS;
import de.measite.minidns.Record.TYPE;
@@ -25,6 +26,8 @@ import de.measite.minidns.Record.TYPE;
*/
public class Client {
+ private static final Logger LOGGER = Logger.getLogger(Client.class.getName());
+
/**
* The internal random class for sequence generation.
*/
@@ -129,18 +132,19 @@ public class Client {
message.setRecursionDesired(true);
message.setId(random.nextInt());
byte[] buf = message.toArray();
- DatagramSocket socket = new DatagramSocket();
- DatagramPacket packet = new DatagramPacket(
- buf, buf.length, InetAddress.getByName(host), port);
- socket.setSoTimeout(timeout);
- socket.send(packet);
- packet = new DatagramPacket(new byte[bufferSize], bufferSize);
- socket.receive(packet);
- DNSMessage dnsMessage = DNSMessage.parse(packet.getData());
- if (dnsMessage.getId() != message.getId()) {
- return null;
+ try (DatagramSocket socket = new DatagramSocket()) {
+ DatagramPacket packet = new DatagramPacket(buf, buf.length,
+ InetAddress.getByName(host), port);
+ socket.setSoTimeout(timeout);
+ socket.send(packet);
+ packet = new DatagramPacket(new byte[bufferSize], bufferSize);
+ socket.receive(packet);
+ DNSMessage dnsMessage = DNSMessage.parse(packet.getData());
+ if (dnsMessage.getId() != message.getId()) {
+ return null;
+ }
+ return dnsMessage;
}
- return dnsMessage;
}
/**
@@ -165,6 +169,7 @@ public class Client {
}
}
} catch (IOException ioe) {
+ LOGGER.log(Level.FINE, "IOException in query", ioe);
}
}
return null;
@@ -177,22 +182,19 @@ public class Client {
public String[] findDNS() {
String[] result = findDNSByReflection();
if (result != null) {
- Log.d("minidns/client",
- "Got DNS servers via reflection: " + Arrays.toString(result));
+ LOGGER.fine("Got DNS servers via reflection: " + Arrays.toString(result));
return result;
}
result = findDNSByExec();
if (result != null) {
- Log.d("minidns/client",
- "Got DNS servers via exec: " + Arrays.toString(result));
+ LOGGER.fine("Got DNS servers via exec: " + Arrays.toString(result));
return result;
}
// fallback for ipv4 and ipv6 connectivity
// see https://developers.google.com/speed/public-dns/docs/using
- Log.d("minidns/client",
- "No DNS found? Using fallback [8.8.8.8, [2001:4860:4860::8888]]");
+ LOGGER.fine("No DNS found? Using fallback [8.8.8.8, [2001:4860:4860::8888]]");
return new String[]{"8.8.8.8", "[2001:4860:4860::8888]"};
}
@@ -238,7 +240,7 @@ public class Client {
return server.toArray(new String[server.size()]);
}
} catch (IOException e) {
- e.printStackTrace();
+ LOGGER.log(Level.WARNING, "Exception in findDNSByExec", e);
}
return null;
}
@@ -283,7 +285,7 @@ public class Client {
}
} catch (Exception e) {
// we might trigger some problems this way
- e.printStackTrace();
+ LOGGER.log(Level.WARNING, "Exception in findDNSByReflection", e);
}
return null;
}
diff --git a/src/de/measite/minidns/DNSMessage.java b/src/main/java/de/measite/minidns/DNSMessage.java
index 14c8f04b..14c8f04b 100644
--- a/src/de/measite/minidns/DNSMessage.java
+++ b/src/main/java/de/measite/minidns/DNSMessage.java
diff --git a/src/de/measite/minidns/Question.java b/src/main/java/de/measite/minidns/Question.java
index 9d1e3f56..9d1e3f56 100644
--- a/src/de/measite/minidns/Question.java
+++ b/src/main/java/de/measite/minidns/Question.java
diff --git a/src/de/measite/minidns/Record.java b/src/main/java/de/measite/minidns/Record.java
index fb0b5d5f..fb0b5d5f 100644
--- a/src/de/measite/minidns/Record.java
+++ b/src/main/java/de/measite/minidns/Record.java
diff --git a/src/de/measite/minidns/record/A.java b/src/main/java/de/measite/minidns/record/A.java
index a85a7af0..a85a7af0 100644
--- a/src/de/measite/minidns/record/A.java
+++ b/src/main/java/de/measite/minidns/record/A.java
diff --git a/src/de/measite/minidns/record/AAAA.java b/src/main/java/de/measite/minidns/record/AAAA.java
index d89147b2..d89147b2 100644
--- a/src/de/measite/minidns/record/AAAA.java
+++ b/src/main/java/de/measite/minidns/record/AAAA.java
diff --git a/src/de/measite/minidns/record/CNAME.java b/src/main/java/de/measite/minidns/record/CNAME.java
index 4657b4a5..4657b4a5 100644
--- a/src/de/measite/minidns/record/CNAME.java
+++ b/src/main/java/de/measite/minidns/record/CNAME.java
diff --git a/src/de/measite/minidns/record/Data.java b/src/main/java/de/measite/minidns/record/Data.java
index 9cb80374..9cb80374 100644
--- a/src/de/measite/minidns/record/Data.java
+++ b/src/main/java/de/measite/minidns/record/Data.java
diff --git a/src/de/measite/minidns/record/NS.java b/src/main/java/de/measite/minidns/record/NS.java
index bf07e8c4..bf07e8c4 100644
--- a/src/de/measite/minidns/record/NS.java
+++ b/src/main/java/de/measite/minidns/record/NS.java
diff --git a/src/de/measite/minidns/record/SRV.java b/src/main/java/de/measite/minidns/record/SRV.java
index 32b70c4d..32b70c4d 100644
--- a/src/de/measite/minidns/record/SRV.java
+++ b/src/main/java/de/measite/minidns/record/SRV.java
diff --git a/src/de/measite/minidns/util/NameUtil.java b/src/main/java/de/measite/minidns/util/NameUtil.java
index 91a6649d..91a6649d 100644
--- a/src/de/measite/minidns/util/NameUtil.java
+++ b/src/main/java/de/measite/minidns/util/NameUtil.java