Software /
code /
prosody
Changeset
13870:8078eebf5601 13.0
util.prosodyctl.check: Improve reporting of DNS lookup problems
Closes #1931
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 05 May 2025 15:05:53 +0200 |
parents | 13869:f44f2a8a8c37 |
children | 13871:9eee04a95a25 |
files | util/prosodyctl/check.lua |
diffstat | 1 files changed, 19 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/util/prosodyctl/check.lua Mon Apr 28 19:41:19 2025 +0200 +++ b/util/prosodyctl/check.lua Mon May 05 15:05:53 2025 +0200 @@ -1096,11 +1096,27 @@ target_hosts:remove("localhost"); end + local function check_record(name, rtype) + local res, err = dns.lookup(name, rtype); + if err then + print(" Problem looking up "..rtype.." record for '"..name.."': "..err); + elseif res and res.bogus then + print(" Problem looking up "..rtype.." record for '"..name.."': "..res.bogus); + elseif res and res.rcode and res.rcode ~= 0 and res.rcode ~= 3 then + print(" Problem looking up "..rtype.." record for '"..name.."': "..res.status); + end + return res and #res > 0; + end + local function check_address(target) - local A, AAAA = dns.lookup(idna.to_ascii(target), "A"), dns.lookup(idna.to_ascii(target), "AAAA"); local prob = {}; - if use_ipv4 and not (A and #A > 0) then table.insert(prob, "A"); end - if use_ipv6 and not (AAAA and #AAAA > 0) then table.insert(prob, "AAAA"); end + local aname = idna.to_ascii(target); + if not aname then + print(" '" .. target .. "' is not a valid hostname"); + return prob; + end + if use_ipv4 and not check_record(aname, "A") then table.insert(prob, "A"); end + if use_ipv6 and not check_record(aname, "AAAA") then table.insert(prob, "AAAA"); end return prob; end