aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2023-05-31 14:08:19 +0200
committerKim Alvefur <zash@zash.se>2023-05-31 14:08:19 +0200
commite4d5c1539653bf3e618618b06aed0180332a1dbf (patch)
treed9fc5eb2f2ea5f86043e51b6f28a5bdf087a1277 /util
parent20afe7d20dfde84a9deb6ed4f85a6e7a9429f09c (diff)
downloadprosody-e4d5c1539653bf3e618618b06aed0180332a1dbf.tar.gz
prosody-e4d5c1539653bf3e618618b06aed0180332a1dbf.zip
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.
Diffstat (limited to 'util')
-rw-r--r--util/prosodyctl/check.lua9
1 files changed, 5 insertions, 4 deletions
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);