Software /
code /
prosody
Comparison
net/dns.lua @ 2300:e182b5029ef2
net.dns: Port some DNS fixes to the resolver:feed() function for net.adns to use
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 03 Dec 2009 01:10:08 +0000 |
parent | 2278:8c10f13c0c20 |
child | 2301:8a01b0898679 |
comparison
equal
deleted
inserted
replaced
2299:b7d25e1ac716 | 2300:e182b5029ef2 |
---|---|
766 function resolver:feed(sock, packet) | 766 function resolver:feed(sock, packet) |
767 --print('receive'); print(self.socket); | 767 --print('receive'); print(self.socket); |
768 self.time = socket.gettime(); | 768 self.time = socket.gettime(); |
769 | 769 |
770 local response = self:decode(packet); | 770 local response = self:decode(packet); |
771 if response then | 771 if response and self.active[response.header.id] |
772 and self.active[response.header.id][response.question.raw] then | |
772 --print('received response'); | 773 --print('received response'); |
773 --self.print(response); | 774 --self.print(response); |
774 | 775 |
775 for i,section in pairs({ 'answer', 'authority', 'additional' }) do | 776 for j,rr in pairs(response.answer) do |
776 for j,rr in pairs(response[section]) do | 777 self:remember(rr, response.question[1].type); |
777 self:remember(rr, response.question[1].type); | |
778 end | |
779 end | 778 end |
780 | 779 |
781 -- retire the query | 780 -- retire the query |
782 local queries = self.active[response.header.id]; | 781 local queries = self.active[response.header.id]; |
783 if queries[response.question.raw] then | 782 queries[response.question.raw] = nil; |
784 queries[response.question.raw] = nil; | |
785 end | |
786 if not next(queries) then self.active[response.header.id] = nil; end | 783 if not next(queries) then self.active[response.header.id] = nil; end |
787 if not next(self.active) then self:closeall(); end | 784 if not next(self.active) then self:closeall(); end |
788 | 785 |
789 -- was the query on the wanted list? | 786 -- was the query on the wanted list? |
790 local q = response.question[1]; | 787 local q = response.question[1]; |