Search in sources :

Example 1 with OPT

use of org.minidns.record.OPT in project minidns by MiniDNS.

the class DNSMessageTest method testMessageSelfOptRecordReconstructione.

@SuppressWarnings("unchecked")
@Test
public void testMessageSelfOptRecordReconstructione() throws Exception {
    DNSMessage.Builder m = DNSMessage.builder();
    m.addAdditionalResourceRecord(record("www.example.com", a("127.0.0.1")));
    m.getEdnsBuilder().setUdpPayloadSize(512).setDnssecOk();
    DNSMessage message = new DNSMessage(m.build().toArray());
    assertEquals(2, message.additionalSection.size());
    assertCsEquals("www.example.com", message.additionalSection.get(0).name);
    assertEquals(TYPE.A, message.additionalSection.get(0).type);
    assertCsEquals("127.0.0.1", message.additionalSection.get(0).payloadData.toString());
    assertCsEquals("EDNS: version: 0, flags: do; udp: 512", new EDNS((Record<OPT>) message.additionalSection.get(1)).toString());
}
Also used : OPT(org.minidns.record.OPT) EDNS(org.minidns.edns.EDNS) DNSMessage(org.minidns.dnsmessage.DNSMessage) Test(org.junit.Test)

Example 2 with OPT

use of org.minidns.record.OPT 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)

Aggregations

EDNS (org.minidns.edns.EDNS)2 OPT (org.minidns.record.OPT)2 Test (org.junit.Test)1 DNSMessage (org.minidns.dnsmessage.DNSMessage)1