Merge 0.10->trunk
[prosody.git] / net / dns.lua
index b047ec542ec3813328d8ee2aaaaa153ba98316df..726b2b80db4ec324496862993f9acc82c79077ca 100644 (file)
@@ -22,8 +22,8 @@ local is_windows = (_ and windows) or os.getenv("WINDIR");
 local coroutine, io, math, string, table =
       coroutine, io, math, string, table;
 
-local ipairs, next, pairs, print, setmetatable, tostring, assert, error, unpack, select, type=
-      ipairs, next, pairs, print, setmetatable, tostring, assert, error, unpack, select, type;
+local ipairs, next, pairs, print, setmetatable, tostring, assert, error, select, type, unpack=
+      ipairs, next, pairs, print, setmetatable, tostring, assert, error, select, type, table.unpack or unpack;
 
 local ztact = { -- public domain 20080404 lua@ztact.com
        get = function(parent, ...)
@@ -190,7 +190,7 @@ end
 local rrs_metatable = {};    -- - - - - - - - - - - - - - - - - -  rrs_metatable
 function rrs_metatable.__tostring(rrs)
        local t = {};
-       for i,rr in ipairs(rrs) do
+       for _, rr in ipairs(rrs) do
                append(t, tostring(rr)..'\n');
        end
        return table.concat(t);
@@ -841,7 +841,7 @@ function resolver:receive(rset)    -- - - - - - - - - - - - - - - - -  receive
        rset = rset or self.socket;
 
        local response;
-       for i,sock in pairs(rset) do
+       for _, sock in pairs(rset) do
 
                if self.socketset[sock] then
                        local packet = sock:receive();
@@ -852,7 +852,7 @@ function resolver:receive(rset)    -- - - - - - - - - - - - - - - - -  receive
                                        --print('received response');
                                        --self.print(response);
 
-                                       for j,rr in pairs(response.answer) do
+                                       for _, rr in pairs(response.answer) do
                                                if rr.name:sub(-#response.question[1].name, -1) == response.question[1].name then
                                                        self:remember(rr, response.question[1].type)
                                                end
@@ -894,7 +894,7 @@ function resolver:feed(sock, packet, force)
                --print('received response');
                --self.print(response);
 
-               for j,rr in pairs(response.answer) do
+               for _, rr in pairs(response.answer) do
                        self:remember(rr, response.question[1].type);
                end
 
@@ -1011,7 +1011,7 @@ end
 
 
 function resolver.print(response)    -- - - - - - - - - - - - - resolver.print
-       for s,s in pairs { 'id', 'qr', 'opcode', 'aa', 'tc', 'rd', 'ra', 'z',
+       for _, s in pairs { 'id', 'qr', 'opcode', 'aa', 'tc', 'rd', 'ra', 'z',
                                                'rcode', 'qdcount', 'ancount', 'nscount', 'arcount' } do
                print( string.format('%-30s', 'header.'..s), response.header[s], hint(response.header, s) );
        end
@@ -1024,7 +1024,7 @@ function resolver.print(response)    -- - - - - - - - - - - - - resolver.print
 
        local common = { name=1, type=1, class=1, ttl=1, rdlength=1, rdata=1 };
        local tmp;
-       for s,s in pairs({'answer', 'authority', 'additional'}) do
+       for _, s in pairs({'answer', 'authority', 'additional'}) do
                for i,rr in pairs(response[s]) do
                        for j,t in pairs({ 'name', 'type', 'class', 'ttl', 'rdlength' }) do
                                tmp = string.format('%s[%i].%s', s, i, t);