| 1 |
/* |
| 2 |
* Copyright 2015-2020 the original author or authors |
| 3 |
* |
| 4 |
* This software is licensed under the Apache License, Version 2.0, |
| 5 |
* the GNU Lesser General Public License version 2 or later ("LGPL") |
| 6 |
* and the WTFPL. |
| 7 |
* You may choose either license to govern your use of this software only |
| 8 |
* upon the condition that you accept all of the terms of either |
| 9 |
* the Apache License 2.0, the LGPL 2.1+ or the WTFPL. |
| 10 |
*/ |
| 11 |
package org.minidns.minidnsrepl; |
| 12 |
|
| 13 |
import java.io.IOException; |
| 14 |
|
| 15 |
import org.minidns.cache.ExtendedLruCache; |
| 16 |
import org.minidns.dnsname.DnsName; |
| 17 |
import org.minidns.dnssec.DnssecClient; |
| 18 |
import org.minidns.dnssec.DnssecQueryResult; |
| 19 |
import org.minidns.dnssec.DnssecUnverifiedReason; |
| 20 |
import org.minidns.integrationtest.IntegrationTestTools.CacheConfig; |
| 21 |
import org.minidns.iterative.ReliableDnsClient.Mode; |
| 22 |
import org.minidns.jul.MiniDnsJul; |
| 23 |
import org.minidns.record.Record.TYPE; |
| 24 |
|
| 25 |
public class DnssecStats { |
| 26 |
|
| 27 |
private static final DnsName DOMAIN = DnsName.from("verteiltesysteme.net"); |
| 28 |
private static final TYPE RR_TYPE = TYPE.A; |
| 29 |
|
| 30 |
public static void iterativeDnssecLookupNormalVsExtendedCache() throws IOException { |
| 31 |
// iterativeDnssecLookup(CacheConfig.normal); |
| 32 |
iterativeDnssecLookup(CacheConfig.extended); |
| 33 |
} |
| 34 |
|
| 35 |
private static void iterativeDnssecLookup(CacheConfig cacheConfig) throws IOException { |
| 36 |
DnssecClient client = MiniDnsStats.getClient(cacheConfig); |
| 37 |
client.setMode(Mode.iterativeOnly); |
| 38 |
DnssecQueryResult secRes = client.queryDnssec(DOMAIN, RR_TYPE); |
| 39 |
|
| 40 |
StringBuilder stats = MiniDnsStats.getStats(client); |
| 41 |
stats.append('\n'); |
| 42 |
stats.append(secRes); |
| 43 |
stats.append('\n'); |
| 44 |
for (DnssecUnverifiedReason r : secRes.getUnverifiedReasons()) { |
| 45 |
stats.append(r); |
| 46 |
} |
| 47 |
stats.append("\n\n"); |
| 48 |
// CHECKSTYLE:OFF |
| 49 |
System.out.println(stats); |
| 50 |
// CHECKSTYLE:ON |
| 51 |
} |
| 52 |
|
| 53 |
public static void iterativeDnsssecTest() throws SecurityException, IllegalArgumentException, IOException { |
| 54 |
MiniDnsJul.enableMiniDnsTrace(); |
| 55 |
DnssecClient client = new DnssecClient(new ExtendedLruCache()); |
| 56 |
client.setMode(Mode.iterativeOnly); |
| 57 |
|
| 58 |
DnssecQueryResult secRes = client.queryDnssec("verteiltesysteme.net", TYPE.A); |
| 59 |
|
| 60 |
// CHECKSTYLE:OFF |
| 61 |
System.out.println(secRes); |
| 62 |
// CHECKSTYLE:ON |
| 63 |
} |
| 64 |
|
| 65 |
} |