diff options
author | Richard van der Hoff <github@rvanderhoff.org.uk> | 2017-09-28 15:24:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-28 15:24:00 +0100 |
commit | 75e67b9ee4526bc8e5ffd9251ad0370604db13cb (patch) | |
tree | 903a854324d6f6cf176903a22cd63d7b80723b34 /synapse/http | |
parent | Up the limits on number of url cache entries to delete at one time (diff) | |
download | synapse-75e67b9ee4526bc8e5ffd9251ad0370604db13cb.tar.xz |
Handle SERVFAILs when doing AAAA lookups for federation (#2477)
... to cope with people with broken dnssec setups, mostly
Diffstat (limited to 'synapse/http')
-rw-r--r-- | synapse/http/endpoint.py | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/synapse/http/endpoint.py b/synapse/http/endpoint.py index 241b17f2cb..a97532162f 100644 --- a/synapse/http/endpoint.py +++ b/synapse/http/endpoint.py @@ -354,16 +354,28 @@ def _get_hosts_for_srv_record(dns_client, host): return res[0] - def eb(res): - res.trap(DNSNameError) - return [] + def eb(res, record_type): + if res.check(DNSNameError): + return [] + logger.warn("Error looking up %s for %s: %s", + record_type, host, res, res.value) + return res # no logcontexts here, so we can safely fire these off and gatherResults d1 = dns_client.lookupAddress(host).addCallbacks(cb, eb) d2 = dns_client.lookupIPV6Address(host).addCallbacks(cb, eb) - results = yield defer.gatherResults([d1, d2], consumeErrors=True) + results = yield defer.DeferredList( + [d1, d2], consumeErrors=True) + + # if all of the lookups failed, raise an exception rather than blowing out + # the cache with an empty result. + if results and all(s == defer.FAILURE for (s, _) in results): + defer.returnValue(results[0][1]) + + for (success, result) in results: + if success == defer.FAILURE: + continue - for result in results: for answer in result: if not answer.payload: continue |