aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-11-24 04:30:32 +0100
committerKim Alvefur <zash@zash.se>2019-11-24 04:30:32 +0100
commit3b8df57d563f91fe8b117fc347321bee58a81549 (patch)
tree8dfb11678b089cc7186d0175f603f1ae1ffbbb46
parentf1816201f19c73650056e681ade9a3196d9d39c8 (diff)
parenta5450086e824443cff04adc9ed5ec3cca8301151 (diff)
downloadprosody-3b8df57d563f91fe8b117fc347321bee58a81549.tar.gz
prosody-3b8df57d563f91fe8b117fc347321bee58a81549.zip
Merge 0.11->trunk
-rw-r--r--net/resolvers/basic.lua28
1 files changed, 17 insertions, 11 deletions
diff --git a/net/resolvers/basic.lua b/net/resolvers/basic.lua
index 2499178a..147d2858 100644
--- a/net/resolvers/basic.lua
+++ b/net/resolvers/basic.lua
@@ -34,16 +34,6 @@ function methods:next(cb)
self:next(cb);
end
- local is_ip = inet_pton(self.hostname);
- if is_ip then
- if #is_ip == 16 then
- cb(self.conn_type.."6", self.hostname, self.port, self.extra);
- elseif #is_ip == 4 then
- cb(self.conn_type.."4", self.hostname, self.port, self.extra);
- end
- return;
- end
-
-- Resolve DNS to target list
local dns_resolver = adns.resolver();
dns_resolver:lookup(function (answer)
@@ -66,11 +56,27 @@ function methods:next(cb)
end
local function new(hostname, port, conn_type, extra)
+ local ascii_host = idna_to_ascii(hostname);
+ local targets = nil;
+
+ local is_ip = inet_pton(hostname);
+ if not is_ip and hostname:sub(1,1) == '[' then
+ is_ip = inet_pton(hostname:sub(2,-2));
+ end
+ if is_ip then
+ if #is_ip == 16 then
+ targets = { { conn_type.."6", hostname, port, extra } };
+ elseif #is_ip == 4 then
+ targets = { { conn_type.."4", hostname, port, extra } };
+ end
+ end
+
return setmetatable({
- hostname = idna_to_ascii(hostname);
+ hostname = ascii_host;
port = port;
conn_type = conn_type or "tcp";
extra = extra;
+ targets = targets;
}, resolver_mt);
end