]> git.ipfire.org Git - thirdparty/pdns.git/blame - pdns/stubquery.cc
dnsdist: Add HTTPStatusAction to return a specific HTTP response
[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
62ec3c21 41 if(argc <= 1) {
6ee22c5e
PD
42 usage();
43 exit(EXIT_FAILURE);
44 }
45
62ec3c21
OM
46 string type(argc == 2 ? "A" : argv[2]);
47
8eccac19 48 ::arg().set("resolver","Use this resolver for ALIAS and the internal stub resolver")="no";
6ee22c5e
PD
49
50 reportAllTypes();
6ee22c5e
PD
51 stubParseResolveConf();
52
c47b819d 53 vector<DNSZoneRecord> ret;
6ee22c5e 54
62ec3c21 55 int res=stubDoResolve(DNSName(argv[1]), DNSRecordContent::TypeToNumber(type), ret);
6ee22c5e
PD
56
57 cout<<"res: "<<res<<endl;
58 for(const auto& r : ret) {
c47b819d 59 cout<<r.dr.d_content->getZoneRepresentation()<<endl;
6ee22c5e
PD
60 }
61}
62catch(std::exception &e)
63{
64 cerr<<"Fatal: "<<e.what()<<endl;
65}
66catch(PDNSException &e)
67{
68 cerr<<"Fatal: "<<e.reason<<endl;
69}