]> git.ipfire.org Git - thirdparty/pdns.git/blame - pdns/stubquery.cc
Merge pull request #5523 from rubenk/fix-typos-in-logmessage
[thirdparty/pdns.git] / pdns / stubquery.cc
CommitLineData
6ee22c5e
PD
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#endif
4#include "arguments.hh"
5#include "dnsrecords.hh"
6#include "dns_random.hh"
7#include "stubresolver.hh"
8#include "statbag.hh"
9
10StatBag S;
11
12ArgvMap &arg()
13{
14 static ArgvMap theArg;
15 return theArg;
16}
17
18void usage() {
19 cerr<<"stubquery"<<endl;
20 cerr<<"Syntax: stubquery QUESTION [QUESTION-TYPE]"<<endl;
21}
22
23int main(int argc, char** argv)
24try
25{
26 DNSName qname;
27 QType qtype;
28
29 for(int i=1; i<argc; i++) {
30 if ((string) argv[i] == "--help") {
31 usage();
32 exit(EXIT_SUCCESS);
33 }
34
35 if ((string) argv[i] == "--version") {
36 cerr<<"stubquery "<<VERSION<<endl;
37 exit(EXIT_SUCCESS);
38 }
39 }
40
41 if(argc < 2) {
42 usage();
43 exit(EXIT_FAILURE);
44 }
45
8eccac19 46 ::arg().set("resolver","Use this resolver for ALIAS and the internal stub resolver")="no";
6ee22c5e
PD
47
48 reportAllTypes();
49 dns_random_init("0123456789abcdef");
50 stubParseResolveConf();
51
c47b819d 52 vector<DNSZoneRecord> ret;
6ee22c5e 53
c47b819d 54 int res=stubDoResolve(DNSName(argv[1]), DNSRecordContent::TypeToNumber(argv[2]), ret);
6ee22c5e
PD
55
56 cout<<"res: "<<res<<endl;
57 for(const auto& r : ret) {
c47b819d 58 cout<<r.dr.d_content->getZoneRepresentation()<<endl;
6ee22c5e
PD
59 }
60}
61catch(std::exception &e)
62{
63 cerr<<"Fatal: "<<e.what()<<endl;
64}
65catch(PDNSException &e)
66{
67 cerr<<"Fatal: "<<e.reason<<endl;
68}