Comparison

util/prosodyctl/check.lua @ 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
parent 13841:d01cfbb7fc4f
comparison
equal deleted inserted replaced
13869:f44f2a8a8c37 13870:8078eebf5601
1094 if target_hosts:contains("localhost") then 1094 if target_hosts:contains("localhost") then
1095 print(" Target 'localhost' cannot be accessed from other servers"); 1095 print(" Target 'localhost' cannot be accessed from other servers");
1096 target_hosts:remove("localhost"); 1096 target_hosts:remove("localhost");
1097 end 1097 end
1098 1098
1099 local function check_record(name, rtype)
1100 local res, err = dns.lookup(name, rtype);
1101 if err then
1102 print(" Problem looking up "..rtype.." record for '"..name.."': "..err);
1103 elseif res and res.bogus then
1104 print(" Problem looking up "..rtype.." record for '"..name.."': "..res.bogus);
1105 elseif res and res.rcode and res.rcode ~= 0 and res.rcode ~= 3 then
1106 print(" Problem looking up "..rtype.." record for '"..name.."': "..res.status);
1107 end
1108 return res and #res > 0;
1109 end
1110
1099 local function check_address(target) 1111 local function check_address(target)
1100 local A, AAAA = dns.lookup(idna.to_ascii(target), "A"), dns.lookup(idna.to_ascii(target), "AAAA");
1101 local prob = {}; 1112 local prob = {};
1102 if use_ipv4 and not (A and #A > 0) then table.insert(prob, "A"); end 1113 local aname = idna.to_ascii(target);
1103 if use_ipv6 and not (AAAA and #AAAA > 0) then table.insert(prob, "AAAA"); end 1114 if not aname then
1115 print(" '" .. target .. "' is not a valid hostname");
1116 return prob;
1117 end
1118 if use_ipv4 and not check_record(aname, "A") then table.insert(prob, "A"); end
1119 if use_ipv6 and not check_record(aname, "AAAA") then table.insert(prob, "AAAA"); end
1104 return prob; 1120 return prob;
1105 end 1121 end
1106 1122
1107 if modules:contains("proxy65") then 1123 if modules:contains("proxy65") then
1108 local proxy65_target = api(host):get_option_string("proxy65_address", host); 1124 local proxy65_target = api(host):get_option_string("proxy65_address", host);