3 @@ -342,6 +342,29 @@ static int doit(struct query *z,int stat
7 + if (typematch(DNS_T_SOA,dtype)) {
8 + byte_copy(key,2,DNS_T_SOA);
9 + cached = cache_get(key,dlen + 2,&cachedlen,&ttl);
10 + if (cached && (cachedlen || byte_diff(dtype,2,DNS_T_ANY))) {
11 + log_cachedanswer(d,DNS_T_SOA);
12 + if (!rqa(z)) goto DIE;
14 + while (pos = dns_packet_copy(cached,cachedlen,pos,misc,20)) {
15 + pos = dns_packet_getname(cached,cachedlen,pos,&t2);
17 + pos = dns_packet_getname(cached,cachedlen,pos,&t3);
19 + if (!response_rstart(d,DNS_T_SOA,ttl)) goto DIE;
20 + if (!response_addname(t2)) goto DIE;
21 + if (!response_addname(t3)) goto DIE;
22 + if (!response_addbytes(misc,20)) goto DIE;
23 + response_rfinish(RESPONSE_ANSWER);
30 if (typematch(DNS_T_A,dtype)) {
31 byte_copy(key,2,DNS_T_A);
32 cached = cache_get(key,dlen + 2,&cachedlen,&ttl);
33 @@ -374,7 +397,7 @@ static int doit(struct query *z,int stat
37 - if (!typematch(DNS_T_ANY,dtype) && !typematch(DNS_T_AXFR,dtype) && !typematch(DNS_T_NS,dtype) && !typematch(DNS_T_PTR,dtype) && !typematch(DNS_T_A,dtype) && !typematch(DNS_T_MX,dtype)) {
38 + if (!typematch(DNS_T_ANY,dtype) && !typematch(DNS_T_AXFR,dtype) && !typematch(DNS_T_NS,dtype) && !typematch(DNS_T_PTR,dtype) && !typematch(DNS_T_A,dtype) && !typematch(DNS_T_MX,dtype) && !typematch(DNS_T_SOA,dtype)) {
39 byte_copy(key,2,dtype);
40 cached = cache_get(key,dlen + 2,&cachedlen,&ttl);
41 if (cached && (cachedlen || byte_diff(dtype,2,DNS_T_ANY))) {
42 @@ -601,15 +624,24 @@ static int doit(struct query *z,int stat
43 else if (byte_equal(type,2,DNS_T_AXFR))
45 else if (byte_equal(type,2,DNS_T_SOA)) {
46 + int non_authority = 0;
49 pos = dns_packet_skipname(buf,len,records[i]); if (!pos) goto DIE;
50 pos = dns_packet_getname(buf,len,pos + 10,&t2); if (!pos) goto DIE;
51 pos = dns_packet_getname(buf,len,pos,&t3); if (!pos) goto DIE;
52 pos = dns_packet_copy(buf,len,pos,misc,20); if (!pos) goto DIE;
53 - if (records[i] < posauthority)
54 + if (records[i] < posauthority) {
55 log_rrsoa(whichserver,t1,t2,t3,misc,ttl);
57 + save_data(t2,dns_domain_length(t2));
58 + save_data(t3,dns_domain_length(t3));
64 + save_finish(DNS_T_SOA,t1,ttl);
66 else if (byte_equal(type,2,DNS_T_CNAME)) {
67 pos = dns_packet_skipname(buf,len,records[j - 1]); if (!pos) goto DIE;