From 7980a9964c475c99b937c46a9c01c6e893a49f8c Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 2 May 2018 19:06:59 +0200 Subject: net.resolvers.basic: Support IP address literals --- net/resolvers/basic.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'net/resolvers/basic.lua') 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) -- cgit v1.2.3