From 6ee22c5e8081157e9ac7e651111286c2b9a32285 Mon Sep 17 00:00:00 2001 From: Peter van Dijk Date: Fri, 13 May 2016 14:23:41 +0200 Subject: [PATCH] add simple stubquery tool for testing the stubresolver --- pdns/.gitignore | 1 + pdns/Makefile.am | 26 ++++++++++++++++++ pdns/stubquery.cc | 68 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 pdns/stubquery.cc diff --git a/pdns/.gitignore b/pdns/.gitignore index c11064050ba7..7ab506045035 100644 --- a/pdns/.gitignore +++ b/pdns/.gitignore @@ -59,3 +59,4 @@ effective_tld_names.dat /dnsmessage.pb.h /pdns.service /pdns.conf-dist +/stubquery diff --git a/pdns/Makefile.am b/pdns/Makefile.am index c71cb4c40bfe..a57f69bb09bb 100644 --- a/pdns/Makefile.am +++ b/pdns/Makefile.am @@ -90,6 +90,7 @@ bin_PROGRAMS += \ nproxy \ nsec3dig \ saxfr \ + stubquery \ ixplore \ sdig @@ -117,6 +118,7 @@ EXTRA_PROGRAMS = \ nproxy \ nsec3dig \ saxfr \ + stubquery \ sdig \ speedtest \ testrunner \ @@ -493,6 +495,30 @@ kvresp_SOURCES = \ unix_utility.cc \ qtype.cc +stubquery_SOURCES = \ + arguments.cc arguments.hh \ + base32.cc \ + base64.cc \ + dns_random.cc \ + dnslabeltext.cc \ + dnsname.cc \ + dnsparser.cc \ + dnsrecords.cc \ + dnswriter.cc \ + logger.cc \ + misc.cc \ + nsecrecords.cc \ + qtype.cc \ + rcpgenerator.cc \ + sillyrecords.cc \ + statbag.cc \ + stubresolver.cc stubresolver.hh \ + stubquery.cc \ + unix_utility.cc + +stubquery_LDADD = $(OPENSSL_LIBS) +stubquery_LDFLAGS = $(AM_LDFLAGS) $(OPENSSL_LDFLAGS) + saxfr_SOURCES = \ base32.cc \ base64.cc base64.hh \ diff --git a/pdns/stubquery.cc b/pdns/stubquery.cc new file mode 100644 index 000000000000..767328b4b8c5 --- /dev/null +++ b/pdns/stubquery.cc @@ -0,0 +1,68 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#include "arguments.hh" +#include "dnsrecords.hh" +#include "dns_random.hh" +#include "stubresolver.hh" +#include "statbag.hh" + +StatBag S; + +ArgvMap &arg() +{ + static ArgvMap theArg; + return theArg; +} + +void usage() { + cerr<<"stubquery"< ret; + + int res=stubDoResolve(argv[1], DNSRecordContent::TypeToNumber(argv[2]), ret); + + cout<<"res: "<