def as_png(request, name): qtype = 'A' for qtype_ in recordtypes: if request.GET.get('show_%s' % qtype_, None): qtype = qtype_ try: query = DnsName.objects.get(name=name, qtype=qtype) except DnsName.DoesNotExist: raise Http404 with open(query.data_path) as fd: root = tracegraph.Zone.load('yaml', fd) skip = [x[5:] for x in request.GET if x.startswith('skip_')] graph = root.graph(skip=skip) return HttpResponse(shell.dot('-T', 'png', input="\n".join(graph)).stdout, content_type='image/png')
def as_png(request, name, qtype): format = request.GET.get('format', 'png') if format not in tracegraph.__dot_formats and format != 'raw': format = 'png' query = get_object_or_404(DnsName, name=name, qtype=qtype) if not os.path.exists(query.data_path): query.trace() return HttpResponseRedirect('./%s/' % qtype) with open(query.data_path) as fd: root = tracegraph.Zone.load('yaml', fd) skip = [x[5:] for x in request.GET if x.startswith('skip_')] graph = root.graph(skip=skip) if format == 'raw': return HttpResponse("\n".join(graph), content_type='text/plain') return HttpResponse(shell.dot('-T', format, input="\n".join(graph)).stdout, content_type='image/png')
def as_png(request, name): qtype = 'A' format = request.GET.get('format', 'png') if format not in tracegraph.__dot_formats and format != 'raw': format = 'png' for qtype_ in recordtypes: if request.GET.get('show_%s' % qtype_, None): qtype = qtype_ try: query = DnsName.objects.get(name=name, qtype=qtype) except DnsName.DoesNotExist: raise Http404 if not os.path.exists(query.data_path): raise Http404 with open(query.data_path) as fd: root = tracegraph.Zone.load('yaml', fd) skip = [x[5:] for x in request.GET if x.startswith('skip_')] graph = root.graph(skip=skip) if format == 'raw': return HttpResponse("\n".join(graph), content_type='text/plain') return HttpResponse(shell.dot('-T', format, input="\n".join(graph)).stdout, content_type='image/png')
name = dns.reversename.from_address(name).to_text() except dns.exception.SyntaxError: pass root = root() root.trace_missing_glue = opts.trace_missing_glue root.even_trace_m_gtld_servers_net = opts.even_trace_m_gtld_servers_net root.trace(name, rdtype=rdtype) if opts.dump: with open(opts.dump, 'w') as fd: root.dump(opts.format, fd) if opts.graph: graph = root.graph(skip=skip, errors_only=opts.errors_only) args = ["-T", opts.graph] if opts.output: args += ["-o", opts.output] if opts.display: pipe(pipe.dot(*args, input="\n".join(graph)) | pipe.display("-")) else: shell.dot(*args, input="\n".join(graph), stdout=sys.stdout) if opts.nagios: graph = root.graph(errors_only=True) nerrors = len([x for x in graph if '->' in x]) if nerrors: print("%d inconsistenies in the dns graph, run with -e -g png for details" % nerrors) sys.exit(2) else: print("DNS trace graph consistent")
pass root = root() root.trace_missing_glue = opts.trace_missing_glue root.even_trace_m_gtld_servers_net = opts.even_trace_m_gtld_servers_net root.trace(name, rdtype=rdtype) if opts.dump: with open(opts.dump, 'w') as fd: root.dump(opts.format, fd) if opts.graph: graph = root.graph(skip=skip, errors_only=opts.errors_only) args = ["-T", opts.graph] if opts.output: args += ["-o", opts.output] if opts.display: pipe(pipe.dot(*args, input="\n".join(graph)) | pipe.display("-")) else: shell.dot(*args, input="\n".join(graph), stdout=sys.stdout) if opts.nagios: graph = root.graph(errors_only=True) nerrors = len([x for x in graph if '->' in x]) if nerrors: print( "%d inconsistenies in the dns graph, run with -e -g png for details" % nerrors) sys.exit(2) else: print("DNS trace graph consistent")