public class DnsMessage extends Object
DnsMessage(byte[])) or serialized
(toArray()).| Modifier and Type | Class and Description |
|---|---|
static class | DnsMessage.BuilderBuilder 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.OPCODESymbolic DNS Opcode values. |
static class | DnsMessage.RESPONSE_CODEPossible DNS response codes. |
| Modifier and Type | Field and Description |
|---|---|
List<Record<? extends Data>> | additionalSectionThe additional section. |
List<Record<? extends Data>> | answerSectionThe answers section records. |
boolean | authenticDataTrue if the server regarded the response as authentic. |
boolean | authoritativeAnswerTrue if this is a authorative response. |
List<Record<? extends Data>> | authoritySectionThe Authority Section. |
boolean | checkingDisabledTrue if the server should not perform DNSSEC validation before returning the result. |
int | idThe DNS message id. |
DnsMessage.OPCODE | opcodeThe DNS message opcode. |
int | optRrPositionThe position of the OPT pseudo-record in the additional section, or -1 if none. |
boolean | qrThe QR flag of the DNS message header. |
List<Question> | questionsThe question section content. |
long | receiveTimestampThe receive timestamp. |
boolean | recursionAvailableTrue if recursion is possible. |
boolean | recursionDesiredTrue if the server should recurse. |
DnsMessage.RESPONSE_CODE | responseCodeThe response code of this dns message. |
boolean | truncatedTrue 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)DnsMessage. |
| Modifier and Type | Method and Description |
|---|---|
DnsMessage.Builder | asBuilder()asBuilder. |
DatagramPacket | asDatagram(InetAddress address,
int port)asDatagram. |
DnsMessage | asNormalizedVersion()asNormalizedVersion. |
String | asTerminalOutput()Format the DnsMessage object in a way suitable for terminal output. |
static DnsMessage.Builder | builder()builder. |
(package private) int | calculateHeaderBitmap()Compute the DNS header bitmap |
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)equals. |
<D extends Data> | filterAdditionalSectionBy(Class<D> type)filterAdditionalSectionBy. |
<D extends Data> | filterAnswerSectionBy(Class<D> type)filterAnswerSectionBy. |
<D extends Data> | filterAuthoritySectionBy(Class<D> type)filterAuthoritySectionBy. |
<D extends Data> | getAnswersFor(Question q)getAnswersFor. |
long | getAnswersMinTtl()Get the minimum TTL from all answers in seconds. |
Edns | getEdns()getEdns. |
<D extends Data> | getFirstOfTypeFromAdditionalSection(Class<D> type)getFirstOfTypeFromAdditionalSection. |
<D extends Data> | getFirstOfTypeFromAnswerSection(Class<D> type)getFirstOfTypeFromAnswerSection. |
<D extends Data> | getFirstOfTypeFromAuthoritySection(Class<D> type)getFirstOfTypeFromAuthoritySection. |
ByteBuffer | getInByteBuffer()getInByteBuffer. |
Record<OPT> | getOptPseudoRecord()getOptPseudoRecord. |
Question | getQuestion()getQuestion. |
DnsMessage.Builder | getResponseBuilder(DnsMessage.RESPONSE_CODE responseCode)getResponseBuilder. |
int | hashCode()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()toString. |
void | writeTo(OutputStream outputStream)writeTo. |
void | writeTo(OutputStream outputStream,
boolean writeLength)writeTo. |
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 IOExceptiondata - 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>> filterAnswerSectionBy(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