net.dns: Normalize records before placing them in the cache, fixes issues with CNAME targets in CAPS (fixes #161)

Fri, 12 Feb 2010 15:05:48 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Fri, 12 Feb 2010 15:05:48 +0000
changeset 2620
481c6724818f
parent 2619
04158baefa34
child 2621
4d0f9f50fdd8

net.dns: Normalize records before placing them in the cache, fixes issues with CNAME targets in CAPS (fixes #161)

net/dns.lua file | annotate | diff | comparison | revisions
--- a/net/dns.lua	Fri Feb 12 15:02:57 2010 +0000
+++ b/net/dns.lua	Fri Feb 12 15:05:48 2010 +0000
@@ -594,17 +594,18 @@
 
 function resolver:remember(rr, type)    -- - - - - - - - - - - - - -  remember
 	--print ('remember', type, rr.class, rr.type, rr.name)
+	local qname, qtype, qclass = standardize(rr.name, rr.type, rr.class);
 
 	if type ~= '*' then
-		type = rr.type;
-		local all = get(self.cache, rr.class, '*', rr.name);
+		type = qtype;
+		local all = get(self.cache, qclass, '*', qname);
 		--print('remember all', all);
 		if all then append(all, rr); end
 	end
 
 	self.cache = self.cache or setmetatable({}, cache_metatable);
-	local rrs = get(self.cache, rr.class, type, rr.name) or
-		set(self.cache, rr.class, type, rr.name, setmetatable({}, rrs_metatable));
+	local rrs = get(self.cache, qclass, type, qname) or
+		set(self.cache, qclass, type, qname, setmetatable({}, rrs_metatable));
 	append(rrs, rr);
 
 	if type == 'MX' then self.unsorted[rrs] = true; end

mercurial