aboutsummaryrefslogtreecommitdiffstats
path: root/net/dns.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2013-06-29 14:45:47 +0100
committerMatthew Wild <mwild1@gmail.com>2013-06-29 14:45:47 +0100
commit1ff17bd2f363d64e96b5f55c40da0768eb2931a0 (patch)
tree27741db74d498be76001287c8a4e6a9076bb5a27 /net/dns.lua
parentd9d3fda27d4cbd522bbf2b53bb22c7659020a0c7 (diff)
parent237fbdb8e53b39063c1df36d94f59695d80c2de2 (diff)
downloadprosody-1ff17bd2f363d64e96b5f55c40da0768eb2931a0.tar.gz
prosody-1ff17bd2f363d64e96b5f55c40da0768eb2931a0.zip
Merge
Diffstat (limited to 'net/dns.lua')
-rw-r--r--net/dns.lua19
1 files changed, 13 insertions, 6 deletions
diff --git a/net/dns.lua b/net/dns.lua
index 89b50255..bd42db73 100644
--- a/net/dns.lua
+++ b/net/dns.lua
@@ -14,6 +14,7 @@
local socket = require "socket";
local timer = require "util.timer";
+local new_ip = require "util.ip".new_ip;
local _, windows = pcall(require, "util.windows");
local is_windows = (_ and windows) or os.getenv("WINDIR");
@@ -597,11 +598,12 @@ function resolver:adddefaultnameservers() -- - - - - adddefaultnameservers
if resolv_conf then
for line in resolv_conf:lines() do
line = line:gsub("#.*$", "")
- :match('^%s*nameserver%s+(.*)%s*$');
+ :match('^%s*nameserver%s+([%x:%.]*)%s*$');
if line then
- line:gsub("%f[%d.](%d+%.%d+%.%d+%.%d+)%f[^%d.]", function (address)
- self:addnameserver(address)
- end);
+ local ip = new_ip(line);
+ if ip then
+ self:addnameserver(ip.addr);
+ end
end
end
end
@@ -621,7 +623,12 @@ function resolver:getsocket(servernum) -- - - - - - - - - - - - - getsocket
if sock then return sock; end
local err;
- sock, err = socket.udp();
+ local peer = self.server[servernum];
+ if peer:find(":") then
+ sock, err = socket.udp6();
+ else
+ sock, err = socket.udp();
+ end
if not sock then
return nil, err;
end
@@ -629,7 +636,7 @@ function resolver:getsocket(servernum) -- - - - - - - - - - - - - getsocket
sock:settimeout(0);
-- todo: attempt to use a random port, fallback to 0
sock:setsockname('*', 0);
- sock:setpeername(self.server[servernum], 53);
+ sock:setpeername(peer, 53);
self.socket[servernum] = sock;
self.socketset[sock] = servernum;
return sock;