]>
git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/tsig-tests.cc
4 #include "dnsparser.hh"
5 #include "dnswriter.hh"
8 #include "dnswriter.hh"
9 #include "dnsrecords.hh"
13 #include "dnssecinfra.hh"
14 #include "axfr-retriever.hh"
15 #include "arguments.hh"
16 #include "dns_random.hh"
17 #include "query-local-address.hh"
23 static ArgvMap theArg
;
27 int main(int argc
, char** argv
)
30 pdns::parseQueryLocalAddress(":: 0.0.0.0");
35 cerr
<<"tsig-tests: ask a TSIG signed question, verify the TSIG signed answer"<<endl
;
36 cerr
<<"Syntax: tsig IP-address port question question-type\n";
40 vector
<uint8_t> packet
;
42 DNSPacketWriter
pw(packet
, DNSName(argv
[3]), DNSRecordContent::TypeToNumber(argv
[4]));
44 pw
.getHeader()->id
=htons(0x4831);
47 B64Decode("Syq9L9WrBWdxBC+HxKok2g==", key
);
49 DNSName
keyname("pdns-b-aa");
51 TSIGRecordContent trc
;
52 trc
.d_algoName
=DNSName("hmac-md5.sig-alg.reg.int");
55 trc
.d_origID
=ntohs(pw
.getHeader()->id
);
58 addTSIG(pw
, trc
, keyname
, key
, "", false);
60 Socket
sock(AF_INET
, SOCK_DGRAM
);
61 ComboAddress
dest(argv
[1] + (*argv
[1]=='@'), atoi(argv
[2]));
62 cerr
<<"Keyname: '"<<keyname
<<"', algo: '"<<trc
.d_algoName
<<"', key: '"<<Base64Encode(key
)<<"'\n";
65 tt
.algo
=DNSName("hmac-md5");
67 AXFRRetriever
axfr(dest
, DNSName("b.aa"), tt
);
68 vector
<DNSResourceRecord
> res
;
69 while(axfr
.getChunk(res
)) {
73 catch(std::exception
&e
)
75 cerr
<<"Fatal: "<<e
.what()<<endl
;
78 catch(PDNSException
& ae
)
80 cerr
<<"Fatal 2: "<<ae
.reason
<<endl
;