public class DnsMessage extends Object
DnsMessage(byte[])) or serialized
(toArray()).| Modifier and Type | Class and Description |
|---|---|
static class |
DnsMessage.Builder
Builder class for constructing DNS messages.
Provides a fluent API for building DNS messages with various sections and flags configured step by step. |
static class |
DnsMessage.OPCODE
Symbolic DNS Opcode values.
|
static class |
DnsMessage.RESPONSE_CODE
Possible DNS response codes.
|
| Modifier and Type | Field and Description |
|---|---|
List<Record<? extends Data>> |
additionalSection
The additional section.
|
List<Record<? extends Data>> |
answerSection
The answers section records.
|
boolean |
authenticData
True if the server regarded the response as authentic.
|
boolean |
authoritativeAnswer
True if this is a authorative response.
|
List<Record<? extends Data>> |
authoritySection
The Authority Section.
|
boolean |
checkingDisabled
True if the server should not perform DNSSEC validation before returning the result.
|
int |
id
The DNS message id.
|
DnsMessage.OPCODE |
opcode
The DNS message opcode.
|
int |
optRrPosition |
boolean |
qr
The QR flag of the DNS message header.
|
List<Question> |
questions
The question section content.
|
long |
receiveTimestamp
The receive timestamp.
|
boolean |
recursionAvailable
True if recursion is possible.
|
boolean |
recursionDesired
True if the server should recurse.
|
DnsMessage.RESPONSE_CODE |
responseCode
The response code of this dns message.
|
boolean |
truncated
True if message is truncated.
|
| Modifier | Constructor and Description |
|---|---|
|
DnsMessage(byte[] data)
Build a DNS Message based on a binary DNS message.
|
protected |
DnsMessage(DnsMessage.Builder builder) |
| Modifier and Type | Method and Description |
|---|---|
DnsMessage.Builder |
asBuilder() |
DatagramPacket |
asDatagram(InetAddress address,
int port) |
DnsMessage |
asNormalizedVersion() |
String |
asTerminalOutput()
Format the DnsMessage object in a way suitable for terminal output.
|
static DnsMessage.Builder |
builder() |
(package private) int |
calculateHeaderBitmap() |
List<Record<? extends Data>> |
copyAnswers()
Copy the records found in the answer section into a new list.
|
List<Record<? extends Data>> |
copyAuthority()
Copy the records found in the authority section into a new list.
|
List<Question> |
copyQuestions()
Copy the questions found in the question section.
|
boolean |
equals(Object other) |
<D extends Data> |
filterAdditionalSectionBy(Class<D> type) |
<D extends Data> |
filterAnswerSectionBy(Class<D> type) |
<D extends Data> |
filterAuthoritySectionBy(Class<D> type) |
<D extends Data> |
getAnswersFor(Question q) |
long |
getAnswersMinTtl()
Get the minimum TTL from all answers in seconds.
|
Edns |
getEdns() |
<D extends Data> |
getFirstOfTypeFromAdditionalSection(Class<D> type) |
<D extends Data> |
getFirstOfTypeFromAnswerSection(Class<D> type) |
<D extends Data> |
getFirstOfTypeFromAuthoritySection(Class<D> type) |
ByteBuffer |
getInByteBuffer() |
Record<OPT> |
getOptPseudoRecord() |
Question |
getQuestion() |
DnsMessage.Builder |
getResponseBuilder(DnsMessage.RESPONSE_CODE responseCode) |
int |
hashCode() |
boolean |
isDnssecOk()
Check if the EDNS DO (DNSSEC OK) flag is set.
|
byte[] |
toArray()
Generate a binary dns packet out of this message.
|
String |
toString() |
void |
writeTo(OutputStream outputStream) |
void |
writeTo(OutputStream outputStream,
boolean writeLength) |
public final List<Record<? extends Data>> additionalSection
This list is unmodifiable.
public final List<Record<? extends Data>> answerSection
This list is unmodifiable.
public final boolean authenticData
public final boolean authoritativeAnswer
public final List<Record<? extends Data>> authoritySection
This list is unmodifiable.
public final boolean checkingDisabled
public final int id
public final DnsMessage.OPCODE opcode
public final int optRrPosition
public final boolean qr
true if the message is a
response and false if it is a query.public final List<Question> questions
This list is unmodifiable.
public final long receiveTimestamp
public final boolean recursionAvailable
public final boolean recursionDesired
public final DnsMessage.RESPONSE_CODE responseCode
public final boolean truncated
public DnsMessage(byte[] data)
throws IOException
data - The DNS message data.IOException - On read errors.protected DnsMessage(DnsMessage.Builder builder)
public DnsMessage.Builder asBuilder()
public DatagramPacket asDatagram(InetAddress address, int port)
public DnsMessage asNormalizedVersion()
public String asTerminalOutput()
dig.public static DnsMessage.Builder builder()
int calculateHeaderBitmap()
public List<Record<? extends Data>> copyAnswers()
answerSectionpublic List<Record<? extends Data>> copyAuthority()
authoritySectionpublic List<Question> copyQuestions()
questionspublic <D extends Data> List<Record<D>> filterAdditionalSectionBy(Class<D> type)
public <D extends Data> List<Record<D>> filterAuthoritySectionBy(Class<D> type)
public long getAnswersMinTtl()
public Edns getEdns()
public <D extends Data> Record<D> getFirstOfTypeFromAdditionalSection(Class<D> type)
public <D extends Data> Record<D> getFirstOfTypeFromAnswerSection(Class<D> type)
public <D extends Data> Record<D> getFirstOfTypeFromAuthoritySection(Class<D> type)
public ByteBuffer getInByteBuffer()
public Question getQuestion()
public DnsMessage.Builder getResponseBuilder(DnsMessage.RESPONSE_CODE responseCode)
public boolean isDnssecOk()
public byte[] toArray()
public void writeTo(OutputStream outputStream) throws IOException
IOExceptionpublic void writeTo(OutputStream outputStream, boolean writeLength) throws IOException
IOException