aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/measite/minidns/DNSMessage.java
diff options
context:
space:
mode:
authorRene Treffer <treffer@measite.de>2014-06-12 22:39:51 +0200
committerRene Treffer <treffer@measite.de>2014-06-12 22:39:51 +0200
commit4da60e7e2071f41cb35f9eacf048c30f5dbf6ca6 (patch)
treec8a3984980120e921b79311623ab7601eefc8c39 /src/main/java/de/measite/minidns/DNSMessage.java
parent7dd8cfc6e6cd9bafb2cb3a6fdc9866de7d7495a6 (diff)
Simplify cache and extend cache operations.
Remove the external cache dependency and use a simple LRU based on LinkedHashMap. Make it possible to get the parse time of DNSMessage, which means we can evaluate the TTL later on :-)
Diffstat (limited to 'src/main/java/de/measite/minidns/DNSMessage.java')
-rw-r--r--src/main/java/de/measite/minidns/DNSMessage.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/main/java/de/measite/minidns/DNSMessage.java b/src/main/java/de/measite/minidns/DNSMessage.java
index ea1b25c8..977c08d0 100644
--- a/src/main/java/de/measite/minidns/DNSMessage.java
+++ b/src/main/java/de/measite/minidns/DNSMessage.java
@@ -196,6 +196,11 @@ public class DNSMessage {
protected Record additionalResourceRecords[];
/**
+ * The receive timestamp of this message.
+ */
+ protected long receiveTimestamp;
+
+ /**
* Retrieve the current DNS message id.
* @return The current DNS message id.
*/
@@ -212,6 +217,14 @@ public class DNSMessage {
}
/**
+ * Get the receive timestamp if this message was created via parse.
+ * This should be used to evaluate TTLs.
+ */
+ public long getReceiveTimestamp() {
+ return receiveTimestamp;
+ }
+
+ /**
* Retrieve the query type (true or false;
* @return True if this DNS message is a query.
*/
@@ -410,6 +423,7 @@ public class DNSMessage {
message.authenticData = ((header >> 5) & 1) == 1;
message.checkDisabled = ((header >> 4) & 1) == 1;
message.responseCode = RESPONSE_CODE.getResponseCode(header & 0xf);
+ message.receiveTimestamp = System.currentTimeMillis();
int questionCount = dis.readUnsignedShort();
int answerCount = dis.readUnsignedShort();
int nameserverCount = dis.readUnsignedShort();