Software /
code /
prosody
Diff
net/resolvers/service.lua @ 10440:1ee87b4979c2
net.resolvers.service: Pass IP literals directly to basic resolver
IP literals will not work with SRV records anyways.
Fixes s2s with IP literals.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 24 Nov 2019 04:43:14 +0100 |
parent | 10401:1ef1f6c43c5b |
child | 10484:b13a31cea7d9 |
line wrap: on
line diff
--- a/net/resolvers/service.lua Sun Nov 24 04:30:32 2019 +0100 +++ b/net/resolvers/service.lua Sun Nov 24 04:43:14 2019 +0100 @@ -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 @@ 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;