Mercurial > prosody-hg
comparison net/dns.lua @ 6632:855085439f7f
Merge 0.9->0.10
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 26 Apr 2015 00:06:44 +0200 |
| parents | 8273236a995f 45222bfb206f |
| children | 9795b8cf14f1 |
comparison
equal
deleted
inserted
replaced
| 6630:6735e2d735d6 | 6632:855085439f7f |
|---|---|
| 699 local function comp_mx(a, b) -- - - - - - - - - - - - - - - - - - - comp_mx | 699 local function comp_mx(a, b) -- - - - - - - - - - - - - - - - - - - comp_mx |
| 700 return (a.pref == b.pref) and (a.mx < b.mx) or (a.pref < b.pref); | 700 return (a.pref == b.pref) and (a.mx < b.mx) or (a.pref < b.pref); |
| 701 end | 701 end |
| 702 | 702 |
| 703 | 703 |
| 704 function resolver:peek (qname, qtype, qclass) -- - - - - - - - - - - - peek | 704 function resolver:peek (qname, qtype, qclass, n) -- - - - - - - - - - - - peek |
| 705 qname, qtype, qclass = standardize(qname, qtype, qclass); | 705 qname, qtype, qclass = standardize(qname, qtype, qclass); |
| 706 local rrs = get(self.cache, qclass, qtype, qname); | 706 local rrs = get(self.cache, qclass, qtype, qname); |
| 707 if not rrs then return nil; end | 707 if not rrs then |
| 708 if n then if n <= 0 then return end else n = 3 end | |
| 709 rrs = get(self.cache, qclass, "CNAME", qname); | |
| 710 if not (rrs and rrs[1]) then return end | |
| 711 return self:peek(rrs[1].cname, qtype, qclass, n - 1); | |
| 712 end | |
| 708 if prune(rrs, socket.gettime()) and qtype == '*' or not next(rrs) then | 713 if prune(rrs, socket.gettime()) and qtype == '*' or not next(rrs) then |
| 709 set(self.cache, qclass, qtype, qname, nil); | 714 set(self.cache, qclass, qtype, qname, nil); |
| 710 return nil; | 715 return nil; |
| 711 end | 716 end |
| 712 if self.unsorted[rrs] then table.sort (rrs, comp_mx); end | 717 if self.unsorted[rrs] then table.sort (rrs, comp_mx); self.unsorted[rrs] = nil; end |
| 713 return rrs; | 718 return rrs; |
| 714 end | 719 end |
| 715 | 720 |
| 716 | 721 |
| 717 function resolver:purge(soft) -- - - - - - - - - - - - - - - - - - - purge | 722 function resolver:purge(soft) -- - - - - - - - - - - - - - - - - - - purge |
