diff options
author | Kim Alvefur <zash@zash.se> | 2018-05-02 19:06:59 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2018-05-02 19:06:59 +0200 |
commit | 7980a9964c475c99b937c46a9c01c6e893a49f8c (patch) | |
tree | b9e1abe8685f51d9eb83406e709a503d527e2ec0 | |
parent | 790c2bef87207f4e82b39c99ead732cabfcc48f4 (diff) | |
download | prosody-7980a9964c475c99b937c46a9c01c6e893a49f8c.tar.gz prosody-7980a9964c475c99b937c46a9c01c6e893a49f8c.zip |
net.resolvers.basic: Support IP address literals
-rw-r--r-- | net/resolvers/basic.lua | 11 |
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) |