Search in sources :

Example 6 with EDNS

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;
}
Also used : OPT(org.minidns.record.OPT) EDNS(org.minidns.edns.EDNS)

Example 7 with 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;
}
Also used : EDNS(org.minidns.edns.EDNS)

Aggregations

EDNS (org.minidns.edns.EDNS)7 Test (org.junit.Test)4 DNSMessage (org.minidns.dnsmessage.DNSMessage)4 Data (org.minidns.record.Data)3 Record (org.minidns.record.Record)3 OPT (org.minidns.record.OPT)2 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 DNSKEY (org.minidns.record.DNSKEY)1 DS (org.minidns.record.DS)1 RRSIG (org.minidns.record.RRSIG)1