use of org.minidns.edns.EDNS in project minidns by MiniDNS.
the class DNSMessage method getEdns.
public EDNS getEdns() {
if (edns != null)
return edns;
Record<OPT> optRecord = getOptPseudoRecord();
if (optRecord == null)
return null;
edns = new EDNS(optRecord);
return edns;
}
use of org.minidns.edns.EDNS in project minidns by MiniDNS.
the class DNSMessage method toString.
@Override
public String toString() {
if (toStringCache != null)
return toStringCache;
StringBuilder sb = new StringBuilder("DNSMessage").append('(').append(id).append(' ').append(opcode).append(' ').append(responseCode).append(' ');
if (qr) {
sb.append("resp[qr=1]");
} else {
sb.append("query[qr=0]");
}
if (authoritativeAnswer)
sb.append(" aa");
if (truncated)
sb.append(" tr");
if (recursionDesired)
sb.append(" rd");
if (recursionAvailable)
sb.append(" ra");
if (authenticData)
sb.append(" ad");
if (checkingDisabled)
sb.append(" cd");
sb.append(")\n");
if (questions != null) {
for (Question question : questions) {
sb.append("[Q: ").append(question).append("]\n");
}
}
if (answerSection != null) {
for (Record<? extends Data> record : answerSection) {
sb.append("[A: ").append(record).append("]\n");
}
}
if (authoritySection != null) {
for (Record<? extends Data> record : authoritySection) {
sb.append("[N: ").append(record).append("]\n");
}
}
if (additionalSection != null) {
for (Record<? extends Data> record : additionalSection) {
sb.append("[X: ");
EDNS edns = EDNS.fromRecord(record);
if (edns != null) {
sb.append(edns.toString());
} else {
sb.append(record);
}
sb.append("]\n");
}
}
// Strip trailing newline.
if (sb.charAt(sb.length() - 1) == '\n') {
sb.setLength(sb.length() - 1);
}
toStringCache = sb.toString();
return toStringCache;
}
Aggregations