Comparison

net/dns.lua @ 8421:3d21c63ec03f

net.dns: Don't compress a single zero group in IPv6 addresses to match behaviour of inet_ntop
author Kim Alvefur <zash@zash.se>
date Fri, 01 Dec 2017 04:50:20 +0100
parent 8263:9b52b1f19b51
child 8440:4e6710b4f873
child 8897:102242a7ee60
comparison
equal deleted inserted replaced
8420:fb27aff6d491 8421:3d21c63ec03f
388 local b1, b2 = self:byte(2); 388 local b1, b2 = self:byte(2);
389 table.insert(addr, ("%02x%02x"):format(b1, b2)); 389 table.insert(addr, ("%02x%02x"):format(b1, b2));
390 end 390 end
391 addr = table.concat(addr, ":"):gsub("%f[%x]0+(%x)","%1"); 391 addr = table.concat(addr, ":"):gsub("%f[%x]0+(%x)","%1");
392 local zeros = {}; 392 local zeros = {};
393 for item in addr:gmatch(":[0:]+:") do 393 for item in addr:gmatch(":[0:]+:[0:]+:") do
394 table.insert(zeros, item) 394 table.insert(zeros, item)
395 end 395 end
396 if #zeros == 0 then 396 if #zeros == 0 then
397 rr.aaaa = addr; 397 rr.aaaa = addr;
398 return 398 return