Diff

net/dns.lua @ 2212:7cb6460b18d8

Merge with trunk.
author Tobias Markmann <tm@ayena.de>
date Thu, 19 Nov 2009 17:53:52 +0100
parent 2082:1381b2071c2e
child 2278:8c10f13c0c20
child 2762:2bddf8b766f7
child 2856:70e6ea49aff3
line wrap: on
line diff
--- a/net/dns.lua	Thu Nov 19 17:20:38 2009 +0100
+++ b/net/dns.lua	Thu Nov 19 17:53:52 2009 +0100
@@ -726,21 +726,21 @@
 			local packet = sock:receive();
 			if packet then
 				response = self:decode(packet);
-				if response then
+				if response and self.active[response.header.id] 
+					and self.active[response.header.id][response.question.raw] then
 					--print('received response');
 					--self.print(response);
 
-					for i,section in pairs({ 'answer', 'authority', 'additional' }) do
-						for j,rr in pairs(response[section]) do
+					for j,rr in pairs(response.answer) do
+						if rr.name:sub(-#response.question[1].name, -1) == response.question[1].name then
 							self:remember(rr, response.question[1].type)
 						end
 					end
 
 					-- retire the query
 					local queries = self.active[response.header.id];
-					if queries[response.question.raw] then
-						queries[response.question.raw] = nil;
-					end
+					queries[response.question.raw] = nil;
+					
 					if not next(queries) then self.active[response.header.id] = nil; end
 					if not next(self.active) then self:closeall(); end