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;
}
}
}
}
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);
}
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());
}
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());
}
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();
}
Aggregations