Search in sources :

Example 26 with DnsMessage

use of org.minidns.dnsmessage.DnsMessage in project minidns by MiniDNS.

the class DNSMessageTest method testComNsec3Lookup.

@Test
public void testComNsec3Lookup() throws Exception {
    DNSMessage m = getMessageFromResource("com-nsec3");
    assertEquals(0, m.answerSection.size());
    List<Record<? extends Data>> records = m.authoritySection;
    assertEquals(8, records.size());
    for (Record<? extends Data> record : records) {
        if (record.type == TYPE.NSEC3) {
            assertEquals(TYPE.NSEC3, record.getPayload().getType());
            NSEC3 nsec3 = (NSEC3) record.payloadData;
            assertEquals(HashAlgorithm.SHA1, nsec3.hashAlgorithm);
            assertEquals(1, nsec3.flags);
            assertEquals(0, nsec3.iterations);
            assertEquals(0, nsec3.salt.length);
            switch(record.name.ace) {
                case "CK0POJMG874LJREF7EFN8430QVIT8BSM.com":
                    assertCsEquals("CK0QFMDQRCSRU0651QLVA1JQB21IF7UR", Base32.encodeToString(nsec3.nextHashed));
                    assertArrayContentEquals(new TYPE[] { TYPE.NS, TYPE.SOA, TYPE.RRSIG, TYPE.DNSKEY, TYPE.NSEC3PARAM }, nsec3.types);
                    break;
                case "V2I33UBTHNVNSP9NS85CURCLSTFPTE24.com":
                    assertCsEquals("V2I4KPUS7NGDML5EEJU3MVHO26GKB6PA", Base32.encodeToString(nsec3.nextHashed));
                    assertArrayContentEquals(new TYPE[] { TYPE.NS, TYPE.DS, TYPE.RRSIG }, nsec3.types);
                    break;
                case "3RL20VCNK6KV8OT9TDIJPI0JU1SS6ONS.com":
                    assertCsEquals("3RL3UFVFRUE94PV5888AIC2TPS0JA9V2", Base32.encodeToString(nsec3.nextHashed));
                    assertArrayContentEquals(new TYPE[] { TYPE.NS, TYPE.DS, TYPE.RRSIG }, nsec3.types);
                    break;
            }
        }
    }
}
Also used : NSEC3(org.minidns.record.NSEC3) Record(org.minidns.record.Record) Data(org.minidns.record.Data) DNSMessage(org.minidns.dnsmessage.DNSMessage) Test(org.junit.Test)

Example 27 with DnsMessage

use of org.minidns.dnsmessage.DnsMessage in project minidns by MiniDNS.

the class DNSMessageTest method testSoaLookup.

@Test
public void testSoaLookup() throws Exception {
    DNSMessage m = getMessageFromResource("oracle-soa");
    assertFalse(m.authoritativeAnswer);
    List<Record<? extends Data>> answers = m.answerSection;
    assertEquals(1, answers.size());
    Record<? extends Data> answer = answers.get(0);
    assertTrue(answer.getPayload() instanceof SOA);
    assertEquals(TYPE.SOA, answer.getPayload().getType());
    SOA soa = (SOA) answer.getPayload();
    assertCsEquals("orcldns1.ultradns.com", soa.mname);
    assertCsEquals("hostmaster\\@oracle.com", soa.rname);
    assertEquals(2015032404L, soa.serial);
    assertEquals(10800, soa.refresh);
    assertEquals(3600, soa.retry);
    assertEquals(1209600, soa.expire);
    assertEquals(900L, soa.minimum);
}
Also used : SOA(org.minidns.record.SOA) Record(org.minidns.record.Record) Data(org.minidns.record.Data) DNSMessage(org.minidns.dnsmessage.DNSMessage) Test(org.junit.Test)

Example 28 with DnsMessage

use of org.minidns.dnsmessage.DnsMessage in project minidns by MiniDNS.

the class DNSMessageTest method testEmptyMessageToString.

@Test
public void testEmptyMessageToString() throws Exception {
    // toString() should never throw an exception or be null
    DNSMessage message = DNSMessage.builder().build();
    assertNotNull(message.toString());
}
Also used : DNSMessage(org.minidns.dnsmessage.DNSMessage) Test(org.junit.Test)

Example 29 with DnsMessage

use of org.minidns.dnsmessage.DnsMessage in project minidns by MiniDNS.

the class DNSMessageTest method testALookup.

@Test
public void testALookup() throws Exception {
    DNSMessage m = getMessageFromResource("sun-a");
    assertFalse(m.authoritativeAnswer);
    List<Record<? extends Data>> answers = m.answerSection;
    assertEquals(2, answers.size());
    Record<? extends Data> cname = answers.get(0);
    Record<? extends Data> a = answers.get(1);
    assertTrue(cname.getPayload() instanceof RRWithTarget);
    assertEquals(TYPE.CNAME, cname.getPayload().getType());
    assertCsEquals("legacy-sun.oraclegha.com", ((RRWithTarget) (cname.getPayload())).target);
    assertCsEquals("legacy-sun.oraclegha.com", a.name);
    assertTrue(a.getPayload() instanceof A);
    assertEquals(TYPE.A, a.getPayload().getType());
    assertCsEquals("156.151.59.35", a.getPayload().toString());
}
Also used : AAAA(org.minidns.record.AAAA) SOA(org.minidns.record.SOA) A(org.minidns.record.A) RRWithTarget(org.minidns.record.RRWithTarget) Record(org.minidns.record.Record) Data(org.minidns.record.Data) DNSMessage(org.minidns.dnsmessage.DNSMessage) Test(org.junit.Test)

Example 30 with DnsMessage

use of org.minidns.dnsmessage.DnsMessage in project Smack by igniterealtime.

the class DoX method main.

public static void main(String[] args) throws XMPPException, SmackException, IOException, InterruptedException {
    SmackConfiguration.DEBUG = true;
    XMPPTCPConnection connection = new XMPPTCPConnection(args[0], args[1]);
    connection.setReplyTimeout(60000);
    connection.connect().login();
    DnsOverXmppManager dox = DnsOverXmppManager.getInstanceFor(connection);
    Jid target = JidCreate.from("dns@moparisthebest.com/listener");
    Question question = new Question("geekplace.eu", Record.TYPE.A);
    DnsMessage response = dox.query(target, question);
    // CHECKSTYLE:OFF
    System.out.println(response);
    // CHECKSTYLE:ON
    connection.disconnect();
}
Also used : DnsOverXmppManager(org.jivesoftware.smackx.dox.DnsOverXmppManager) XMPPTCPConnection(org.jivesoftware.smack.tcp.XMPPTCPConnection) Jid(org.jxmpp.jid.Jid) Question(org.minidns.dnsmessage.Question) DnsMessage(org.minidns.dnsmessage.DnsMessage)

Aggregations

DNSMessage (org.minidns.dnsmessage.DNSMessage)67 Test (org.junit.Test)35 Data (org.minidns.record.Data)16 Record (org.minidns.record.Record)16 IOException (java.io.IOException)15 Question (org.minidns.dnsmessage.Question)14 InetAddress (java.net.InetAddress)6 LRUCache (org.minidns.cache.LRUCache)6 ArrayList (java.util.ArrayList)5 DNSClient (org.minidns.DNSClient)5 LinkedList (java.util.LinkedList)4 EDNS (org.minidns.edns.EDNS)4 RRSIG (org.minidns.record.RRSIG)4 Date (java.util.Date)3 Level (java.util.logging.Level)3 InternalMiniDnsFuture (org.minidns.MiniDnsFuture.InternalMiniDnsFuture)3 DNSName (org.minidns.dnsname.DNSName)3 DNSKEY (org.minidns.record.DNSKEY)3 DatagramSocket (java.net.DatagramSocket)2 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2