Software /
code /
prosody
Changeset
8775:ae7cf011e46a
net.resolvers.basic: Support IP address literals
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 02 May 2018 19:06:59 +0200 |
parents | 8774:cac4bd0d3335 |
children | 8776:e7d4344e0fea |
files | net/resolvers/basic.lua |
diffstat | 1 files changed, 11 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/net/resolvers/basic.lua Wed May 02 12:39:42 2018 +0200 +++ b/net/resolvers/basic.lua Wed May 02 19:06:59 2018 +0200 @@ -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 @@ 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)