Software /
code /
prosody
Comparison
util/prosodyctl/check.lua @ 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 |
parent | 12898:4255db0f8e58 |
child | 13122:45458ecaacae |
child | 13216:fcc052ca1652 |
comparison
equal
deleted
inserted
replaced
13110:d5f322dd424b | 13121:332e95f75dbb |
---|---|
749 | 749 |
750 local external_addresses, internal_addresses = set.new(), set.new(); | 750 local external_addresses, internal_addresses = set.new(), set.new(); |
751 | 751 |
752 local fqdn = socket.dns.tohostname(socket.dns.gethostname()); | 752 local fqdn = socket.dns.tohostname(socket.dns.gethostname()); |
753 if fqdn then | 753 if fqdn then |
754 do | 754 local fqdn_a = idna.to_ascii(fqdn); |
755 local res = dns.lookup(idna.to_ascii(fqdn), "A"); | 755 if fqdn_a then |
756 local res = dns.lookup(fqdn_a, "A"); | |
756 if res then | 757 if res then |
757 for _, record in ipairs(res) do | 758 for _, record in ipairs(res) do |
758 external_addresses:add(record.a); | 759 external_addresses:add(record.a); |
759 end | 760 end |
760 end | 761 end |
761 end | 762 end |
762 do | 763 if fqdn_a then |
763 local res = dns.lookup(idna.to_ascii(fqdn), "AAAA"); | 764 local res = dns.lookup(fqdn_a, "AAAA"); |
764 if res then | 765 if res then |
765 for _, record in ipairs(res) do | 766 for _, record in ipairs(res) do |
766 external_addresses:add(record.aaaa); | 767 external_addresses:add(record.aaaa); |
767 end | 768 end |
768 end | 769 end |