net.server_select: Close all connections when quitting (and not just stepping), match...
[prosody.git] / net / dns.lua
index 037f3ec666c202e9bb644b9221eddc75117dcf99..d893e38f5cc982cc4b3e9bf53a8a5e5f3dccdd42 100644 (file)
@@ -71,8 +71,8 @@ local get, set = ztact.get, ztact.set;
 local default_timeout = 15;
 
 -------------------------------------------------- module dns
-module('dns')
-local dns = _M;
+local _ENV = nil;
+local dns = {};
 
 
 -- dns type & class codes ------------------------------ dns type & class codes
@@ -213,15 +213,6 @@ function cache_metatable.__tostring(cache)
 end
 
 
-function resolver:new()    -- - - - - - - - - - - - - - - - - - - - - resolver
-       local r = { active = {}, cache = {}, unsorted = {} };
-       setmetatable(r, resolver);
-       setmetatable(r.cache, cache_metatable);
-       setmetatable(r.unsorted, { __mode = 'kv' });
-       return r;
-end
-
-
 -- packet layer -------------------------------------------------- packet layer
 
 
@@ -629,7 +620,7 @@ function resolver:getsocket(servernum)    -- - - - - - - - - - - - - getsocket
        if peer:find(":") then
                sock, err = socket.udp6();
        else
-               sock, err = socket.udp();
+               sock, err = (socket.udp4 or socket.udp)();
        end
        if sock and self.socket_wrapper then sock, err = self.socket_wrapper(sock, self); end
        if not sock then
@@ -862,9 +853,7 @@ function resolver:receive(rset)    -- - - - - - - - - - - - - - - - -  receive
                                        --self.print(response);
 
                                        for j,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
+                                               self:remember(rr, response.question[1].type)
                                        end
 
                                        -- retire the query
@@ -1054,8 +1043,6 @@ end
 
 
 function dns.resolver ()    -- - - - - - - - - - - - - - - - - - - - - resolver
-       -- this function seems to be redundant with resolver.new ()
-
        local r = { active = {}, cache = {}, unsorted = {}, wanted = {}, best_server = 1 };
        setmetatable (r, resolver);
        setmetatable (r.cache, cache_metatable);