1 /* 2 * This file is a part of DNSViz, a tool suite for DNS/DNSSEC monitoring, 3 * analysis, and visualization. 4 * Created by Casey Deccio (casey@deccio.net) 5 * 6 * Copyright 2016 VeriSign, Inc. 7 * 8 * DNSViz is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * DNSViz is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License along 19 * with DNSViz. If not, see <http://www.gnu.org/licenses/>. 20 */ 21 22 package net.dnsviz.applet; 23 24 import java.applet.Applet; 25 import java.io.IOException; 26 import java.io.PrintWriter; 27 import java.io.StringWriter; 28 import java.net.InetAddress; 29 import java.net.UnknownHostException; 30 31 import net.dnsviz.transport.DNSQueryTransportHandler; 32 import net.dnsviz.util.DNSSettings; 33 34 import net.dnsviz.lookingglass.DNSLookingGlass; 35 36 public class DNSLookingGlassApplet extends Applet { 37 static final long serialVersionUID = 0; 38 private Exception err = null; 39 private DNSLookingGlass lg = null; 40 DNSLookingGlassApplet()41 public DNSLookingGlassApplet() { 42 lg = new DNSLookingGlass(); 43 } 44 getDNSQueryTransportHandler(String req, String dst, int dport, String src, int sport, long timeout, boolean tcp)45 public DNSQueryTransportHandler getDNSQueryTransportHandler(String req, String dst, int dport, String src, int sport, long timeout, boolean tcp) { 46 err = null; 47 try { 48 return lg.getDNSQueryTransportHandler(req, dst, dport, src, sport, timeout, tcp); 49 } catch (Exception ex) { 50 err = ex; 51 return null; 52 } 53 } 54 executeQueries(DNSQueryTransportHandler [] qths)55 public void executeQueries(DNSQueryTransportHandler [] qths) { 56 err = null; 57 try { 58 lg.executeQueries(qths); 59 } catch (Exception ex) { 60 err = ex; 61 } 62 } 63 getDNSServers()64 public InetAddress [] getDNSServers() { 65 return new DNSSettings().getDNSServers(); 66 } 67 hasError()68 public boolean hasError() { 69 return err != null; 70 } 71 getError()72 public Exception getError() { 73 return err; 74 } 75 getErrorTrace()76 public String getErrorTrace() { 77 if (err == null) { 78 return null; 79 } 80 StringWriter sw = new StringWriter(); 81 PrintWriter pw = new PrintWriter(sw); 82 err.printStackTrace(pw); 83 return sw.toString(); 84 } 85 } 86