public class DnsMessage extends Object
DnsMessage(byte[])
) or serialized
(toArray()
).Modifier and Type | Class and Description |
---|---|
static class |
DnsMessage.Builder |
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 int id
public final DnsMessage.OPCODE opcode
public final DnsMessage.RESPONSE_CODE responseCode
public final boolean qr
true
if the message is a
response and false
if it is a query.public final boolean authoritativeAnswer
public final boolean truncated
public final boolean recursionDesired
public final boolean recursionAvailable
public final boolean authenticData
public final boolean checkingDisabled
public final List<Question> questions
This list is unmodifiable.
public final List<Record<? extends Data>> answerSection
This list is unmodifiable.
public final List<Record<? extends Data>> authoritySection
This list is unmodifiable.
public final List<Record<? extends Data>> additionalSection
This list is unmodifiable.
public final int optRrPosition
public final long receiveTimestamp
protected DnsMessage(DnsMessage.Builder builder)
public DnsMessage(byte[] data) throws IOException
data
- The DNS message data.IOException
- On read errors.public byte[] toArray()
public DatagramPacket asDatagram(InetAddress address, int port)
public void writeTo(OutputStream outputStream) throws IOException
IOException
public void writeTo(OutputStream outputStream, boolean writeLength) throws IOException
IOException
public ByteBuffer getInByteBuffer()
int calculateHeaderBitmap()
public Question getQuestion()
public List<Question> copyQuestions()
questions
public List<Record<? extends Data>> copyAnswers()
answerSection
public List<Record<? extends Data>> copyAuthority()
authoritySection
public Edns getEdns()
public boolean isDnssecOk()
public String asTerminalOutput()
dig
.public long getAnswersMinTtl()
public DnsMessage.Builder asBuilder()
public DnsMessage asNormalizedVersion()
public DnsMessage.Builder getResponseBuilder(DnsMessage.RESPONSE_CODE responseCode)
public <D extends Data> List<Record<D>> filterAuthoritySectionBy(Class<D> type)
public <D extends Data> List<Record<D>> filterAdditionalSectionBy(Class<D> type)
public <D extends Data> Record<D> getFirstOfTypeFromAnswerSection(Class<D> type)
public <D extends Data> Record<D> getFirstOfTypeFromAuthoritySection(Class<D> type)
public <D extends Data> Record<D> getFirstOfTypeFromAdditionalSection(Class<D> type)
public static DnsMessage.Builder builder()