Comparison

net/dns.lua @ 6631:45222bfb206f

net.dns, mod_s2s: Add chasing of CNAMEs to net.dns and remove it from mod_s2s
author Kim Alvefur <zash@zash.se>
date Fri, 24 Apr 2015 14:14:01 +0200
parent 6509:7cb69eba3e95
child 6632:855085439f7f
child 6645:4f934cf03bc9
comparison
equal deleted inserted replaced
6601:debd9a7be528 6631:45222bfb206f
692 local function comp_mx(a, b) -- - - - - - - - - - - - - - - - - - - comp_mx 692 local function comp_mx(a, b) -- - - - - - - - - - - - - - - - - - - comp_mx
693 return (a.pref == b.pref) and (a.mx < b.mx) or (a.pref < b.pref); 693 return (a.pref == b.pref) and (a.mx < b.mx) or (a.pref < b.pref);
694 end 694 end
695 695
696 696
697 function resolver:peek (qname, qtype, qclass) -- - - - - - - - - - - - peek 697 function resolver:peek (qname, qtype, qclass, n) -- - - - - - - - - - - - peek
698 qname, qtype, qclass = standardize(qname, qtype, qclass); 698 qname, qtype, qclass = standardize(qname, qtype, qclass);
699 local rrs = get(self.cache, qclass, qtype, qname); 699 local rrs = get(self.cache, qclass, qtype, qname);
700 if not rrs then return nil; end 700 if not rrs then
701 if n then if n <= 0 then return end else n = 3 end
702 rrs = get(self.cache, qclass, "CNAME", qname);
703 if not (rrs and rrs[1]) then return end
704 return self:peek(rrs[1].cname, qtype, qclass, n - 1);
705 end
701 if prune(rrs, socket.gettime()) and qtype == '*' or not next(rrs) then 706 if prune(rrs, socket.gettime()) and qtype == '*' or not next(rrs) then
702 set(self.cache, qclass, qtype, qname, nil); 707 set(self.cache, qclass, qtype, qname, nil);
703 return nil; 708 return nil;
704 end 709 end
705 if self.unsorted[rrs] then table.sort (rrs, comp_mx); end 710 if self.unsorted[rrs] then table.sort (rrs, comp_mx); self.unsorted[rrs] = nil; end
706 return rrs; 711 return rrs;
707 end 712 end
708 713
709 714
710 function resolver:purge(soft) -- - - - - - - - - - - - - - - - - - - purge 715 function resolver:purge(soft) -- - - - - - - - - - - - - - - - - - - purge