From e4d5c1539653bf3e618618b06aed0180332a1dbf Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 31 May 2023 14:08:19 +0200 Subject: util.prosodyctl.check: Fix error where hostname can't be turned into A label Where gethostname or tohostname returns an invalid name, e.g. containing underscores or something, to_ascii would reject this and return nil, which triggers an error in the dns lookup. Reported by prova2 in the chat, for whom tohostname returned a long name containing underscores. --- util/prosodyctl/check.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'util') diff --git a/util/prosodyctl/check.lua b/util/prosodyctl/check.lua index 2fd3c784..2e3fb6d8 100644 --- a/util/prosodyctl/check.lua +++ b/util/prosodyctl/check.lua @@ -751,16 +751,17 @@ local function check(arg) local fqdn = socket.dns.tohostname(socket.dns.gethostname()); if fqdn then - do - local res = dns.lookup(idna.to_ascii(fqdn), "A"); + local fqdn_a = idna.to_ascii(fqdn); + if fqdn_a then + local res = dns.lookup(fqdn_a, "A"); if res then for _, record in ipairs(res) do external_addresses:add(record.a); end end end - do - local res = dns.lookup(idna.to_ascii(fqdn), "AAAA"); + if fqdn_a then + local res = dns.lookup(fqdn_a, "AAAA"); if res then for _, record in ipairs(res) do external_addresses:add(record.aaaa); -- cgit v1.2.3