aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-11-24 04:43:14 +0100
committerKim Alvefur <zash@zash.se>2019-11-24 04:43:14 +0100
commitae03335f0be444d9bc6e54326a616bf10456f358 (patch)
treefb877c19e1056a0edd4bac4fc35882190e05cf8e /net
parent42b9614fe2f8c1e248cea33f852d3a2639614996 (diff)
downloadprosody-ae03335f0be444d9bc6e54326a616bf10456f358.tar.gz
prosody-ae03335f0be444d9bc6e54326a616bf10456f358.zip
net.resolvers.service: Pass IP literals directly to basic resolver
IP literals will not work with SRV records anyways. Fixes s2s with IP literals.
Diffstat (limited to 'net')
-rw-r--r--net/resolvers/service.lua9
1 files changed, 9 insertions, 0 deletions
diff --git a/net/resolvers/service.lua b/net/resolvers/service.lua
index 65b086d2..504fb421 100644
--- a/net/resolvers/service.lua
+++ b/net/resolvers/service.lua
@@ -1,5 +1,6 @@
local adns = require "net.adns";
local basic = require "net.resolvers.basic";
+local inet_pton = require "util.net".pton;
local idna_to_ascii = require "util.encodings".idna.to_ascii;
local unpack = table.unpack or unpack; -- luacheck: ignore 113
@@ -69,6 +70,14 @@ function methods:next(cb)
end
local function new(hostname, service, conn_type, extra)
+ 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 and extra and extra.default_port then
+ return basic.new(hostname, extra.default_port, conn_type, extra);
+ end
+
return setmetatable({
hostname = idna_to_ascii(hostname);
service = service;