001/* 002 * Copyright 2015-2024 the original author or authors 003 * 004 * This software is licensed under the Apache License, Version 2.0, 005 * the GNU Lesser General Public License version 2 or later ("LGPL") 006 * and the WTFPL. 007 * You may choose either license to govern your use of this software only 008 * upon the condition that you accept all of the terms of either 009 * the Apache License 2.0, the LGPL 2.1+ or the WTFPL. 010 */ 011package org.minidns.minidnsrepl; 012 013import java.io.IOException; 014 015import org.minidns.cache.ExtendedLruCache; 016import org.minidns.dnsname.DnsName; 017import org.minidns.dnssec.DnssecClient; 018import org.minidns.dnssec.DnssecQueryResult; 019import org.minidns.dnssec.DnssecUnverifiedReason; 020import org.minidns.integrationtest.IntegrationTestTools.CacheConfig; 021import org.minidns.iterative.ReliableDnsClient.Mode; 022import org.minidns.jul.MiniDnsJul; 023import org.minidns.record.Record.TYPE; 024 025public class DnssecStats { 026 027 private static final DnsName DOMAIN = DnsName.from("verteiltesysteme.net"); 028 private static final TYPE RR_TYPE = TYPE.A; 029 030 public static void iterativeDnssecLookupNormalVsExtendedCache() throws IOException { 031 // iterativeDnssecLookup(CacheConfig.normal); 032 iterativeDnssecLookup(CacheConfig.extended); 033 } 034 035 private static void iterativeDnssecLookup(CacheConfig cacheConfig) throws IOException { 036 DnssecClient client = MiniDnsStats.getClient(cacheConfig); 037 client.setMode(Mode.iterativeOnly); 038 DnssecQueryResult secRes = client.queryDnssec(DOMAIN, RR_TYPE); 039 040 StringBuilder stats = MiniDnsStats.getStats(client); 041 stats.append('\n'); 042 stats.append(secRes); 043 stats.append('\n'); 044 for (DnssecUnverifiedReason r : secRes.getUnverifiedReasons()) { 045 stats.append(r); 046 } 047 stats.append("\n\n"); 048 // CHECKSTYLE:OFF 049 System.out.println(stats); 050 // CHECKSTYLE:ON 051 } 052 053 public static void iterativeDnsssecTest() throws SecurityException, IllegalArgumentException, IOException { 054 MiniDnsJul.enableMiniDnsTrace(); 055 DnssecClient client = new DnssecClient(new ExtendedLruCache()); 056 client.setMode(Mode.iterativeOnly); 057 058 DnssecQueryResult secRes = client.queryDnssec("verteiltesysteme.net", TYPE.A); 059 060 // CHECKSTYLE:OFF 061 System.out.println(secRes); 062 // CHECKSTYLE:ON 063 } 064 065}