Software /
code /
prosody
Changeset
13121:332e95f75dbb 0.12
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.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 31 May 2023 14:08:19 +0200 |
parents | 13110:d5f322dd424b |
children | 13122:45458ecaacae 13138:0b0cefce6e42 |
files | util/prosodyctl/check.lua |
diffstat | 1 files changed, 5 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/util/prosodyctl/check.lua Thu Aug 18 03:26:32 2022 +0200 +++ b/util/prosodyctl/check.lua Wed May 31 14:08:19 2023 +0200 @@ -751,16 +751,17 @@ 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);