]> git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/stubquery.cc
rec: allow exception to proxy protocal usage for specific listen addresses
[thirdparty/pdns.git] / pdns / stubquery.cc
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
10 StatBag S;
11
12 ArgvMap &arg()
13 {
14 static ArgvMap theArg;
15 return theArg;
16 }
17
18 static void usage() {
19 cerr<<"stubquery"<<endl;
20 cerr<<"Syntax: stubquery QUESTION [QUESTION-TYPE]"<<endl;
21 }
22
23 int main(int argc, char** argv)
24 try
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 <= 1) {
42 usage();
43 exit(EXIT_FAILURE);
44 }
45
46 string type(argc == 2 ? "A" : argv[2]);
47
48 ::arg().set("resolver","Use this resolver for ALIAS and the internal stub resolver")="no";
49
50 reportAllTypes();
51 stubParseResolveConf();
52
53 vector<DNSZoneRecord> ret;
54
55 int res=stubDoResolve(DNSName(argv[1]), DNSRecordContent::TypeToNumber(type), ret);
56
57 cout<<"res: "<<res<<endl;
58 for(const auto& r : ret) {
59 cout<<r.dr.getContent()->getZoneRepresentation()<<endl;
60 }
61 }
62 catch(std::exception &e)
63 {
64 cerr<<"Fatal: "<<e.what()<<endl;
65 }
66 catch(PDNSException &e)
67 {
68 cerr<<"Fatal: "<<e.reason<<endl;
69 }