Comparison

net/dns.lua @ 2762:2bddf8b766f7

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 2082:1381b2071c2e
child 2763:083430330585
comparison
equal deleted inserted replaced
2761:5d3ad9a6b3be 2762:2bddf8b766f7
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];