Software /
code /
prosody
Diff
net/resolvers/basic.lua @ 11901:26406ce35e20
net.connect: Propagate last error message from resolvers
Previously it would only say "unable to resolve server" for all DNS
problems. While "NoError in A lookup" might not make much sense to
users, it should help in debugging more than the previous generic error.
Friendlier errors will be future work.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 12 Nov 2021 16:52:55 +0100 |
parent | 11708:5ef729c355f3 |
child | 12025:6ed7fd28f5e3 |
line wrap: on
line diff
--- a/net/resolvers/basic.lua Fri Nov 12 13:30:39 2021 +0000 +++ b/net/resolvers/basic.lua Fri Nov 12 16:52:55 2021 +0100 @@ -52,12 +52,17 @@ local dns_resolver = adns.resolver(); if not self.extra or self.extra.use_ipv4 ~= false then - dns_resolver:lookup(function (answer) + dns_resolver:lookup(function (answer, err) if answer then secure = secure and answer.secure; for _, record in ipairs(answer) do table.insert(targets, { self.conn_type.."4", record.a, self.port, self.extra }); end + if answer.status then + self.last_error = answer.status .. " in A lookup"; + end + else + self.last_error = err; end ready(); end, self.hostname, "A", "IN"); @@ -66,12 +71,17 @@ end if not self.extra or self.extra.use_ipv6 ~= false then - dns_resolver:lookup(function (answer) + dns_resolver:lookup(function (answer, err) if answer then secure = secure and answer.secure; for _, record in ipairs(answer) do table.insert(targets, { self.conn_type.."6", record.aaaa, self.port, self.extra }); end + if answer.status then + self.last_error = answer.status .. " in AAAA lookup"; + end + else + self.last_error = err; end ready(); end, self.hostname, "AAAA", "IN"); @@ -80,12 +90,17 @@ end if self.extra and self.extra.use_dane == true then - dns_resolver:lookup(function (answer) + dns_resolver:lookup(function (answer, err) if answer then secure = secure and answer.secure; for _, record in ipairs(answer) do table.insert(tlsa, record.tlsa); end + if answer.status then + self.last_error = answer.status .. " in TLSA lookup"; + end + else + self.last_error = err; end ready(); end, ("_%d._tcp.%s"):format(self.port, self.hostname), "TLSA", "IN");