aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-05-02 19:06:59 +0200
committerKim Alvefur <zash@zash.se>2018-05-02 19:06:59 +0200
commit5cb2160a0bf9ac45cb57e3a8d1c1ae5ea56e95c1 (patch)
treeb9e1abe8685f51d9eb83406e709a503d527e2ec0
parent31c92dfc4b0811cbdbdb2dc6b7ada31b14406488 (diff)
downloadprosody-5cb2160a0bf9ac45cb57e3a8d1c1ae5ea56e95c1.tar.gz
prosody-5cb2160a0bf9ac45cb57e3a8d1c1ae5ea56e95c1.zip
net.resolvers.basic: Support IP address literals
-rw-r--r--net/resolvers/basic.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/net/resolvers/basic.lua b/net/resolvers/basic.lua
index 792e6d32..c2fd9260 100644
--- a/net/resolvers/basic.lua
+++ b/net/resolvers/basic.lua
@@ -1,4 +1,5 @@
local adns = require "net.adns";
+local inet_pton = require "util.net".pton;
local methods = {};
local resolver_mt = { __index = methods };
@@ -25,6 +26,16 @@ 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, self.hostname, self.port, self.extra);
+ end
+ return;
+ end
+
-- Resolve DNS to target list
local dns_resolver = adns.resolver();
dns_resolver:lookup(function (answer)