Comparison

net/dns.lua @ 2856:70e6ea49aff3

net.dns: Normalize records before placing them in the cache, fixes issues with CNAME targets in CAPS (fixes #161)
author Matthew Wild <mwild1@gmail.com>
date Fri, 12 Feb 2010 15:05:48 +0000
parent 2082:1381b2071c2e
child 2877:1edeb8fe7d14
comparison
equal deleted inserted replaced
2855:66a1aa0bedc0 2856:70e6ea49aff3
592 end 592 end
593 593
594 594
595 function resolver:remember(rr, type) -- - - - - - - - - - - - - - remember 595 function resolver:remember(rr, type) -- - - - - - - - - - - - - - remember
596 --print ('remember', type, rr.class, rr.type, rr.name) 596 --print ('remember', type, rr.class, rr.type, rr.name)
597 local qname, qtype, qclass = standardize(rr.name, rr.type, rr.class);
597 598
598 if type ~= '*' then 599 if type ~= '*' then
599 type = rr.type; 600 type = qtype;
600 local all = get(self.cache, rr.class, '*', rr.name); 601 local all = get(self.cache, qclass, '*', qname);
601 --print('remember all', all); 602 --print('remember all', all);
602 if all then append(all, rr); end 603 if all then append(all, rr); end
603 end 604 end
604 605
605 self.cache = self.cache or setmetatable({}, cache_metatable); 606 self.cache = self.cache or setmetatable({}, cache_metatable);
606 local rrs = get(self.cache, rr.class, type, rr.name) or 607 local rrs = get(self.cache, qclass, type, qname) or
607 set(self.cache, rr.class, type, rr.name, setmetatable({}, rrs_metatable)); 608 set(self.cache, qclass, type, qname, setmetatable({}, rrs_metatable));
608 append(rrs, rr); 609 append(rrs, rr);
609 610
610 if type == 'MX' then self.unsorted[rrs] = true; end 611 if type == 'MX' then self.unsorted[rrs] = true; end
611 end 612 end
612 613