Diff

net/dns.lua @ 4267:29d7eb6ff62c

net.dns: Support for resolving AAAA records
author Matthew Wild <mwild1@gmail.com>
date Mon, 16 May 2011 19:33:02 +0100
parent 4251:96e9d5f9ab3b
child 4373:9a20acf315c9
line wrap: on
line diff
--- a/net/dns.lua	Sat May 07 21:17:03 2011 +0500
+++ b/net/dns.lua	Mon May 16 19:33:02 2011 +0100
@@ -389,6 +389,14 @@
 	rr.a = string.format('%i.%i.%i.%i', b1, b2, b3, b4);
 end
 
+function resolver:AAAA(rr)
+	local addr = {};
+	for i = 1, rr.rdlength, 2 do
+		local b1, b2 = self:byte(2);
+		table.insert(addr, ("%02x%02x"):format(b1, b2));
+	end
+	rr.aaaa = table.concat(addr, ":");
+end
 
 function resolver:CNAME(rr)    -- - - - - - - - - - - - - - - - - - - -  CNAME
 	rr.cname = self:name();