Comparison

net/dns.lua @ 7500:4c519444d4a2

net.dns: remove unused one-letter loop variables [luacheck]
author Anton Shestakov <av6@dwimlabs.net>
date Thu, 14 Jul 2016 18:43:17 +0800
parent 7480:3dc7de31d3d1
child 7527:936b78e9f399
comparison
equal deleted inserted replaced
7499:b4f781ed7045 7500:4c519444d4a2
384 rr.a = string.format('%i.%i.%i.%i', b1, b2, b3, b4); 384 rr.a = string.format('%i.%i.%i.%i', b1, b2, b3, b4);
385 end 385 end
386 386
387 function resolver:AAAA(rr) 387 function resolver:AAAA(rr)
388 local addr = {}; 388 local addr = {};
389 for i = 1, rr.rdlength, 2 do 389 for _ = 1, rr.rdlength, 2 do
390 local b1, b2 = self:byte(2); 390 local b1, b2 = self:byte(2);
391 table.insert(addr, ("%02x%02x"):format(b1, b2)); 391 table.insert(addr, ("%02x%02x"):format(b1, b2));
392 end 392 end
393 addr = table.concat(addr, ":"):gsub("%f[%x]0+(%x)","%1"); 393 addr = table.concat(addr, ":"):gsub("%f[%x]0+(%x)","%1");
394 local zeros = {}; 394 local zeros = {};
521 end 521 end
522 522
523 523
524 function resolver:rrs (count) -- - - - - - - - - - - - - - - - - - - - - rrs 524 function resolver:rrs (count) -- - - - - - - - - - - - - - - - - - - - - rrs
525 local rrs = {}; 525 local rrs = {};
526 for i = 1,count do append(rrs, self:rr()); end 526 for _ = 1, count do append(rrs, self:rr()); end
527 return rrs; 527 return rrs;
528 end 528 end
529 529
530 530
531 function resolver:decode(packet, force) -- - - - - - - - - - - - - - decode 531 function resolver:decode(packet, force) -- - - - - - - - - - - - - - decode
534 if not header then return nil; end 534 if not header then return nil; end
535 local response = { header = header }; 535 local response = { header = header };
536 536
537 response.question = {}; 537 response.question = {};
538 local offset = self.offset; 538 local offset = self.offset;
539 for i = 1,response.header.qdcount do 539 for _ = 1, response.header.qdcount do
540 append(response.question, self:question()); 540 append(response.question, self:question());
541 end 541 end
542 response.question.raw = string.sub(self.packet, offset, self.offset - 1); 542 response.question.raw = string.sub(self.packet, offset, self.offset - 1);
543 543
544 if not force then 544 if not force then
1024 1024
1025 local common = { name=1, type=1, class=1, ttl=1, rdlength=1, rdata=1 }; 1025 local common = { name=1, type=1, class=1, ttl=1, rdlength=1, rdata=1 };
1026 local tmp; 1026 local tmp;
1027 for _, s in pairs({'answer', 'authority', 'additional'}) do 1027 for _, s in pairs({'answer', 'authority', 'additional'}) do
1028 for i,rr in pairs(response[s]) do 1028 for i,rr in pairs(response[s]) do
1029 for j,t in pairs({ 'name', 'type', 'class', 'ttl', 'rdlength' }) do 1029 for _, t in pairs({ 'name', 'type', 'class', 'ttl', 'rdlength' }) do
1030 tmp = string.format('%s[%i].%s', s, i, t); 1030 tmp = string.format('%s[%i].%s', s, i, t);
1031 print(string.format('%-30s', tmp), rr[t], hint(rr, t)); 1031 print(string.format('%-30s', tmp), rr[t], hint(rr, t));
1032 end 1032 end
1033 for j,t in pairs(rr) do 1033 for j,t in pairs(rr) do
1034 if not common[j] then 1034 if not common[j] then