use of org.minidns.dnsmessage.DNSMessage in project minidns by MiniDNS.
the class IterativeDNSClientTest method notGluedNsTest.
@SuppressWarnings("unchecked")
@Test
public void notGluedNsTest() throws IOException {
IterativeDNSClient client = new IterativeDNSClient(new LRUCache(0));
applyZones(client, rootZone(record("com", ns("ns.com")), record("net", ns("ns.net")), record("ns.com", a("1.1.1.1")), record("ns.net", a("1.1.2.1"))), zone("com", "ns.com", "1.1.1.1", record("example.com", ns("example.ns.net"))), zone("net", "ns.net", "1.1.2.1", record("example.ns.net", a("1.1.2.2"))), zone("example.com", "example.ns.net", "1.1.2.2", record("www.example.com", a("1.1.1.3"))));
DNSMessage message = client.query("www.example.com", TYPE.A);
assertNotNull(message);
List<Record<? extends Data>> answers = message.answerSection;
assertEquals(1, answers.size());
assertEquals(TYPE.A, answers.get(0).type);
assertArrayEquals(new byte[] { 1, 1, 1, 3 }, ((A) answers.get(0).payloadData).getIp());
}
use of org.minidns.dnsmessage.DNSMessage in project minidns by MiniDNS.
the class IterativeDNSClientTest method basicIterativeTest.
@SuppressWarnings("unchecked")
@Test
public void basicIterativeTest() throws IOException {
IterativeDNSClient client = new IterativeDNSClient(new LRUCache(0));
applyZones(client, rootZone(record("com", ns("ns.com")), record("ns.com", a("1.1.1.1"))), zone("com", "ns.com", "1.1.1.1", record("example.com", ns("ns.example.com")), record("ns.example.com", a("1.1.1.2"))), zone("example.com", "ns.example.com", "1.1.1.2", record("www.example.com", a("1.1.1.3"))));
DNSMessage message = client.query("www.example.com", TYPE.A);
assertNotNull(message);
List<Record<? extends Data>> answers = message.answerSection;
assertEquals(1, answers.size());
assertEquals(TYPE.A, answers.get(0).type);
assertArrayEquals(new byte[] { 1, 1, 1, 3 }, ((A) answers.get(0).payloadData).getIp());
}
use of org.minidns.dnsmessage.DNSMessage in project minidns by MiniDNS.
the class MiniDNSStats method gatherStatsFor.
public static StringBuilder gatherStatsFor(DNSSECClient client, String testName, String name, TYPE type) throws IOException {
DNSMessage response;
long start, stop;
start = System.currentTimeMillis();
response = client.query(name, type);
stop = System.currentTimeMillis();
StringBuilder sb = new StringBuilder();
sb.append(testName).append('\n');
char[] headline = new char[testName.length()];
Arrays.fill(headline, '#');
sb.append(headline).append('\n');
sb.append(response).append('\n');
sb.append("Took ").append(stop - start).append("ms").append('\n');
sb.append(getStats(client)).append('\n');
sb.append('\n');
return sb;
}
use of org.minidns.dnsmessage.DNSMessage in project minidns by MiniDNS.
the class DNSSECClientTest method testSingleZSK.
@SuppressWarnings("unchecked")
@Test
public void testSingleZSK() throws IOException {
applyZones(client, signedRootZone(sign(rootKSK, "", rootPrivateKSK, algorithm, record("", rootKSK), record("", rootZSK)), sign(rootZSK, "", rootPrivateZSK, algorithm, record("com", ds("com", digestType, comKSK))), sign(rootZSK, "", rootPrivateZSK, algorithm, record("com", ns("ns.com"))), sign(rootZSK, "", rootPrivateZSK, algorithm, record("ns.com", a("1.1.1.1")))), signedZone("com", "ns.com", "1.1.1.1", sign(comKSK, "com", comPrivateKSK, algorithm, record("com", comKSK)), sign(comKSK, "com", comPrivateKSK, algorithm, record("example.com", a("1.1.1.2")))));
DNSMessage message = client.query("example.com", Record.TYPE.A);
assertNotNull(message);
assertTrue(message.authenticData);
checkCorrectExampleMessage(message);
}
use of org.minidns.dnsmessage.DNSMessage in project minidns by MiniDNS.
the class DNSSECClientTest method testUnknownDelegationDigestType.
@SuppressWarnings("unchecked")
@Test
public void testUnknownDelegationDigestType() throws IOException {
applyZones(client, signedRootZone(sign(rootKSK, "", rootPrivateKSK, algorithm, record("", rootKSK), record("", rootZSK)), sign(rootZSK, "", rootPrivateZSK, algorithm, record("com", ds(comKSK.getKeyTag(), algorithm, (byte) 213, new byte[0]))), sign(rootZSK, "", rootPrivateZSK, algorithm, record("com", ns("ns.com"))), sign(rootZSK, "", rootPrivateZSK, algorithm, record("ns.com", a("1.1.1.1")))), signedZone("com", "ns.com", "1.1.1.1", sign(comKSK, "com", comPrivateKSK, algorithm, record("com", comKSK), record("com", comZSK)), sign(comZSK, "com", comPrivateZSK, algorithm, record("example.com", a("1.1.1.2")))));
DNSMessage message = client.query("example.com", Record.TYPE.A);
assertNotNull(message);
assertFalse(message.authenticData);
checkCorrectExampleMessage(message);
}
Aggregations