]>
Commit | Line | Data |
---|---|---|
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 | ||
10 | StatBag S; | |
11 | ||
12 | ArgvMap &arg() | |
13 | { | |
14 | static ArgvMap theArg; | |
15 | return theArg; | |
16 | } | |
17 | ||
18 | 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 < 2) { | |
42 | usage(); | |
43 | exit(EXIT_FAILURE); | |
44 | } | |
45 | ||
46 | ::arg().set("recursor","If recursion is desired, IP address of a recursing nameserver")="no"; | |
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 | } | |
61 | catch(std::exception &e) | |
62 | { | |
63 | cerr<<"Fatal: "<<e.what()<<endl; | |
64 | } | |
65 | catch(PDNSException &e) | |
66 | { | |
67 | cerr<<"Fatal: "<<e.reason<<endl; | |
68 | } |